{"id":804,"date":"2023-07-14T20:24:32","date_gmt":"2023-07-14T23:24:32","guid":{"rendered":"https:\/\/freeshell.de\/~felipe\/blog\/?p=804"},"modified":"2024-06-21T04:02:30","modified_gmt":"2024-06-21T07:02:30","slug":"streamline-package-distribution-with-aur-and-brew-leveraging-the-power-of-github","status":"publish","type":"post","link":"https:\/\/freeshell.de\/~felipe\/blog\/07\/2023\/linux\/streamline-package-distribution-with-aur-and-brew-leveraging-the-power-of-github\/","title":{"rendered":"Streamline Package Distribution with AUR and Brew: Leveraging the Power of GitHub"},"content":{"rendered":"\n<p>It&#8217;s crucial to have a repository on GitHub for seamless development and collaboration. In the case of Arch Linux&#8217;s AUR, creating an account on <a href=\"https:\/\/aur.archlinux.org\/\">aur.archlinux.org<\/a> is essential. Additionally, generating and configuring an SSH key pair linked to the AUR account is crucial. Here&#8217;s how you can set it up:<\/p>\n\n\n\n<p>Create the <code>~\/.ssh\/config<\/code> file with the following content:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Host aur.archlinux.org\nIdentityFile ~\/.ssh\/aur\nUser aur<\/code><\/pre>\n\n\n\n<p>Generate the SSH keys:<\/p>\n\n\n\n<p>ssh-keygen -f ~\/.ssh\/aur<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">ssh-keygen -b 4096 (RSA)\n\nThis command will create a public key in the specified folder.\n\nNext, let's create the AUR repository (which is separate from the GitHub repository for our project):<\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>git -c init.defaultbranch=master clone ssh:\/\/aur@aur.archlinux.org\/pkgbase.git<\/code><\/pre>\n\n\n\n<p>You may receive a warning about cloning an empty repository, but don&#8217;t worry. Now, you can place the binaries, tarball, or any files related to the installation of the project inside this folder.<\/p>\n\n\n\n<p>To proceed, add a remote label to your repository (Inside of it):<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>git remote add label ssh:\/\/aur@aur.archlinux.org\/pkgbase.git<\/code><\/pre>\n\n\n\n<p>Replace <code>pkgbase<\/code> with the name of the package you wish to publish on AUR.<\/p>\n\n\n\n<p>Finally, follow these steps to complete the AUR package creation:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ makepkg --printsrcinfo &gt; .SRCINFO\n$ git add PKGBUILD .SRCINFO\n$ git commit -m \"Updates\"\n$ git push origin master<\/code><\/pre>\n\n\n\n<p>Example of a PKGBUILD:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Maintainer: Tu nombre &lt;usuario@mail.ch&gt;\npkgname=nombre-del-proyecto\npkgver=v.1.0.2\npkgrel=1\npkgdesc=\"Descripci\u00f3n de la aplicaci\u00f3n o software\"\narch=('x86_64')\nurl=\"https:\/\/github.com\/usuario\/proyecto\"\nlicense=('MIT')\ndepends=('gcc' 'vim' 'nano')\n\nsource=(\"https:\/\/github.com\/usuario\/repo-proyecto\/archive\/refs\/tags\/$pkgver.tar.gz\")\n\nbuild() {\n  cd \"$srcdir\/proyecto-$pkgver\"\n  #make\n  .\/setup\n}\n\npackage() {\n  cd \"$srcdir\/proyecto-$pkgver\"\n  install -Dm755 term_notes \"$pkgdir\/usr\/bin\/proyecto\"\n}\n\nsha256sums=('e1ae65286b64c3466d5749524c79df1063ec9db35b265f0359d24cc76397d88c')\n<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p>Make sure to review the PKGBUILD file, ensuring it matches the provided template and contains the correct <code>sha256sums<\/code>. You can generate the <code>sha256sums<\/code> by running <code>sha256sum -b * &gt; SHA256SUMS<\/code>. Open the resulting <code>SHA256SUMS<\/code> file with a text editor to verify the sha256sums for the tarball versions in the GitHub repository.<\/p>\n\n\n\n<p>In Mac OS is:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>shasum -a 256 src\/file-project.c<\/code><\/pre>\n\n\n\n<p>Moving on to Brew:<\/p>\n\n\n\n<p>Inside the root folder of your GitHub project, create a folder called <code>Formula<\/code>. Within this folder, create a file named <code>project.rb<\/code>, where <code>project<\/code> represents the name of your project in Brew.<\/p>\n\n\n\n<p>Here&#8217;s an example of a formula in Ruby:<\/p>\n\n\n\n<p><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>class TermNotes &lt; Formula\n  desc \"Description of the application\"\n  homepage \"https:\/\/github.com\/user\/repoproject\"\n  url \"https:\/\/github.com\/user\/repoproject\/archive\/refs\/tags\/v.1.0.2.tar.gz\"\n  sha256 \"e1ae65286b64c3466d5346346345634634634563464536d24cc76397d88c\"\n  license \"MIT\"\n\n  depends_on \"gcc\"\n  depends_on \"vim\"\n  depends_on \"nano\"\n\n  def install\n    if OS.mac?\n      bin.install \"named-project\" =&gt; \"renamed-project\"\n    else\n      bin.install \"project\"\n    end\n  end\n\n  def caveats\n    &lt;&lt;~EOS\n      'Term Notes' has been installed!\n\n      On macOS, you can run the program using 'term-notes'.\n\n      On Linux, you may need to create a symbolic link to make it accessible globally.\n      Run the following command:\n\n        sudo ln -s #{opt_bin}\/project-name \/usr\/local\/bin\/renamed-project\n\n      Enjoy taking notes with 'Term Notes'!\n    EOS\n  end\n\n  test do\n    # Add your test logic here\n  end\nend\n<\/code><\/pre>\n\n\n\n<p>To utilize the tap functionality, ensure you have Homebrew installed on your Mac or Linux system. Visit <a href=\"https:\/\/brew.sh\/\">brew.sh<\/a> for installation instructions. Once installed, use <code>tap<\/code> as follows:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>brew tap &lt;username&gt;\/&lt;repository&gt; &lt;full-github-url-repoproject&gt;<\/code><\/pre>\n\n\n\n<p>To install the project using brew, run:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>brew install name-project<\/code><\/pre>\n\n\n\n<p>Replace <code>name-project<\/code> with the same name used for the file inside the <code>Formula<\/code> folder in your GitHub project&#8217;s root directory.<\/p>\n\n\n\n<p>Once your tap is installed, Homebrew will automatically update it whenever a user runs <code>brew update<\/code>. Outdated formulas will be upgraded when a user runs <code>brew upgrade<\/code> along with core formulas.<\/p>\n\n\n\n<p>Remember to update the AUR repository by replacing the sha256sum and adjusting the tag&#8217;s version to reflect the changes in the GitHub repository inside the <code>.rb<\/code> formula file in the <code>Formula<\/code> folder.<\/p>\n\n\n\n<p>For more information about maintaining a tap, refer to the <a href=\"https:\/\/docs.brew.sh\/How-to-Create-and-Maintain-a-Tap#maintaining-a-tap\">official Homebrew documentation<\/a>. To learn about the AUR submission guidelines and sha256sums, visit the <a href=\"https:\/\/wiki.archlinux.org\/title\/AUR_submission_guidelines#Rules_of_submission\">Arch Linux wiki<\/a> and this <a href=\"https:\/\/superuser.com\/questions\/940420\/how-to-create-a-sha256sums-file\">Super User post<\/a>.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>It&#8217;s crucial to have a repository on GitHub for seamless development and collaboration. In the case of Arch Linux&#8217;s AUR, creating an account on aur.archlinux.org is essential. Additionally, generating and configuring an SSH key pair linked to the AUR account is crucial. Here&#8217;s how you can set it up: Create the ~\/.ssh\/config file with the [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[70,76],"tags":[66,84,85,88,86,67,75,87,81],"class_list":["post-804","post","type-post","status-publish","format-standard","hentry","category-linux","category-mac","tag-arch","tag-aur","tag-brew","tag-distribution","tag-github","tag-linux","tag-mac","tag-package","tag-programming"],"_links":{"self":[{"href":"https:\/\/freeshell.de\/~felipe\/blog\/wp-json\/wp\/v2\/posts\/804","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/freeshell.de\/~felipe\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/freeshell.de\/~felipe\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/freeshell.de\/~felipe\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/freeshell.de\/~felipe\/blog\/wp-json\/wp\/v2\/comments?post=804"}],"version-history":[{"count":9,"href":"https:\/\/freeshell.de\/~felipe\/blog\/wp-json\/wp\/v2\/posts\/804\/revisions"}],"predecessor-version":[{"id":888,"href":"https:\/\/freeshell.de\/~felipe\/blog\/wp-json\/wp\/v2\/posts\/804\/revisions\/888"}],"wp:attachment":[{"href":"https:\/\/freeshell.de\/~felipe\/blog\/wp-json\/wp\/v2\/media?parent=804"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/freeshell.de\/~felipe\/blog\/wp-json\/wp\/v2\/categories?post=804"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/freeshell.de\/~felipe\/blog\/wp-json\/wp\/v2\/tags?post=804"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}