{"id":209,"date":"2018-02-26T23:48:52","date_gmt":"2018-02-26T22:48:52","guid":{"rendered":"http:\/\/xpam.pl\/blog\/?p=209"},"modified":"2024-04-03T00:35:59","modified_gmt":"2024-04-02T22:35:59","slug":"lib-packaging-in-your-own-repo","status":"publish","type":"post","link":"https:\/\/xpam.pl\/blog\/?p=209","title":{"rendered":"Lib packaging for your own repo"},"content":{"rendered":"<p>This is a note to self about the release procedure and distro packaging of a development library.<\/p>\n<p>This instructions expect <a href=\"https:\/\/www.aptly.info\/\">aptly<\/a> and <a href=\"http:\/\/yum.baseurl.org\/wiki\/RepoCreate\">createrepo<\/a> to be preinstalled on your repo server together with a valid GPG key.<\/p>\n<h1>Packaging a .deb<\/h1>\n<p>1. Checkout the release tag and build the deb according to README. Each build should be done on the same machine as the target distribution. If I am packaging for Centos 6 I am also building on Centos 6. If CMake and CPack are set up correctly it usually boils down to:<\/p>\n<pre><code class=\"language-bash\">cmake -G &quot;Unix makefiles&quot; -H.\/ -B.\/build\ncd build\nmake\ncpack -G &quot;DEB&quot;<\/code><\/pre>\n<p>If the project is missing CMake, refuse to package it.<\/p>\n<p>2. Check that deb info is correct:<br \/>\n<code>dpkg-deb -I bncsutil-1.4.1-Linux.deb<\/code><br \/>\n3. Rename it to distro you are building on, then scp to your repo server<br \/>\n<code>mv bncsutil-1.4.1-Linux.deb bncsutil-1.4.1-Debian9.deb<\/code><br \/>\n4. If aptly repo does not exist yet, create it<br \/>\n<code>aptly repo create -comment=&quot;Debian 9 repo&quot; -component=&quot;main&quot; -distribution=&quot;bnetdocs-stretch&quot; debian9<\/code><br \/>\nIdeally you only create the repo the first time, for future updates you create a snapshot of it, add a package, then switch the repo to new snapshot. See aptly docs for more.<\/p>\n<p>Alternatively, you can just add more packages and update the repo with<br \/>\n<code>aptly publish update bnetdocs-stretch debian9<\/code><br \/>\n&nbsp;<\/p>\n<p>5. Add package to repo<br \/>\n<code>aptly repo add debian9 deb_archives\/bncsutil-1.4.1-Debian9.deb<\/code><br \/>\n6. Publish repo<br \/>\n<code>aptly publish repo debian9 debian9<\/code><br \/>\n7. On target machine, add repo to <strong>\/etc\/apt\/sources.list <\/strong>and fetch<strong> public key<\/strong><br \/>\n<code>deb http:\/\/apt.xpam.pl\/debian8\/ bnetdocs-stretch main<\/code><br \/>\n<code>wget -qO - https:\/\/apt.xpam.pl\/xpam.pl-pubkey.asc | sudo apt-key add -<\/code><br \/>\n8. Update and then check if package info is correct<br \/>\n<code>apt-cache show bncsutil<\/code><br \/>\n9. If big mistakes were made<br \/>\n<code>aptly publish drop debian9 debian9<\/code><br \/>\n..and start over. Repeat for Debian 8 etc.<\/p>\n<h1>Packaging an .rpm<\/h1>\n<p>1. See the previous #1. The only difference is<br \/>\n<code>cpack -G &quot;RPM&quot;<\/code><br \/>\n2. Check that rpm info is correct<br \/>\n<code>rpm -qip bncsutil-1.4.1-Linux.rpm<\/code><br \/>\n3. Rename it to distro you are building on, then scp to your repo server<br \/>\n<code>mv bncsutil-1.4.1-Linux.rpm bncsutil-1.4.1-Centos7.rpm<\/code><br \/>\n4. Make sure you have <strong>.rpmmacros<\/strong> file in home dir with uid of gpg signing key (check out your keys with <strong>gpg &#8211;list-keys<\/strong>). If you don't have one, generate it. Entry in the file should look like:<br \/>\n<code>%_gpg_name &lt;uid here&gt;<\/code><br \/>\n5. Sign rpm<br \/>\n<code>rpm --addsign rpm_archives\/bncsutil-1.4.1-Centos7.rpm<\/code><br \/>\n4. Move to appropriate repo that was created by createrepo earlier (see createrepo docs)<br \/>\n<code>mv rpm_archives\/bncsutil-1.4.1-Centos7.rpm .createrepo-centos7\/<\/code><br \/>\n5. Update repo metadata<br \/>\n<code>createrepo --update .\/.createrepo-centos7\/<\/code><br \/>\n6. Add your repo on the target machine<\/p>\n<pre><code class=\"language-bash\">yum -y install yum-utils\nyum-config-manager --add-repo https:\/\/centos7.rpm.xpam.pl\nyum-config-manager --enable https:\/\/centos7.rpm.xpam.pl\nrpm --import https:\/\/centos7.rpm.xpam.pl\/xpam.pl-pubkey.asc<\/code><\/pre>\n<p><code><\/code>Since createrepo is pretty much just an http server you can simply delete an rpm and update the metadata in case things go south.<\/p>\n<p>Repeat for Centos 6 etc.<\/p>\n<div class=\"wp-post-signature\">\r\n<br \/>\r\n<br \/>\r\n<img src='https:\/\/xpam.pl\/aaaaff.png' title='Moonie' \/> Cen<br \/>\r\n<a href='https:\/\/github.com\/cen1'>GitHub<\/a><br \/>\r\n<a href='https:\/\/eurobattle.net'>Eurobattle.net<\/a><br \/>\r\n<a href='https:\/\/lagabuse.com'>Lagabuse.com<\/a><br \/>\r\n<a href='https:\/\/bnetdocs.org'>Bnetdocs<\/a><br \/>\r\n<\/div>\r\n","protected":false},"excerpt":{"rendered":"<p>This is a note to self about the release procedure and distro packaging of a development library. This instructions expect aptly and createrepo to be preinstalled on your repo server together with a valid GPG key. Packaging a .deb 1. Checkout the release tag and build the deb according to README. Each build should be [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[20,18],"tags":[],"class_list":["post-209","post","type-post","status-publish","format-standard","hentry","category-linux","category-script-magic"],"_links":{"self":[{"href":"https:\/\/xpam.pl\/blog\/index.php?rest_route=\/wp\/v2\/posts\/209","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/xpam.pl\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/xpam.pl\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/xpam.pl\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/xpam.pl\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=209"}],"version-history":[{"count":8,"href":"https:\/\/xpam.pl\/blog\/index.php?rest_route=\/wp\/v2\/posts\/209\/revisions"}],"predecessor-version":[{"id":538,"href":"https:\/\/xpam.pl\/blog\/index.php?rest_route=\/wp\/v2\/posts\/209\/revisions\/538"}],"wp:attachment":[{"href":"https:\/\/xpam.pl\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=209"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/xpam.pl\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=209"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/xpam.pl\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=209"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}