Package maintainer guide - ParabolaWiki

# Package maintainer guide

This article describes the steps needed to start working on our repos. If you are going to make a new -libre replacement for some package check our guide for creating libre replacements.

Note: Try to hang around the #parabola and subscribe to the dev list

If anything important comes up, you'll find it there.

Also, register yourself to the issue tracker, so we can assign you tasks or you can pick some by yourself.

Packager guidelines are being discussed as of Feb, 2012. Please participate! (Archive)

## Tools

Install libretools. It will also install ssh, rsync, git, and other tools needed to package.

    # pacman -S libretools

Warning: You'll need to set GPGKEY, and add repo to your ~/.ssh/config before using libretools.
Warning: If you are upgrading libretools, you will need to merge your /etc/libretools.conf.pacnew.

## Configuring everything

### Set GPGKEY

Create your GPGKEY

Warning: When using integrated key management (like one available in GNOME) you should omit this section as a private key won't be retrived correctly. The key will be provided automatically upon request from the packaging scripts.

To do package signing, you will need to set the GPGKEY variable. You either set it as an environmental variable, or in /etc/makepkg.conf, or in ~/.makepkg.conf.

I prefer to set it as an environmental variable by putting the following in my ~/.profile:

File: `~/.profile`

    if [ -z "$GPGKEY" ] && [ -f "${HOME}/.gnupg/gpg.conf" ]; then
    	export GPGKEY=`sed -nr 's/^\s*default-key\s+//p' "${HOME}/.gnupg/gpg.conf"`
    fi

Note: The GPGKEY variable replaces the SIGID variable that was set in /etc/libretools.conf.

### Configure SSH

Add the following to your ~/.ssh/config

File: `~/.ssh/config`

    Host repo
            Port 1863
            HostName repo.parabola.nu
    	user repo

    Host repo.parabola.nu
            Port 1863
            HostName repo.parabola.nu
    	IdentityFile ~/.ssh/''yourparabolapackagerskey''
    	user repo

    Host parabola.nu
            Port 1863
            HostName repo.parabola.nu
            IdentityFile ~/.ssh/''yourparabolapackagerskey''
            user repo

    Host projects.parabola.nu
            Port 1863
            HostName projects.parabola.nu
    	IdentityFile ~/.ssh/''yourparabolapackagerskey''
    	User git

And send your public key (~/.ssh/id_rsa.pub or custom name) to the Parabola mailing list.

Note: The key and the email should be signed with your GnuPG key. Using the above example you would use gpg --armor --sign ~/.ssh/id_rsa.pub to sign your SSH key.
Note: The 'repo' host replaces the old 'parabola' host.

## Packaging Environment

Packaging can be messy and become a burden (like any repetitive task). Libretools exist to make it lighter.

### Working directory

To minimize errors in uploading packages, we have created automatic tools for the process, our libretools use the directory hierarchy of our repos.

There's a script that will help you generate a proper working directory, awesomely called createworkdir. Run it, and it will create all the needed directories, plus it will git-clone the ABSLibre tree for you if you sent your SSH public key to the dev mailing list (see below).

    $ createworkdir

You can find more info about the directory tree here.

#### Updating ABSLibre

When building a package, you need an up-to-date copy of the recipe for the package. To update abslibre in your $WORKDIR just:

    $ cd $WORKDIR/abslibre && git pull

### Chroot

You'll need a clean packaging environment to make sure the packages you make work in every parabola system despite what settings and packages you have on yours. That's what a chroot is for.

You need to create a chroot dir for building packages inside. This will also help you identify missing dependencies and keep your every day system clean too. You can create a chroot by running sudo librechroot -M /etc/makepkg.conf -C /etc/pacman.conf make, however, any command that requires a chroot will automatically create one if it doesn't exist.

Also, note that we explicitly used sudo, instead of giving the usual #, to signify running it as root. This is because part of the path to the chroot is based on the username. See librechroot help for more details.

Note: If you have modified your /etc/makepkg.conf or /etc/pacman.conf you will want to make sure it is restored to default in your chroots or you can expect problems. Also every-time you run librechroot or libremakepkg these files get re-copied. If you do not want this behaviour to happen you can try setting chattr +i [filename] inside the chroot.

#### Updating the chroot

You of course want to keep the packages in the chroot up-to-date.

    $ sudo librechroot update

## Building packages

Warning: Do not use any directory in $WORKDIR/staging to build

Before making a package, you should update ABSLibre and your chroot.

Make sure you have configured the PKGDEST and SRCDEST in /etc/makepkg.conf.

Then, change (cd) to the directory for the package in $WORKDIR/abslibre, and run libremakepkg (almost like plain makepkg):

    $ sudo libremakepkg

After the package is built, it will automatically be added to a local pacman repository, so it can be used as a dependency for other packages you are building.

Check the libremakepkg page for a description on how libremakepkg works.

## Creating packages

Please follow this guide: Creating -libre packages.

Also, take a look at Common packaging mistakes.

## Uploading packages

### Configuring git

All of your packages will need to include a PKGBUILD uploaded to the abslibre.git. You may configure your ~/.gitconfig as follows:

File: `~/.gitconfig`

    [color]
    	ui = auto
    [push]
    	default = simple
    [user]
    	name = Your Name
    	email = your@email.com
    	signingkey = [Your GPG key fingerprint here]
    [commit]
    	gpgsign = true

Once git has been configured you can simply push any updates as follows:

    $ git add [editedfile(s)]
    $ git commit -m "I changed something, just letting everyone know"
    $ git push

### Uploading binary

To upload packages to our repo, just do:

    $ librestage repo-to-put-the-package-in # stage the package to be uploaded
    $ librerelease                          # upload all staged packages

By default, librerelease will also clean the local pacman repository in your chroot (sudo librechroot clean-repo). If you don't want it to do this, change the value for HOOKPOSTRELEASE in /etc/libretools.conf.

## Tips and Tricks

### Building i686 packages from an x86_64 machine

See Building 32-bit packages on a 64-bit system

### Building armv7h packages from an x86 (i686 and/or x86_64) machine

See Building armv7h packages on a x86 system

### Releasing several packages at the same time

Originally, librerelease would decide where to put a package and upload it to the repo server right away. Now, librestage does the first part and librerelease does the second, so in practice, you can package several packages and stage them for uploading later. Before running librerelease, make sure you run gpg-agent, so you'll only have to enter your password once.

### Staging one package for several repositories

Take note librestage accepts several repo names as arguments. If you do so, it will stage the package(s) on all of them, allowing you to upload packages in any number of repos you want. It's not a feature to abuse on, but it's useful while we migrate to [libre] and [libre-testing] repos... you'll have to release into [core] and [libre], or [testing] and [libre-testing] at the same time, for instance.

### MD5sum checking

If you change the sources array on a PKGBUILD, you'll have to change the md5sums array to reflect this. Remove it from the PKGBUILD and use this command to generate md5sum for your packages:

    $ makepkg -g >> PKGBUILD

### Building packages from source control

The librefetch tool exists to help with building packages from source control. If you are familiar with the old mksource or SRCBUILD systems, those work; just add https://repo.parabola.nu/other/$pkgname/$pkgname-$pkgver.tar.gz to your source array, and librefetch will automatically build it for you. Of mksource and SRCBUILD, I recommend mksource, it is much simpler. For example, here is a portion of my PKGBUILD to build a bleeding-edge version of wmii:

File: `PKGBUILD`

    source=("https://repo.parabola.nu/other/~lukeshu/wmii/wmii-hg-${pkgver}.tar.gz")
    md5sums=('1ab85d01467e5e53c9b16ca19cca9824')

    mkdepends=("mercurial")
    mksource=("wmii-hg${pkgver}::hg+https://code.google.com/p/wmii/#revision=${pkgver}")
    mkmd5sums=('SKIP')
    mksource() {
    	# don't include this precompiled binary (probably included by accident)
    	rm "${srcdir}/wmii-hg${pkgver}/lib/libutf/libutf.a"
    }

Use librefetch -g to generate the mkmd5sums array, and makepkg -g to generate the plain md5sums array.

librestage/librerelease uploads the generated tarball for you.

### SSH connection to Parabola

Make sure the permissions in your ~/.ssh to 700:

    $ chmod 700 ~/.ssh

Also make sure the permissions of your key ~/.ssh/id_ecdsa to 600:

    $ chmod 600 ~/.ssh

If you added the repo host for your ssh config, you can just:

    $ ssh repo@repo

and to copy files using scp:

    $ scp local-file repo@repo:remote-path

### Maintaining Package on time to stay up to date!

THIS IS WITH AUR3 ... WE HAVE TO FIND THE WAY WITH AUR4!!!

At the time you have installed libretools and start to build packages the next step is to maintain them up to date.

To make it easy there is a script that told you when your package are out dated!

(at this time I do not remember who was the author that does not sign this script, I just know that it have been be write by one of the Pa\ rabola hackers list, Thanks to him!)

First that you have to do is to clone the aur-git

    git clone git://pkgbuild.com/aur-mirror.git

Then install expac if not already done

    pacman -S expac

then copy that script in a filename you wish for example out-of-date

    pattern="$1"
    cd aur-mirror
    expac -S '%r/%n %v %b %p' -t '%F %T %z' | grep "^pcr" | cut -b 5- | awk -v pattern="$pattern" "\$1 ~ pattern" | while IFS= read -r line
    do
      set -- ${line}
      if [[ -e ${1}/PKGBUILD ]] ; then
        # Skip plowshare because its pkgver is too long
        [[ ${1} =~ plowshare ]] && continue
        source ${1}/PKGBUILD && [[ "${2}" < "${pkgver}-${pkgrel}" ]] && {
          printf "%-40s%15s   %-20s   %-50s\n" "${1}" "${2}" "${3} ${4} ${5}" "${*: 6}"
          date="$(git log -1 --format='%ci' -- "${1}/PKGBUILD")"
          printf "%-40s%15s   %-50s\n" "${pkgname}" "${pkgver}-${pkgrel}" "${date}"
          echo --
        }
      else
        echo "${1} is not in AUR"
        echo --
      fi
    done

save it and chmod +x it

    chmod +x out-of-date

Now you will have just to execute it using ^a to list all (a)lphatetical a package

    ./out-of-date ^a

Here you are an up-to-date maintainer!

Categories:

- Packaging
- Libretools