From 9efd4a78db21b6eadbf212c8072622d2df765062 Mon Sep 17 00:00:00 2001 From: Max Rees Date: Mon, 3 Jun 2019 23:58:34 -0400 Subject: abuild: change $srcdir and $pkgbasedir overrides Occasionally, a package will use the $srcdir environment variable for its own purposes and change its behavior during build if it is set. This is not normally a problem since $srcdir is not normally exported by abuild. However, if $srcdir is inherited from the environment in order to override its default value of $startdir/src, it will continue to be inherited and thus confuse those packages. Instead, check for $ABUILD_SRCDIR. Likewise for $pkgbasedir and $ABUILD_PKGBASEDIR for consistency sake. --- abuild.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/abuild.in b/abuild.in index 7daa366..af8cbe5 100644 --- a/abuild.in +++ b/abuild.in @@ -2558,8 +2558,8 @@ fi APKBUILD=$(readlink -f "$APKBUILD") startdir="${APKBUILD%/*}" -srcdir=${srcdir:-"$startdir/src"} -pkgbasedir=${pkgbasedir:-"$startdir/pkg"} +srcdir=${ABUILD_SRCDIR:-"$startdir/src"} +pkgbasedir=${ABUILD_PKGBASEDIR:-"$startdir/pkg"} repo=${startdir%/*} repo=${repo##*/} -- cgit v1.2.3-60-g2f50 From 5a162fad5719f7d935e76d6f8ac68b7938a9e527 Mon Sep 17 00:00:00 2001 From: Max Rees Date: Tue, 4 Jun 2019 00:07:15 -0400 Subject: abuild, buildlab, checkapk: use $APK for apk --- abuild.in | 2 +- buildlab.in | 12 ++++++------ checkapk.in | 5 +++-- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/abuild.in b/abuild.in index af8cbe5..6c548fb 100644 --- a/abuild.in +++ b/abuild.in @@ -2166,7 +2166,7 @@ rootbld() { fi [ "$CBUILD" = "$CHOST" ] || die "rootbld: cross-building not supported currently" - apk info -eq abuild-rootbld || die "rootbld: abuild-rootbld package not installed" + $APK info -eq abuild-rootbld || die "rootbld: abuild-rootbld package not installed" logcmd "chroot building building $repo/$pkgname-$pkgver-r$pkgrel" diff --git a/buildlab.in b/buildlab.in index e8d3d09..1b56ffc 100644 --- a/buildlab.in +++ b/buildlab.in @@ -106,8 +106,8 @@ do_chroot_action() { update_chroot() { local path="$1" - apk --root $path --repositories "$path"/etc/apk/repositories update - apk --root $path --repositories "$path"/etc/apk/repositories upgrade -a + $APK --root $path --repositories "$path"/etc/apk/repositories update + $APK --root $path --repositories "$path"/etc/apk/repositories upgrade -a } prepare_chroot() { @@ -139,19 +139,19 @@ prepare_chroot() { msg "Updating package lists..." - apk --arch $buildarch --root $path --repositories "$path"/etc/apk/repositories update + $APK --arch $buildarch --root $path --repositories "$path"/etc/apk/repositories update msg "Installing alpine-base..." - apk --arch $buildarch --root $path --repositories "$path"/etc/apk/repositories add --initdb alpine-base + $APK --arch $buildarch --root $path --repositories "$path"/etc/apk/repositories add --initdb alpine-base msg "Installing abuild..." - apk --arch $buildarch --root $path --repositories "$path"/etc/apk/repositories add --initdb abuild + $APK --arch $buildarch --root $path --repositories "$path"/etc/apk/repositories add --initdb abuild msg "Installing build-base..." - apk --arch $buildarch --root $path --repositories "$path"/etc/apk/repositories add --initdb build-base + $APK --arch $buildarch --root $path --repositories "$path"/etc/apk/repositories add --initdb build-base msg "Adding abuild user..." diff --git a/checkapk.in b/checkapk.in index 4f9b27a..da2fde3 100644 --- a/checkapk.in +++ b/checkapk.in @@ -15,6 +15,7 @@ if ! [ -f "$datadir/functions.sh" ]; then fi . "$datadir/functions.sh" +: ${APK:="apk"} usage() { cat >&2 <<-__EOF__ @@ -67,12 +68,12 @@ for i in $pkgname $subpackages; do # generate a temp repositories file with only the http(s) repos grep -E "^https?:" /etc/apk/repositories > $tmpdir/repositories - oldpkg=$(apk fetch --repositories-file $tmpdir/repositories --simulate 2>&1 | sed 's/^Downloading //') + oldpkg=$($APK fetch --repositories-file $tmpdir/repositories --simulate 2>&1 | sed 's/^Downloading //') if [ "${oldpkg}" = "${pkg}" ]; then die "the built package ($_pkgname) is already in the repo" fi - apk fetch --quiet --repositories-file $tmpdir/repositories --stdout $_pkgname \ + $APK fetch --quiet --repositories-file $tmpdir/repositories --stdout $_pkgname \ | tar -ztf - | grep -v '^\.SIGN\.' | sort > filelist-$_pkgname-old \ || die "failed to download old pkg, maybe run 'apk update'?" -- cgit v1.2.3-60-g2f50 From 54d6a4a10318f06ba10d28ab8ac8290f81cb6970 Mon Sep 17 00:00:00 2001 From: Max Rees Date: Tue, 4 Jun 2019 00:14:59 -0400 Subject: Use $ABUILD_GIT for git from abuild.conf / environment --- abuild-keygen.in | 2 +- abuild.in | 21 ++++++++++----------- abump.in | 6 +++--- apkgrel.in | 4 ++-- functions.sh.in | 11 ++++++++--- 5 files changed, 24 insertions(+), 20 deletions(-) diff --git a/abuild-keygen.in b/abuild-keygen.in index afdb1ab..42cd3f9 100644 --- a/abuild-keygen.in +++ b/abuild-keygen.in @@ -25,7 +25,7 @@ get_privkey_file() { # if PACKAGER does not contain a valid email address, then ask git if [ -z "$emailaddr" ] || [ "${emailaddr##*@}" = "$emailaddr" ]; then - emailaddr=$(git config --get user.email 2>/dev/null) + emailaddr=$($ABUILD_GIT config --get user.email 2>/dev/null) fi default_name="${emailaddr:-$USER}-$(printf "%x" $(date +%s))" diff --git a/abuild.in b/abuild.in index 6c548fb..b32105b 100644 --- a/abuild.in +++ b/abuild.in @@ -12,7 +12,6 @@ sysconfdir=@sysconfdir@ datadir=@datadir@ abuild_path=$(readlink -f $0) -git=$(command -v git) || git=true if ! [ -f "$datadir/functions.sh" ]; then echo "$datadir/functions.sh: not found" >&2 @@ -818,12 +817,12 @@ prepare_language_packs() { # echo '-dirty' if git is not clean git_dirty() { - [ $($git status -s "$startdir" | wc -l) -ne 0 ] && echo "-dirty" + [ $($ABUILD_GIT status -s "$startdir" | wc -l) -ne 0 ] && echo "-dirty" } # echo last commit hash id git_last_commit() { - $git log --format=oneline -n 1 "$startdir" | awk '{print $1}' + $ABUILD_GIT log --format=oneline -n 1 "$startdir" | awk '{print $1}' } get_maintainer() { @@ -1565,7 +1564,7 @@ update_abuildrepo_index() { subpkg_unset if [ -z "$DESCRIPTION" ]; then - DESCRIPTION="$repo $(cd $startdir && $git describe 2>/dev/null || true)" + DESCRIPTION="$repo $(cd $startdir && $ABUILD_GIT describe 2>/dev/null || true)" fi for i in $allarch; do @@ -2201,7 +2200,7 @@ rootbld() { fi local version="edge" buildhost="edge" gitref - if gitref="$(expr "$(git symbolic-ref --short HEAD)" : '\([0-9]\+\(\.[0-9]\+\)*\)-')"; then + if gitref="$(expr "$($ABUILD_GIT symbolic-ref --short HEAD)" : '\([0-9]\+\(\.[0-9]\+\)*\)-')"; then version=v${gitref} buildhost="$(printf '%s' "$gitref" | sed 's/[.]/-/')" fi @@ -2209,10 +2208,10 @@ rootbld() { local repo_template="$aportsgit/$repo/.rootbld-repositories" [ -s "$repo_template" ] || die "rootbld: $repo_template does not exist" ( - for key in $(git config --list --name-only); do + for key in $($ABUILD_GIT config --list --name-only); do k=${key#abuild.} [ $k != $key ] && \ - eval "export $k=\"$(git config --get $key)\"" + eval "export $k=\"$($ABUILD_GIT config --get $key)\"" done export mirror version @@ -2424,12 +2423,12 @@ snapshot() { # clone git repo and archive if [ -n "$giturl" ]; then local _version="${verbase:-0}_git${_date}" - [ "$git" = "true" ] && die "Missing git! Install git to support git clone." + [ "$ABUILD_GIT" = "true" ] && die "Missing git! Install git to support git clone." local _rev="${reporev:-HEAD}" [ "$_rev" = "HEAD" ] && local _depth="--depth=1" msg "Creating git snapshot: $pkgname-$_version" - git clone $_depth --bare $giturl $pkgname-$_version || return 1 - git --git-dir $pkgname-$_version archive \ + $ABUILD_GIT clone $_depth --bare $giturl $pkgname-$_version || return 1 + $ABUILD_GIT --git-dir $pkgname-$_version archive \ --format=$_format \ -o $pkgname-$_version.$_format \ --prefix=$pkgname-$_version/ $_rev \ @@ -2468,7 +2467,7 @@ usage() { -A Print CARCH and exit -c Enable colored output -d Disable dependency checking - -D Set APKINDEX description (default: \$repo \$(git describe)) + -D Set APKINDEX description (default: \$repo \$(\$ABUILD_GIT describe)) -f Force specified cmd (skip checks: apk up to date, arch, libc) -F Force run as root -h Show this help diff --git a/abump.in b/abump.in index ee2df1e..798fd18 100644 --- a/abump.in +++ b/abump.in @@ -76,8 +76,8 @@ fixes #${fixes#\#} $ABUILD $abuild_opts checksum all - git add APKBUILD - git commit -m"$message" + $ABUILD_GIT add APKBUILD + $ABUILD_GIT commit -m"$message" ) rc=$? if [ $rc -gt 0 ]; then @@ -111,7 +111,7 @@ cvelist= fixes= [ -n "$APORTSDIR" ] || error "can't locate \$APORTSDIR" -git rev-parse 2>/dev/null || die "not in a git tree" +$ABUILD_GIT rev-parse 2>/dev/null || die "not in a git tree" args=$(getopt -o f:s:Rkqh --long fixes:,security:,recursive,keep,quiet,help \ -n "$program" -- "$@") diff --git a/apkgrel.in b/apkgrel.in index fd63271..e5f1ef8 100644 --- a/apkgrel.in +++ b/apkgrel.in @@ -45,7 +45,7 @@ do_add () { local f= old= for f; do [ -n "$only_clean_git" ] \ - && [ -n "$(git diff --name-only "${f%/*}")" ] \ + && [ -n "$($ABUILD_GIT diff --name-only "${f%/*}")" ] \ && continue old=$(show_plain "$f") case $old in @@ -107,7 +107,7 @@ while true; do -z|--zero) setto=0; cmd=do_set;; -a|--add) cmd=do_add;; -g|--clean-git) # verify that we're in a git tree - git rev-parse 2>/dev/null || die "not in a git tree" + $ABUILD_GIT rev-parse 2>/dev/null || die "not in a git tree" cmd=do_add only_clean_git=1;; -s|--set) setto=$2; shift; cmd=do_set;; diff --git a/functions.sh.in b/functions.sh.in index 557f9a8..1295ee2 100644 --- a/functions.sh.in +++ b/functions.sh.in @@ -65,7 +65,7 @@ hostspec_to_libc() { readconfig() { local _APORTSDIR _BUILDDIR _PKGDEST _SRCPKGDEST _REPODEST _SRCDEST local _CARCH _CHOST _CTARGET _CPPFLAGS _CFLAGS _CXXFLAGS _LDFLAGS - local _JOBS _MAKEFLAGS _PACKAGER _USE_COLORS + local _JOBS _MAKEFLAGS _PACKAGER _USE_COLORS _ABUILD_GIT local gitbase= [ -n "${APORTSDIR+x}" ] && _APORTSDIR=$APORTSDIR [ -n "${BUILDDIR+x}" ] && _BUILDDIR=$BUILDDIR @@ -84,20 +84,25 @@ readconfig() { [ -n "${MAKEFLAGS+x}" ] && _MAKEFLAGS=$MAKEFLAGS [ -n "${PACKAGER+x}" ] && _PACKAGER=$PACKAGER [ -n "${USE_COLORS+x}" ] && _USE_COLORS="$USE_COLORS" + [ -n "${ABUILD_GIT+x}" ] && _ABUILD_GIT=$ABUILD_GIT : ${ABUILD_CONF:=$sysconfdir/abuild.conf} : ${ABUILD_USERDIR:=$HOME/.abuild} : ${ABUILD_USERCONF:=$ABUILD_USERDIR/abuild.conf} [ -f "$ABUILD_CONF" ] && . "$ABUILD_CONF" [ -f "$ABUILD_USERCONF" ] && . "$ABUILD_USERCONF" + ABUILD_GIT=${_ABUILD_GIT-$ABUILD_GIT} + if [ -z "$ABUILD_GIT" ]; then + ABUILD_GIT=$(command -v git) || ABUILD_GIT=true + fi APORTSDIR=${_APORTSDIR-$APORTSDIR} - gitbase=$(git rev-parse --show-toplevel 2>/dev/null) || true # already is -P + gitbase=$($ABUILD_GIT rev-parse --show-toplevel 2>/dev/null) || true # already is -P if [ -d "$APORTSDIR" ]; then APORTSDIR=$(cd "$APORTSDIR"; pwd -P) elif [ -z "$APORTSDIR" ] && [ -d "$HOME/aports" ]; then APORTSDIR=$(cd "$HOME/aports"; pwd -P) else if [ -n "$gitbase" ]; then - case $(git config remote.origin.url) in + case $($ABUILD_GIT config remote.origin.url) in */aports) APORTSDIR=$gitbase ;; *) APORTSDIR= ;; esac -- cgit v1.2.3-60-g2f50 From bed5c444f37fc4e0558af45c1d82005b331d4b0e Mon Sep 17 00:00:00 2001 From: Max Rees Date: Tue, 4 Jun 2019 00:31:45 -0400 Subject: abump, apkgrel: ensure git is maybe installed first --- abump.in | 1 + apkgrel.in | 1 + 2 files changed, 2 insertions(+) diff --git a/abump.in b/abump.in index 798fd18..d88d032 100644 --- a/abump.in +++ b/abump.in @@ -111,6 +111,7 @@ cvelist= fixes= [ -n "$APORTSDIR" ] || error "can't locate \$APORTSDIR" +[ "$ABUILD_GIT" != "true" ] || die "can't locate git command" $ABUILD_GIT rev-parse 2>/dev/null || die "not in a git tree" args=$(getopt -o f:s:Rkqh --long fixes:,security:,recursive,keep,quiet,help \ diff --git a/apkgrel.in b/apkgrel.in index e5f1ef8..31fe27b 100644 --- a/apkgrel.in +++ b/apkgrel.in @@ -107,6 +107,7 @@ while true; do -z|--zero) setto=0; cmd=do_set;; -a|--add) cmd=do_add;; -g|--clean-git) # verify that we're in a git tree + [ "$ABUILD_GIT" != "true" ] || die "can't locate git command" $ABUILD_GIT rev-parse 2>/dev/null || die "not in a git tree" cmd=do_add only_clean_git=1;; -- cgit v1.2.3-60-g2f50 From f4e30e198e61111e76658b2bd8aeccc75ccd7deb Mon Sep 17 00:00:00 2001 From: Max Rees Date: Fri, 23 Aug 2019 13:00:44 -0500 Subject: abuild: use $ABUILD_FETCH for abuild-fetch --- abuild.in | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/abuild.in b/abuild.in index b32105b..2e46625 100644 --- a/abuild.in +++ b/abuild.in @@ -25,6 +25,7 @@ fi : ${APK:="/sbin/apk"} : ${ADDUSER:="abuild-adduser"} : ${ADDGROUP:="abuild-addgroup"} +: ${ABUILD_FETCH:="abuild-fetch"} apk_opt_wait="--wait 30" @@ -335,7 +336,7 @@ uri_fetch() { local uri="$1" mkdir -p "$SRCDEST" msg "Fetching $uri" - abuild-fetch -d "$SRCDEST" "$uri" + $ABUILD_FETCH -d "$SRCDEST" "$uri" } is_remote() { -- cgit v1.2.3-60-g2f50 From e91c1ca5f5498ca0383163a7ce5fe7899399aaac Mon Sep 17 00:00:00 2001 From: Max Rees Date: Mon, 1 Jun 2020 22:24:05 -0500 Subject: checkapk: use APK_FETCH for apk --- checkapk.in | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/checkapk.in b/checkapk.in index da2fde3..01773c9 100644 --- a/checkapk.in +++ b/checkapk.in @@ -15,7 +15,7 @@ if ! [ -f "$datadir/functions.sh" ]; then fi . "$datadir/functions.sh" -: ${APK:="apk"} +: ${APK_FETCH:="apk"} usage() { cat >&2 <<-__EOF__ @@ -68,12 +68,12 @@ for i in $pkgname $subpackages; do # generate a temp repositories file with only the http(s) repos grep -E "^https?:" /etc/apk/repositories > $tmpdir/repositories - oldpkg=$($APK fetch --repositories-file $tmpdir/repositories --simulate 2>&1 | sed 's/^Downloading //') + oldpkg=$($APK_FETCH fetch --repositories-file $tmpdir/repositories --simulate 2>&1 | sed 's/^Downloading //') if [ "${oldpkg}" = "${pkg}" ]; then die "the built package ($_pkgname) is already in the repo" fi - $APK fetch --quiet --repositories-file $tmpdir/repositories --stdout $_pkgname \ + $APK_FETCH fetch --quiet --repositories-file $tmpdir/repositories --stdout $_pkgname \ | tar -ztf - | grep -v '^\.SIGN\.' | sort > filelist-$_pkgname-old \ || die "failed to download old pkg, maybe run 'apk update'?" -- cgit v1.2.3-60-g2f50 From bea4965bb14fc4d1a44432e107205472a65e74d2 Mon Sep 17 00:00:00 2001 From: Max Rees Date: Sun, 5 Jul 2020 22:40:34 -0500 Subject: abuild: add ABUILD_TMP for easier out-of-tree builds --- abuild.in | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/abuild.in b/abuild.in index 2e46625..6bb087a 100644 --- a/abuild.in +++ b/abuild.in @@ -2558,12 +2558,18 @@ fi APKBUILD=$(readlink -f "$APKBUILD") startdir="${APKBUILD%/*}" -srcdir=${ABUILD_SRCDIR:-"$startdir/src"} -pkgbasedir=${ABUILD_PKGBASEDIR:-"$startdir/pkg"} repo=${startdir%/*} repo=${repo##*/} +if [ -n "$ABUILD_TMP" ]; then + srcdir="$ABUILD_TMP/$repo/${startdir##*/}/src" + pkgbasedir="$ABUILD_TMP/$repo/${startdir##*/}/pkg" +else + srcdir="${ABUILD_SRCDIR:-"$startdir/src"}" + pkgbasedir="${ABUILD_PKGBASEDIR:-"$startdir/pkg"}" +fi + SRCDEST=${SRCDEST:-$startdir} BUILD_ROOT= -- cgit v1.2.3-60-g2f50