Build Package with Qi.

build-package-with-qi

Build Package with Qi.

Back in August 2024, I discovered a linux distro called Dragora GNU/Linux. Dragora has a unique package manager called qi. For package instalation, Qi feel like installpkg from Slackaware. For building package, qi takes some similiar approaches from PKGBUILD (Archlinux) and APKBUILD (Alpine linux). Qi uses a recipe as alternative of PKGBUILD, APKBUILD or slackbuild file to build package. Qi seems universal to use across distros, I’ve been actively using it on Ubuntu, Dragora, and LFS.


Qi Recipe.

Qi recipe consist of 2 parts :

  1. Package information, such as package name, description, url and package source url, etc.
  2. Build instructions, how the package will be built (extract source code, patching if needed, and install to destination directory).

This is a simple qi recipe template.

set -e

program=
version=
release=
description=""
homepage=""
license=""

tarname=
fetch=""

srcdir=

build() 
{
	unpack "${tardir}/$tarname"
	
	cd "$srcdir"
	
	# Set sane permissions
	chmod -R u+w,go-w,a+rX-s .

	patch -p1 -i ${worktree}/patch_file

	autoreconf -vif
	./configure \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--infodir=/usr/share/info

	make 
	make DESTDIR="$destdir" install 
}

We get some terminologies from the template above, like tardir, srcdir, worktree and destdir.

  • tardir, a directory where the tarball containing source code can be found. It’s usually at /usr/src/qi/sources/ but we can defined using -s option.
  • srcdir, contains the source code to be compiled. The defaults location is ${program}-${version} but somehow source code has its unique location.
  • worktree, the working tree where archives (additional files), patches, and recipe are expected. It’s located at /usr/src/qi/.
  • destdir, the place where the built package will be installed, and defaults to ${TMPDIR}/package-${program} or /usr/src/qi/build/package-${program}.

How do we use the recipe for building package(s) ?

It’s quite simple, for starter, make sure you have these following tools :

  • qi & graft, build qi and graft from source code should be easy.
  • wget and/or wget2 , needed for downloading source code.
  • patch, needed for applying patch.
  • archive tools (tar, gunzip, unrar, etc), needed to unpack archive.

If we already had those tools, it’s time to build the package ! The steps it’s quite simple :

  1. Create and adjust the recipe as you need !

    $ vim recipe
    
  2. Build the package ! We can use this command :

    $ sudo qi build recipe
    

    The build process duration depends on the recipe. Just wait ! The package will be produced at /var/cache/qi/packages/amd64/ .

  3. Once the package is ready, we can install it using this command :

    $ sudo qi install -p /var/cache/qi/packages/amd64/name_of_package.tlz
    
    

Comments

Popular posts from this blog

How to fix "gzip: stdin: not in gzip format" error on w3m.

Build gettext and libintl.so on musl.