Previous: , Up: Build   [Index]


Tutorial

One of the most trivial and simple skel of hello world program can be made with the following skel in skel/hw.do:

[ -n "$BASS_ROOT" ] || BASS_ROOT="$(dirname "$(realpath -- "$0")")"/../../..
sname=$1.do . "$BASS_ROOT"/lib/rc
. "$BASS_ROOT"/build/skel/common.rc

mkdir -p "$SKELBINS"/$ARCH/$NAME/bin
cd "$SKELBINS"/$ARCH
cp ~/src/misc/hw/hw.pl $NAME/bin
"$BASS_ROOT"/build/lib/mk-pkg $NAME

But let’s write a skel and build a skelpkg for convenient GNU parallel utility.

  1. Go to build/ subdirectory, and create configuration file. I tend to call it rc. Set $BASS_RC environment variable with the path to it:
    $ cd build/
    $ cat >rc <<EOF
    MAKE_JOBS=8
    SKELBINS=/tmp/skelbins
    EOF
    $ export BASS_RC=`realpath rc`
    

    You can look for variables you can set in lib/rc. One of the most important variable is $ARCH, which sets what architecture you are using. If you have got non-Git capable checkout, then probably you should also set $BASS_REV to some dummy string. When it is changed – your skelbin’s hashes too. $SKELBINS path is crucial to be the same as it will be on the slaves.

  2. Prepare distfile download rule. distfiles/ directory contains default.do target, so it will be executed by default for every target in it (unless that target has its own .do file). And by default that target will download file based on corresponding .meta4 file nearby.

    According to parallel’s homepage, it is advised to use GNU mirrors for downloading, so let’s take its latest release with the signature:

    $ wget https://ftpmirror.gnu.org/parallel/parallel-20240122.tar.bz2
    $ wget https://ftpmirror.gnu.org/parallel/parallel-20240122.tar.bz2.sig
    

    Its .sig file contains non-signature related commentary, that we should strip off:

    $ perl -i -ne 'print if /BEGIN/../END/' parallel-20240122.tar.bz2.sig
    

    Many software provides signatures in binary format, that could be easily converted with gpg --enarmor <....sig >....asc.

    Then we must create corresponding Metalink4 file, which includes signature, URL(s) and checksums. I will use meta4ra-create utility for that purpose:

    $ meta4ra-create \
        -fn parallel-20240122.tar.bz2 \
        -sig-pgp parallel-20240122.tar.bz2.sig \
        https://ftpmirror.gnu.org/parallel/parallel-20240122.tar.bz2 \
        <parallel-20240122.tar.bz2 >parallel-20240122.tar.bz2.meta4
    
  3. Write the skel file skel/sysutils/parallel-20240122.do itself:
    [ -n "$BASS_ROOT" ] || BASS_ROOT="$(dirname "$(realpath -- "$0")")"/../../../..
    sname=$1.do . "$BASS_ROOT"/lib/rc
    . "$BASS_ROOT"/build/skel/common.rc
    
    bdeps="rc-paths stow archivers/zstd devel/gmake-4.4.1"
    rdeps="lang/perl-5.32.1"
    redo-ifchange $bdeps "$DISTFILES"/$name.tar.bz2 $rdeps
    hsh=$("$BASS_ROOT"/build/bin/cksum $BASS_REV $spath)
    . "$BASS_ROOT"/build/lib/create-tmp-for-build.rc
    "$BASS_ROOT"/build/bin/pkg-inst $bdeps $rdeps
    . ./rc
    $TAR xf "$DISTFILES"/$name.tar.bz2
    "$BASS_ROOT"/bin/rm-r "$SKELBINS"/$ARCH/$NAME-$hsh
    
    cd $NAME
    ./configure --prefix="$SKELBINS"/$ARCH/$NAME-$hsh --disable-documentation >&2
    perl -i -ne 'print unless /^\s+citation_notice..;$/' src/parallel
    gmake -j$MAKE_JOBS >&2
    gmake install >&2
    
    cd "$SKELBINS"/$ARCH
    "$LIB"/prepare-preinst-010-rdeps $NAME-$hsh $rdeps
    mkdir -p $NAME-$hsh/skelpkg/$NAME-$hsh/hooks/postinst
    cat >$NAME-$hsh/skelpkg/$NAME-$hsh/hooks/postinst/01will-cite <<EOF
    #!/bin/sh
    echo yeah, yeah, will cite >&2
    EOF
    chmod +x $NAME-$hsh/skelpkg/$NAME-$hsh/hooks/postinst/01will-cite
    "$BASS_ROOT"/build/lib/mk-pkg $NAME-$hsh
    
  4. Create a link to it in skelpkgs’s directory for the given architecture. You can use pkg/mk-arch to conveniently create $ARCH directory and link all missing skels to it:
    $ pkg/mk-arch
    
  5. Run the skelpkg creation job itself:
    $ redo pkg/FreeBSD-amd64-13.2-RELEASE/sysutils/parallel-20240122
    
  6. Check and confirm that created file looks like a skelpkg:
    % tar xfO pkg/FreeBSD-amd64-13.2-RELEASE/sysutils/parallel-20240122 bin | tar tf -
    parallel-20240122-xhVYojyMWD8XeHTuTe44q1NyHI2b_l5fKsopunYFzkc/
    parallel-20240122-xhVYojyMWD8XeHTuTe44q1NyHI2b_l5fKsopunYFzkc/bin/
    parallel-20240122-xhVYojyMWD8XeHTuTe44q1NyHI2b_l5fKsopunYFzkc/bin/env_parallel
    parallel-20240122-xhVYojyMWD8XeHTuTe44q1NyHI2b_l5fKsopunYFzkc/bin/[...]
    parallel-20240122-xhVYojyMWD8XeHTuTe44q1NyHI2b_l5fKsopunYFzkc/bin/parallel
    

Let’s describe what is happening in the skel:


Previous: Distfiles, Up: Build   [Index]