Very nice work @aerique, and everyone, thank you.
Myself I use coderus work from Docker Hub to build in docker.
I write Gitlab CI scripts to do that, because they can then be used both on a local machine using gitlab-runner
, or using the CI feature on gitlab.
Anyway I have taken the recipe above and put it in a gitlab-ci file. Posting below in case anyone is interested in building that way.
Not too much interesting or new in there, but it stores the output rpms in a dir in docker, and creates a local repo for zypper to install from instead of using online repos.
stages:
- build
image: "coderus/sailfishos-platform-sdk-${TARGET}:${SFOS_VERSION}"
tags:
- docker
default:
variables:
#SFOS_VERSION: "4.0.1.45"
SFOS_VERSION: "4.1.0.23"
GIT_SUBMODULE_STRATEGY: recursive
OUTDIR: $CI_PROJECT_DIR/output
#BLDDIR: ~/build # this does not work because ~ does not expand. use a shell variable instead
YAMLNAME: ownkeepass.yaml
SPECNAME: ownkeepass.spec
TARGET: armv7hl # set this globally for local builds because gitlab-ci-runner can not deal with extends: foo
.build-local:
stage: build
script:
# prep
- BLDDIR=~/build
- mkdir -p $OUTDIR/$SFOS_VERSION/
- mkdir -p ${BLDDIR}
- cp -r $CI_PROJECT_DIR/* $BLDDIR/
- pushd $BLDDIR
# argon
- git clone https://git.sr.ht/~aerique/libargon2-spec libargon2-spec-git
- pushd libargon2-spec-git
- git submodule update --init --recursive
- mb2 -t SailfishOS-$SFOS_VERSION-$TARGET --no-fix-version prepare | tee $OUTDIR/prepare.log
- mb2 -t SailfishOS-$SFOS_VERSION-$TARGET --no-fix-version build | tee $OUTDIR/build.log
- cp -r RPMS/* $OUTDIR/$SFOS_VERSION/
- popd
# sodium
- git clone https://git.sr.ht/~aerique/libsodium-spec libsodium-spec-git
- pushd libsodium-spec-git
- curl -o libsodium-1.0.18-stable.tar.gz https://download.libsodium.org/libsodium/releases/libsodium-1.0.18-stable.tar.gz
- tar xvfz libsodium-1.0.18-stable.tar.gz
- mb2 -t SailfishOS-$SFOS_VERSION-$TARGET --no-fix-version prepare | tee $OUTDIR/prepare.log
- mb2 -t SailfishOS-$SFOS_VERSION-$TARGET --no-fix-version build | tee $OUTDIR/build.log
- cp -r RPMS/* $OUTDIR/$SFOS_VERSION/
- popd
# main
- LR=~/myrepo
- mkdir -p $LR
- for f in $(find $OUTDIR/$SFOS_VERSION -type f -name *.rpm); do cp ${f} $LR; done
- sb2 -t SailfishOS-$SFOS_VERSION-$TARGET -m sdk-install -R zypper ar --no-gpgcheck $LR localfiles
- sb2 -t SailfishOS-$SFOS_VERSION-$TARGET -m sdk-install -R zypper ref
- sb2 -t SailfishOS-$SFOS_VERSION-$TARGET -m sdk-install -R zypper --non-interactive install libgcrypt-devel
- sb2 -t SailfishOS-$SFOS_VERSION-$TARGET -m sdk-install -R zypper --non-interactive install --from localfiles libargon2-devel libsodium-devel
- git clone https://github.com/24mu13/ownkeepass.git ownkeepass
- pushd ownkeepass
- git submodule update --init --recursive
- cd Sailfish
- sed -i -e '/.*libargon2.*/d' rpm/harbour-ownkeepass.yaml
- sed -i -e '/.*libargon2.*/d' rpm/harbour-ownkeepass.spec
- mb2 -t SailfishOS-$SFOS_VERSION-$TARGET --no-fix-version prepare | tee $OUTDIR/prepare.log
- mb2 -t SailfishOS-$SFOS_VERSION-$TARGET --no-fix-version build | tee $OUTDIR/build.log
- cp -r RPMS/* $OUTDIR/$SFOS_VERSION/
- rm -r $BLDDIR/
artifacts:
when: always
paths:
- "output/*.log"
- "output/*.spec"
- "output/*.yaml"
- "output/$SFOS_VERSION"
cache:
key: ${CI_PROJECT_NAME}_${CI_JOB_NAME}
paths:
- $SRCNAME-$SRCTAG
- /home/.zypp-cache
- /srv/mer/targets/SailfishOS-$SFOS_VERSION-$TARGET/var/cache/zypp/
- /var/cache/zypp/
- /home/nemo/src
build-arm64:
stage: build
extends: .build-local
variables:
TARGET: aarch64
build-arm:
stage: build
extends: .build-local
variables:
TARGET: armv7hl
build-x86:
stage: build
extends: .build-local
variables:
TARGET: i486
If you have gitlab-runner
instaled locally, this will run the build:
#!/usr/bin/env bash
BASE_DIR=$PWD
BUILD_DIR=$BASE_DIR/build
CACHE_DIR=${HOME}/.cache/gitlab-runner-cache
mkdir -p $BUILD_DIR
builder="$1"
if [[ x"$1" = x"" ]]; then
builder='.build-local'
fi
case $1 in
'-h'|'list'|'help')
echo these local builders exist:
grep '^\..*local' .gitlab-ci.yml
exit 0
;;
esac
DOPTS="--docker-pull-policy=never --docker-volumes "$BUILD_DIR/:/builds:rw" --docker-cache-dir $CACHE_DIR "
[[ -e $BASE_DIR/build.log ]] && mv $BASE_DIR/build.log $BASE_DIR/build.log.old
gitlab-ci-multi-runner -l warn exec docker $DOPTS $builder 2>&1 | tee $BASE_DIR/build.log | grep -v 'ERROR: Could not create cache adapter'