Commit f7e2b48d authored by Timo Teräs's avatar Timo Teräs

abuild: remove PKGDEST and install_after features

supporting these features with cross building is non-trivial
and they do are generally not useful features, so remove them.
as result the abuildrepo is also removed to write out paths.
all package generation paths now use $REPODEST/$repo/$CARCH
which allows easily writing packages to correct $subpkgarch
in future commits.
parent f459607d
...@@ -6,7 +6,6 @@ prefix ?= /usr ...@@ -6,7 +6,6 @@ prefix ?= /usr
bindir ?= $(prefix)/bin bindir ?= $(prefix)/bin
sysconfdir ?= /etc sysconfdir ?= /etc
datadir ?= $(prefix)/share/$(PACKAGE) datadir ?= $(prefix)/share/$(PACKAGE)
abuildrepo ?= ~/.cache/abuild
SCRIPTS := abuild abuild-keygen abuild-sign newapkbuild \ SCRIPTS := abuild abuild-keygen abuild-sign newapkbuild \
abump apkgrel buildlab apkbuild-cpan checkapk \ abump apkgrel buildlab apkbuild-cpan checkapk \
...@@ -35,7 +34,6 @@ SED_REPLACE := -e 's:@VERSION@:$(FULL_VERSION):g' \ ...@@ -35,7 +34,6 @@ SED_REPLACE := -e 's:@VERSION@:$(FULL_VERSION):g' \
-e 's:@prefix@:$(prefix):g' \ -e 's:@prefix@:$(prefix):g' \
-e 's:@sysconfdir@:$(sysconfdir):g' \ -e 's:@sysconfdir@:$(sysconfdir):g' \
-e 's:@datadir@:$(datadir):g' \ -e 's:@datadir@:$(datadir):g' \
-e 's:@abuildrepo@:$(abuildrepo):g'
SSL_CFLAGS ?= $(shell pkg-config --cflags openssl) SSL_CFLAGS ?= $(shell pkg-config --cflags openssl)
SSL_LDFLAGS ?= $(shell pkg-config --cflags openssl) SSL_LDFLAGS ?= $(shell pkg-config --cflags openssl)
......
...@@ -2,13 +2,13 @@ ...@@ -2,13 +2,13 @@
# abuild - build apk packages (light version of makepkg) # abuild - build apk packages (light version of makepkg)
# Copyright (c) 2008-2015 Natanael Copa <ncopa@alpinelinux.org> # Copyright (c) 2008-2015 Natanael Copa <ncopa@alpinelinux.org>
# Copyright (c) 2016 Timo Teräs <timo.teras@iki.fi>
# #
# Distributed under GPL-2 # Distributed under GPL-2
# #
program_version=@VERSION@ program_version=@VERSION@
sysconfdir=@sysconfdir@ sysconfdir=@sysconfdir@
abuildrepo_base=@abuildrepo@
datadir=@datadir@ datadir=@datadir@
abuild_path=$(readlink -f $0) abuild_path=$(readlink -f $0)
...@@ -472,8 +472,8 @@ cleanpkg() { ...@@ -472,8 +472,8 @@ cleanpkg() {
msg "Cleaning built packages..." msg "Cleaning built packages..."
for i in $(listpkgnames); do for i in $(listpkgnames); do
local p="${i%%:*}-$pkgver-r$pkgrel" local p="${i%%:*}-$pkgver-r$pkgrel"
rm -f "$PKGDEST/$p.apk" "$PKGDEST/$p.src.tar.gz" \ rm -f "$REPODEST/$repo/$CARCH/$p.apk" \
"$abuildrepo"/$p.apk "$abuildrepo"/*/$p.apk "$REPODEST/$repo/src/$p.src.tar.gz"
done done
# remove given packages from index # remove given packages from index
update_abuildrepo_index update_abuildrepo_index
...@@ -486,10 +486,10 @@ cleanoldpkg() { ...@@ -486,10 +486,10 @@ cleanoldpkg() {
msg "Cleaning all packages except $pkgver-r$pkgrel..." msg "Cleaning all packages except $pkgver-r$pkgrel..."
for i in $(listpkgnames); do for i in $(listpkgnames); do
local pn=${i%%:*} local pn=${i%%:*}
for j in "$PKGDEST"/$pn-[0-9]*.apk ; do for j in "$REPODEST"/$repo/*/$pn-[0-9]*.apk ; do
[ "$j" = "$PKGDEST/$pn-$pkgver-r$pkgrel.apk" ] \ [ "${j##*/}" = "$pn-$pkgver-r$pkgrel.apk" ] \
&& continue && continue
rm -f "$j" "$abuildrepo"/*/${j##*/} rm -f "$j"
done done
done done
update_abuildrepo_index update_abuildrepo_index
...@@ -586,8 +586,8 @@ build() { ...@@ -586,8 +586,8 @@ build() {
# generate a simple tar.gz package of pkgdir # generate a simple tar.gz package of pkgdir
targz() { targz() {
cd "$pkgdir" || return 1 cd "$pkgdir" || return 1
mkdir -p "$PKGDEST" mkdir -p "$REPODEST"/src
tar -czf "$PKGDEST"/$pkgname-$pkgver-r$pkgrel.tar.gz * tar -czf "$REPODEST"/src/$pkgname-$pkgver-r$pkgrel.tar.gz *
} }
postcheck() { postcheck() {
...@@ -1297,7 +1297,6 @@ human_size() { ...@@ -1297,7 +1297,6 @@ human_size() {
create_apks() { create_apks() {
local file= dir= name= ver= apk= datadir= size= local file= dir= name= ver= apk= datadir= size=
getpkgver || return 1 getpkgver || return 1
mkdir -p "$PKGDEST"
if ! options_has "!tracedeps"; then if ! options_has "!tracedeps"; then
for file in "$pkgbasedir"/.control.*/.PKGINFO; do for file in "$pkgbasedir"/.control.*/.PKGINFO; do
dir="${file%/.PKGINFO}" dir="${file%/.PKGINFO}"
...@@ -1313,13 +1312,13 @@ create_apks() { ...@@ -1313,13 +1312,13 @@ create_apks() {
fi fi
for file in "$pkgbasedir"/.control.*/.PKGINFO; do for file in "$pkgbasedir"/.control.*/.PKGINFO; do
dir="${file%/.PKGINFO}" local dir="${file%/.PKGINFO}"
name=$(pkginfo_val pkgname $file) local name=$(pkginfo_val pkgname $file)
ver=$(pkginfo_val pkgver $file) local ver=$(pkginfo_val pkgver $file)
size=$(pkginfo_val size $file | human_size) local size=$(pkginfo_val size $file | human_size)
apk=$name-$ver.apk local apk=$name-$ver.apk
datadir="$pkgbasedir"/$name local datadir="$pkgbasedir"/$name
subpkgname=$name local subpkgname=$name
trace_apk_deps "$name" "$dir" || return 1 trace_apk_deps "$name" "$dir" || return 1
msg "Package size: ${size}" msg "Package size: ${size}"
...@@ -1347,39 +1346,10 @@ create_apks() { ...@@ -1347,39 +1346,10 @@ create_apks() {
msg "Create $apk" msg "Create $apk"
# create the final apk # create the final apk
cat control.tar.gz data.tar.gz > "$PKGDEST"/$apk mkdir -p "$REPODEST"/$repo/$CARCH
cat control.tar.gz data.tar.gz > "$REPODEST"/$repo/$CARCH/$apk
) )
done done
subpkgname=
}
clean_abuildrepo() {
local apk
cd "$abuildrepo" || return 1
# remove compat symlink
for d in "$abuildrepo/$CARCH"; do
[ -L "$d" ] && rm "$d"
done
# remove broken links from abuildrepo
for apk in *.apk */*.apk; do
if [ -L "$apk" ] && [ ! -f "$apk" ]; then
rm -f "$apk"
fi
done
}
mklinks_abuildrepo() {
[ -n "$REPODEST" ] && return 0
local apk
mkdir -p "$abuildrepo"/$CARCH
cd "$abuildrepo" || return 1
# create links for this package
for apk in $(listpkg); do
[ -f "$PKGDEST"/$apk ] || continue
ln -sf "$PKGDEST"/$apk "$abuildrepo"/$CARCH/$apk
done
} }
build_abuildrepo() { build_abuildrepo() {
...@@ -1391,7 +1361,7 @@ build_abuildrepo() { ...@@ -1391,7 +1361,7 @@ build_abuildrepo() {
if ! apk_up2date || [ -n "$force" ]; then if ! apk_up2date || [ -n "$force" ]; then
# check early if we have abuild key # check early if we have abuild key
abuild-sign --installed || return 1 abuild-sign --installed || return 1
logcmd "building ${abuildrepo##*/}/$pkgname-$pkgver-r$pkgrel" logcmd "building $repo/$pkgname-$pkgver-r$pkgrel"
sanitycheck && builddeps && clean && fetch && unpack \ sanitycheck && builddeps && clean && fetch && unpack \
&& prepare && mkusers && $_build && rootpkg \ && prepare && mkusers && $_build && rootpkg \
&& cleanup $CLEANUP \ && cleanup $CLEANUP \
...@@ -1401,10 +1371,7 @@ build_abuildrepo() { ...@@ -1401,10 +1371,7 @@ build_abuildrepo() {
} }
update_abuildrepo_index() { update_abuildrepo_index() {
clean_abuildrepo cd "$REPODEST/$repo"
mklinks_abuildrepo
cd "$abuildrepo"
local index=$CARCH/APKINDEX.tar.gz local index=$CARCH/APKINDEX.tar.gz
msg "Updating the cached abuild repository index..." msg "Updating the cached abuild repository index..."
...@@ -1620,9 +1587,9 @@ srcpkg() { ...@@ -1620,9 +1587,9 @@ srcpkg() {
files="$files $prefix/$f" files="$files $prefix/$f"
done done
mkdir -p "$PKGDEST" mkdir -p "$REPODEST/src"
msg "Creating source package $p.src.tar.gz..." msg "Creating source package $p.src.tar.gz..."
(cd .. && tar -zcf "$PKGDEST/$p.src.tar.gz" $files) (cd .. && tar -zcf "$REPODEST/src/$p.src.tar.gz" $files)
} }
# return true if arch is supported or noarch # return true if arch is supported or noarch
...@@ -1647,11 +1614,11 @@ check_libc() { ...@@ -1647,11 +1614,11 @@ check_libc() {
# check if package is up to date # check if package is up to date
apk_up2date() { apk_up2date() {
getpkgver || return 1 getpkgver || return 1
local pkg="$PKGDEST/$pkgname-$pkgver-r$pkgrel.apk" local pkg="$REPODEST/$repo/$CARCH/$pkgname-$pkgver-r$pkgrel.apk"
local i s local i s
cd "$startdir" cd "$startdir"
for i in $pkgname $subpackages; do for i in $pkgname $subpackages; do
[ -f "$PKGDEST/${i%%:*}-$pkgver-r$pkgrel.apk" ] || return 1 [ -f "$REPODEST/$repo/$CARCH/${i%:*}-$pkgver-r$pkgrel.apk" ] || return 1
done done
[ -n "$keep" ] && return 0 [ -n "$keep" ] && return 0
...@@ -1672,7 +1639,7 @@ apk_up2date() { ...@@ -1672,7 +1639,7 @@ apk_up2date() {
abuildindex_up2date() { abuildindex_up2date() {
local i local i
getpkgver || return 1 getpkgver || return 1
local dir="$abuildrepo"/$CARCH local dir="$REPODEST"/$repo/$CARCH
local apk="${pkgname%%:*}-$pkgver-r$pkgrel.apk" local apk="${pkgname%%:*}-$pkgver-r$pkgrel.apk"
local idx="$dir"/APKINDEX.tar.gz local idx="$dir"/APKINDEX.tar.gz
local file="$dir"/$apk local file="$dir"/$apk
...@@ -1837,14 +1804,14 @@ builddeps() { ...@@ -1837,14 +1804,14 @@ builddeps() {
if [ -n "$install_deps" ] && [ -z "$recursive" ]; then if [ -n "$install_deps" ] && [ -z "$recursive" ]; then
# make a --simulate run first to detect missing deps # make a --simulate run first to detect missing deps
# apk-tools --virtual is no goot at reporting those. # apk-tools --virtual is no goot at reporting those.
$SUDO_APK add --repository "$abuildrepo" $apk_opt_wait \ $SUDO_APK add --repository "$REPODEST/$repo" $apk_opt_wait \
--simulate --quiet $builddeps || return 1 --simulate --quiet $builddeps || return 1
$SUDO_APK add --repository "$abuildrepo" $apk_opt_wait \ $SUDO_APK add --repository "$REPODEST/$repo" $apk_opt_wait \
--virtual .makedepends-$pkgname $builddeps || return 1 --virtual .makedepends-$pkgname $builddeps || return 1
if cross_compiling; then if cross_compiling; then
$SUDO_APK add --root "$CBUILDROOT" --repository "$abuildrepo" $apk_opt_wait \ $SUDO_APK add --root "$CBUILDROOT" --repository "$REPODEST/$repo" $apk_opt_wait \
--simulate --quiet $hostdeps || return 1 --simulate --quiet $hostdeps || return 1
$SUDO_APK add --root "$CBUILDROOT" --repository "$abuildrepo" $apk_opt_wait \ $SUDO_APK add --root "$CBUILDROOT" --repository "$REPODEST/$repo" $apk_opt_wait \
--no-scripts --virtual .makedepends-$pkgname $hostdeps || return 1 --no-scripts --virtual .makedepends-$pkgname $hostdeps || return 1
fi fi
return 0 return 0
...@@ -1858,7 +1825,7 @@ builddeps() { ...@@ -1858,7 +1825,7 @@ builddeps() {
# find dependencies that are installed but missing in repo. # find dependencies that are installed but missing in repo.
for i in $builddeps; do for i in $builddeps; do
local m=$($APK search --repository "$abuildrepo" ${i%%[<>=]*}) local m=$($APK search --repository "$REPODEST/$repo" ${i%%[<>=]*})
if [ -z "$m" ]; then if [ -z "$m" ]; then
missing="$missing $i" missing="$missing $i"
fi fi
...@@ -1886,7 +1853,7 @@ builddeps() { ...@@ -1886,7 +1853,7 @@ builddeps() {
cd "$dir" && $0 $forceroot $keep $quiet $install_deps \ cd "$dir" && $0 $forceroot $keep $quiet $install_deps \
$recursive $upgrade $color_opt abuildindex || return 1 $recursive $upgrade $color_opt abuildindex || return 1
done done
$SUDO_APK add --upgrade --repository "$abuildrepo" \ $SUDO_APK add --upgrade --repository "$REPODEST/$repo" \
$apk_opt_wait \ $apk_opt_wait \
--virtual .makedepends-$pkgname $builddeps --virtual .makedepends-$pkgname $builddeps
} }
...@@ -2024,32 +1991,13 @@ install_has() { ...@@ -2024,32 +1991,13 @@ install_has() {
list_has "$1" $install list_has "$1" $install
} }
# install package after build
post_add() {
getpkgver || return 1
local pkgf="$PKGDEST/$1-$pkgver-r$pkgrel.apk"
local deps i
if ! subpackages_has $1 && [ "$1" != "$pkgname" ]; then
die "$1 is not built by this APKBUILD"
fi
# recursively install dependencies that are provided by this APKBUILD
deps=$($APK index "$pkgf" 2>/dev/null | awk -F: '$1=="D" { print $2 }')
for i in $deps; do
if subpackages_has $i || [ "$i" = "$pkgname" ]; then
post_add $i || return 1
fi
done
$SUDO_APK add $apk_opt_wait --upgrade "$pkgf" \
|| die "Failed to install $1"
}
deps() { deps() {
local builddeps= i local builddeps= i
for i in $depends $makedepends; do for i in $depends $makedepends; do
[ "$pkgname" = "${i%%[<>=]*}" ] && continue [ "$pkgname" = "${i%%[<>=]*}" ] && continue
subpackages_has ${i%%[<>=]*} || builddeps="$builddeps $i" subpackages_has ${i%%[<>=]*} || builddeps="$builddeps $i"
done done
$SUDO_APK add $apk_opt_wait --repository "$abuildrepo" \ $SUDO_APK add $apk_opt_wait --repository "$REPODEST/$repo" \
--virtual .makedepends-$pkgname \ --virtual .makedepends-$pkgname \
$builddeps $builddeps
} }
...@@ -2143,8 +2091,7 @@ snapshot() { ...@@ -2143,8 +2091,7 @@ snapshot() {
usage() { usage() {
echo "$program $program_version" echo "$program $program_version"
cat << EOF cat << EOF
usage: $program [options] [-i PKG] [-P REPODEST] [-p PKGDEST] usage: $program [options] [-P REPODEST] [-s SRCDEST] [cmd] ...
[-s SRCDEST] [cmd] ...
$program [-c] -n PKGNAME[-PKGVER] $program [-c] -n PKGNAME[-PKGVER]
Options: Options:
-A Print CARCH and exit -A Print CARCH and exit
...@@ -2157,8 +2104,7 @@ Options: ...@@ -2157,8 +2104,7 @@ Options:
-k Keep built packages, even if APKBUILD or sources are newer -k Keep built packages, even if APKBUILD or sources are newer
-K Keep buildtime temp dirs and files (srcdir/pkgdir/deps) -K Keep buildtime temp dirs and files (srcdir/pkgdir/deps)
-m Disable colors (monochrome) -m Disable colors (monochrome)
-p Set package destination directory -P Set REPODEST as the repository location for created packages
-P Set PKGDEST to REPODEST/<repo>/\$CARCH, where repo is the parents dir name
-q Quiet -q Quiet
-r Install missing dependencies from system repository (using sudo) -r Install missing dependencies from system repository (using sudo)
-R Recursively build and install missing dependencies (using sudo) -R Recursively build and install missing dependencies (using sudo)
...@@ -2174,9 +2120,9 @@ Commands: ...@@ -2174,9 +2120,9 @@ Commands:
cleanpkg Remove already built binary and source package cleanpkg Remove already built binary and source package
deps Install packages listed in makedepends and depends deps Install packages listed in makedepends and depends
fetch Fetch sources to \$SRCDEST and verify checksums fetch Fetch sources to \$SRCDEST and verify checksums
index Regenerate the APKINDEX for abuildrepo index Regenerate indexes in \$REPODEST
listpkg List target packages listpkg List target packages
package Create package in \$PKGDEST package Create package in \$REPODEST
prepare Apply patches prepare Apply patches
rootpkg Run 'package', the split functions and create apks as fakeroot rootpkg Run 'package', the split functions and create apks as fakeroot
sanitycheck Basic sanity check of APKBUILD sanitycheck Basic sanity check of APKBUILD
...@@ -2199,7 +2145,7 @@ EOF ...@@ -2199,7 +2145,7 @@ EOF
APKBUILD="${APKBUILD:-./APKBUILD}" APKBUILD="${APKBUILD:-./APKBUILD}"
unset force unset force
unset recursive unset recursive
while getopts "AcdfFhi:kKimnp:P:qrRs:u" opt; do while getopts "AcdfFhkKimnp:P:qrRs:u" opt; do
case $opt in case $opt in
'A') echo "$CARCH"; exit 0;; 'A') echo "$CARCH"; exit 0;;
'c') enable_colors 'c') enable_colors
...@@ -2208,13 +2154,11 @@ while getopts "AcdfFhi:kKimnp:P:qrRs:u" opt; do ...@@ -2208,13 +2154,11 @@ while getopts "AcdfFhi:kKimnp:P:qrRs:u" opt; do
'f') force="-f";; 'f') force="-f";;
'F') forceroot="-F";; 'F') forceroot="-F";;
'h') usage;; 'h') usage;;
'i') install_after="$install_after $OPTARG";;
'k') keep="-k";; 'k') keep="-k";;
'K') CLEANUP="" ERROR_CLEANUP="" ;; 'K') CLEANUP="" ERROR_CLEANUP="" ;;
'm') disable_colors 'm') disable_colors
color_opt="-m";; color_opt="-m";;
'n') die "Use newapkbuild to create new aports";; 'n') die "Use newapkbuild to create new aports";;
'p') PKGDEST=$OPTARG;;
'P') REPODEST=$OPTARG;; 'P') REPODEST=$OPTARG;;
'q') quiet="-q";; 'q') quiet="-q";;
'r') install_deps="-r";; 'r') install_deps="-r";;
...@@ -2244,7 +2188,6 @@ repo=${startdir%/*} ...@@ -2244,7 +2188,6 @@ repo=${startdir%/*}
repo=${repo##*/} repo=${repo##*/}
SRCDEST=${SRCDEST:-$startdir} SRCDEST=${SRCDEST:-$startdir}
PKGDEST=${PKGDEST:-$startdir}
# set a default CC # set a default CC
: ${CC:=gcc} : ${CC:=gcc}
...@@ -2254,15 +2197,15 @@ cd "$startdir" || die ...@@ -2254,15 +2197,15 @@ cd "$startdir" || die
. "$APKBUILD" . "$APKBUILD"
# If REPODEST is set then it will override the PKGDEST # If REPODEST is set then it will override the PKGDEST
if [ -n "$REPODEST" ]; then if [ -z "$REPODEST" ]; then
PKGDEST="$REPODEST/$repo/$CARCH" warning "REPODEST is not set and is now required. Defaulting to ~/packages"
# for recursive action [ -n "$PKGDEST" ] && die "PKGDEST is no longer supported."
export REPODEST REPODEST="~/packages"
abuildrepo="$REPODEST"/$repo
else
abuildrepo="$abuildrepo_base"/$repo
fi fi
# for recursive action
export REPODEST
# if we want build debug package # if we want build debug package
if [ -n "$DEBUG" ] || subpackage_types_has "dbg"; then if [ -n "$DEBUG" ] || subpackage_types_has "dbg"; then
CFLAGS="$CFLAGS -g" CFLAGS="$CFLAGS -g"
...@@ -2295,8 +2238,4 @@ while [ $# -gt 0 ]; do ...@@ -2295,8 +2238,4 @@ while [ $# -gt 0 ]; do
shift shift
done done
for i in $install_after; do
post_add $i
done
cleanup cleanup
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment