Compare commits
10 Commits
main
...
cross-buil
Author | SHA1 | Date | |
---|---|---|---|
![]() |
74355b39d5 | ||
![]() |
05e2a0370e | ||
![]() |
e4d542950b | ||
![]() |
a51c889314 | ||
![]() |
8508cec612 | ||
![]() |
8a38bdd545 | ||
![]() |
b044128dad | ||
![]() |
89835de93f | ||
![]() |
24022b3c82 | ||
![]() |
ba7cf16e67 |
2
Makefile
2
Makefile
@ -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' \
|
|||||||
-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)
|
||||||
|
470
abuild.in
470
abuild.in
@ -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)
|
||||||
@ -79,12 +79,7 @@ cleanup() {
|
|||||||
deps)
|
deps)
|
||||||
if [ -z "$install_after" ] && [ -n "$uninstall_after" ]; then
|
if [ -z "$install_after" ] && [ -n "$uninstall_after" ]; then
|
||||||
msg "Uninstalling dependencies..."
|
msg "Uninstalling dependencies..."
|
||||||
$SUDO_APK del --quiet $apk_opt_wait $uninstall_after
|
undeps
|
||||||
if cross_compiling; then
|
|
||||||
$SUDO_APK del --root "$CBUILDROOT" \
|
|
||||||
--no-scripts --quiet $apk_opt_wait \
|
|
||||||
$uninstall_after
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
@ -132,13 +127,6 @@ default_sanitycheck() {
|
|||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
# check if CARCH, CBUILD, CHOST and CTARGET is set
|
|
||||||
[ -z "$CHOST" ] && die "Please set CHOST in /etc/abuild.conf"
|
|
||||||
|
|
||||||
if [ -z "$CARCH" ]; then
|
|
||||||
die "Please fix CHOST, or set CARCH in abuild.conf"
|
|
||||||
fi
|
|
||||||
|
|
||||||
for i in $install; do
|
for i in $install; do
|
||||||
local n=${i%.*}
|
local n=${i%.*}
|
||||||
local suff=${i##*.}
|
local suff=${i##*.}
|
||||||
@ -441,25 +429,39 @@ cleancache() {
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
listpkgnames() {
|
subpkg_unset() {
|
||||||
local i
|
unset subpkgname subpkgsplit subpkgarch
|
||||||
for i in $pkgname $subpackages; do
|
}
|
||||||
echo ${i%%:*}
|
|
||||||
done
|
subpkg_set() {
|
||||||
for i in $linguas; do
|
subpkgname=${1%%:*}
|
||||||
echo $pkgname-lang-$i
|
|
||||||
done
|
local _splitarch=${1#*:}
|
||||||
|
[ "$_splitarch" = "$1" ] && _splitarch=""
|
||||||
|
|
||||||
|
subpkgsplit=${_splitarch%%:*}
|
||||||
|
[ -z "$subpkgsplit" ] && subpkgsplit="${subpkgname##*-}"
|
||||||
|
|
||||||
|
subpkgarch=${_splitarch#*:}
|
||||||
|
if [ "$subpkgarch" = "$_splitarch" -o -z "$subpkgarch" ]; then
|
||||||
|
case "$subpkgname" in
|
||||||
|
*-doc | *-lang | *-lang-*) subpkgarch="noarch" ;;
|
||||||
|
*) subpkgarch="$pkgarch" ;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
cleanpkg() {
|
cleanpkg() {
|
||||||
local i
|
local i
|
||||||
getpkgver || return 1
|
getpkgver || return 1
|
||||||
msg "Cleaning built packages..."
|
msg "Cleaning built packages..."
|
||||||
for i in $(listpkgnames); do
|
rm -f "$REPODEST/$repo/src/$pkgname-$pkgver-r$pkgrel.src.tar.gz"
|
||||||
local p="${i%%:*}-$pkgver-r$pkgrel"
|
for i in $allpackages; do
|
||||||
rm -f "$PKGDEST/$p.apk" "$PKGDEST/$p.src.tar.gz" \
|
subpkg_set "$i"
|
||||||
"$abuildrepo"/$p.apk "$abuildrepo"/*/$p.apk
|
rm -f "$REPODEST/$repo/$subpkgarch/$subpkgname-$pkgver-r$pkgrel.apk"
|
||||||
done
|
done
|
||||||
|
subpkg_unset
|
||||||
|
|
||||||
# remove given packages from index
|
# remove given packages from index
|
||||||
update_abuildrepo_index
|
update_abuildrepo_index
|
||||||
}
|
}
|
||||||
@ -469,14 +471,15 @@ cleanoldpkg() {
|
|||||||
local i j
|
local i j
|
||||||
getpkgver || return 1
|
getpkgver || return 1
|
||||||
msg "Cleaning all packages except $pkgver-r$pkgrel..."
|
msg "Cleaning all packages except $pkgver-r$pkgrel..."
|
||||||
for i in $(listpkgnames); do
|
for i in $allpackages; do
|
||||||
local pn=${i%%:*}
|
subpkg_set "$i"
|
||||||
for j in "$PKGDEST"/$pn-[0-9]*.apk ; do
|
for j in "$REPODEST"/$repo/*/$subpkgname-[0-9]*.apk ; do
|
||||||
[ "$j" = "$PKGDEST/$pn-$pkgver-r$pkgrel.apk" ] \
|
[ "${j##*/}" = "$subpkgname-$pkgver-r$pkgrel.apk" ] \
|
||||||
&& continue
|
&& continue
|
||||||
rm -f "$j" "$abuildrepo"/*/${j##*/}
|
rm -f "$j"
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
|
subpkg_unset
|
||||||
update_abuildrepo_index
|
update_abuildrepo_index
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
@ -571,20 +574,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 *
|
||||||
}
|
|
||||||
|
|
||||||
get_split_func() {
|
|
||||||
# get the 'func' from "sub-pkg:func:arch"
|
|
||||||
local _splitarch=${1#*:}
|
|
||||||
[ "$_splitarch" = "$1" ] && _splitarch=""
|
|
||||||
local _split=${_splitarch%:*}
|
|
||||||
if [ -z "$_split" ]; then
|
|
||||||
local _name=${1%%:*}
|
|
||||||
_split="${_name##*-}"
|
|
||||||
fi
|
|
||||||
echo $_split
|
|
||||||
}
|
}
|
||||||
|
|
||||||
postcheck() {
|
postcheck() {
|
||||||
@ -678,20 +669,17 @@ pre_split() {
|
|||||||
# the subpackages should not inherit those form main package
|
# the subpackages should not inherit those form main package
|
||||||
provides=""
|
provides=""
|
||||||
install_if=""
|
install_if=""
|
||||||
apkbuild_arch="$arch"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
prepare_subpackages() {
|
prepare_subpackages() {
|
||||||
local i
|
local i
|
||||||
cd "$startdir"
|
cd "$startdir"
|
||||||
for i in $subpackages; do
|
for i in $subpackages; do
|
||||||
local func=$(get_split_func $i)
|
|
||||||
# call abuild recursively, setting subpkg{dir,name}
|
# call abuild recursively, setting subpkg{dir,name}
|
||||||
msg "Running split function $func..."
|
( subpkg_set "$i"; msg "Running split function $subpkgsplit..."; \
|
||||||
local dir="$pkgbasedir/${i%%:*}" name="${i%%:*}"
|
subpkgdir="$pkgbasedir/$subpkgname" subpkgname="$subpkgname" subpkgarch="$subpkgarch" \
|
||||||
( subpkgdir="$dir" subpkgname="$name" \
|
$0 pre_split $subpkgsplit prepare_package \
|
||||||
$0 pre_split $func prepare_package \
|
&& postcheck "$pkgbasedir/$subpkgname" "$subpkgname" ) || return 1
|
||||||
&& postcheck "$dir" "$name" ) || return 1
|
|
||||||
done
|
done
|
||||||
postcheck "$pkgdir" "$pkgname" || return 1
|
postcheck "$pkgdir" "$pkgname" || return 1
|
||||||
# post check for /usr/share/locale
|
# post check for /usr/share/locale
|
||||||
@ -704,7 +692,7 @@ prepare_subpackages() {
|
|||||||
default_lang() {
|
default_lang() {
|
||||||
pkgdesc="Languages for package $pkgname"
|
pkgdesc="Languages for package $pkgname"
|
||||||
install_if="$pkgname=$pkgver-r$pkgrel lang"
|
install_if="$pkgname=$pkgver-r$pkgrel lang"
|
||||||
arch="noarch"
|
|
||||||
local dir
|
local dir
|
||||||
for dir in ${langdir:-/usr/share/locale}; do
|
for dir in ${langdir:-/usr/share/locale}; do
|
||||||
mkdir -p "$subpkgdir"/${dir%/*}
|
mkdir -p "$subpkgdir"/${dir%/*}
|
||||||
@ -722,8 +710,8 @@ default_lang_subpkg() {
|
|||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
pkgdesc="$pkgname language pack for $lang"
|
pkgdesc="$pkgname language pack for $lang"
|
||||||
arch="noarch"
|
|
||||||
install_if="$pkgname=$pkgver-r$pkgrel lang-$lang"
|
install_if="$pkgname=$pkgver-r$pkgrel lang-$lang"
|
||||||
|
|
||||||
local dir
|
local dir
|
||||||
for dir in ${langdir:-/usr/share/locale}; do
|
for dir in ${langdir:-/usr/share/locale}; do
|
||||||
mkdir -p "$subpkgdir"/$dir
|
mkdir -p "$subpkgdir"/$dir
|
||||||
@ -738,6 +726,7 @@ lang_subpkg() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
prepare_language_packs() {
|
prepare_language_packs() {
|
||||||
|
local lang
|
||||||
for lang in $linguas; do
|
for lang in $linguas; do
|
||||||
lang="$lang" \
|
lang="$lang" \
|
||||||
subpkgname="$pkgname-lang-$lang" \
|
subpkgname="$pkgname-lang-$lang" \
|
||||||
@ -787,8 +776,8 @@ check_depends_dev() {
|
|||||||
fi
|
fi
|
||||||
local i
|
local i
|
||||||
for i in $pkgname $subpackages; do
|
for i in $pkgname $subpackages; do
|
||||||
case "$i" in
|
case "${i%%:*}" in
|
||||||
*-dev) return 0 ;;
|
*-dev) return 0 ;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
return 1
|
return 1
|
||||||
@ -808,16 +797,12 @@ prepare_metafiles() {
|
|||||||
mkdir -p "$controldir"
|
mkdir -p "$controldir"
|
||||||
local builddate=$(date -u "+%s")
|
local builddate=$(date -u "+%s")
|
||||||
local size=$(du -sk | awk '{print $1 * 1024}')
|
local size=$(du -sk | awk '{print $1 * 1024}')
|
||||||
local parch="$CARCH"
|
|
||||||
|
|
||||||
# we need to wait with setting noarch til our build infra can handle it
|
if [ "$arch" != "$apkbuild_arch" ]; then
|
||||||
# if [ "$arch" = "noarch" ]; then
|
local msg="Split function set arch=\"$arch\" for $name, use subpackages=pkg:split:arch format instead"
|
||||||
# parch="noarch"
|
[ "$arch" != "noarch" ] && die "$msg"
|
||||||
# fi
|
warning "$msg"
|
||||||
|
subpkgarch="$arch"
|
||||||
# save arch incase subpackages set it different than main pkg
|
|
||||||
if [ "${apkbuild_arch:-$arch}" != "$arch" ]; then
|
|
||||||
echo "$arch" > "$controldir"/.arch
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "# Generated by $(basename $0) $program_version" >"$pkginfo"
|
echo "# Generated by $(basename $0) $program_version" >"$pkginfo"
|
||||||
@ -833,7 +818,7 @@ url = $url
|
|||||||
builddate = $builddate
|
builddate = $builddate
|
||||||
packager = ${PACKAGER:-"Unknown"}
|
packager = ${PACKAGER:-"Unknown"}
|
||||||
size = $size
|
size = $size
|
||||||
arch = $parch
|
arch = ${subpkgarch:-$pkgarch}
|
||||||
origin = $pkgname
|
origin = $pkgname
|
||||||
EOF
|
EOF
|
||||||
local i deps
|
local i deps
|
||||||
@ -904,7 +889,7 @@ EOF
|
|||||||
prepare_trace_rpaths() {
|
prepare_trace_rpaths() {
|
||||||
local dir=${subpkgdir:-$pkgdir}
|
local dir=${subpkgdir:-$pkgdir}
|
||||||
local etype= soname= file= sover=
|
local etype= soname= file= sover=
|
||||||
[ "$arch" = "noarch" ] && return 0
|
[ "${subpkgarch:-$pkgarch}" = "noarch" ] && return 0
|
||||||
options_has "!tracedeps" && return 0
|
options_has "!tracedeps" && return 0
|
||||||
# lets tell all the places we should look for .so files - all rpaths
|
# lets tell all the places we should look for .so files - all rpaths
|
||||||
scanelf --quiet --recursive --rpath "$dir" \
|
scanelf --quiet --recursive --rpath "$dir" \
|
||||||
@ -974,10 +959,10 @@ is_doc_pkg() {
|
|||||||
archcheck() {
|
archcheck() {
|
||||||
options_has "!archcheck" && return 0
|
options_has "!archcheck" && return 0
|
||||||
if dir_has_arch_binaries "${subpkgdir:-$pkgdir}"; then
|
if dir_has_arch_binaries "${subpkgdir:-$pkgdir}"; then
|
||||||
[ "$arch" != "noarch" ] && return 0
|
[ "${subpkgarch:-$pkgarch}" != "noarch" ] && return 0
|
||||||
error "Arch specific binaries found so arch must not be set to \"noarch\""
|
error "Arch specific binaries found so arch must not be set to \"noarch\""
|
||||||
return 1
|
return 1
|
||||||
elif [ "$arch" != "noarch" ] && ! is_dev_pkg; then
|
elif [ "${subpkgarch:-$pkgarch}" != "noarch" ] && ! is_dev_pkg; then
|
||||||
# we dont want -dev package go to noarch
|
# we dont want -dev package go to noarch
|
||||||
warning "No arch specific binaries found so arch should probably be set to \"noarch\""
|
warning "No arch specific binaries found so arch should probably be set to \"noarch\""
|
||||||
fi
|
fi
|
||||||
@ -1041,7 +1026,15 @@ subpkg_provides_pc() {
|
|||||||
trace_apk_deps() {
|
trace_apk_deps() {
|
||||||
local name="$1"
|
local name="$1"
|
||||||
local dir="$2"
|
local dir="$2"
|
||||||
|
local parch="$3"
|
||||||
local i= found= autodeps= deppkgs= missing=
|
local i= found= autodeps= deppkgs= missing=
|
||||||
|
local apkroot=
|
||||||
|
|
||||||
|
case "$parch" in
|
||||||
|
$CBUILD_ARCH) ;;
|
||||||
|
$CARCH | $CTARGET_ARCH) apkroot="--root $CBUILDROOT" ;;
|
||||||
|
esac
|
||||||
|
|
||||||
msg "Tracing dependencies..."
|
msg "Tracing dependencies..."
|
||||||
# add pkgconfig if usr/lib/pkgconfig is found
|
# add pkgconfig if usr/lib/pkgconfig is found
|
||||||
if [ -d "$pkgbasedir"/$name/usr/lib/pkgconfig ] \
|
if [ -d "$pkgbasedir"/$name/usr/lib/pkgconfig ] \
|
||||||
@ -1063,8 +1056,8 @@ trace_apk_deps() {
|
|||||||
|
|
||||||
if subpkg_provides_prefixed_so "$i"; then
|
if subpkg_provides_prefixed_so "$i"; then
|
||||||
autodeps="$autodeps so:$sonameprefix$i"
|
autodeps="$autodeps so:$sonameprefix$i"
|
||||||
elif subpkg_provides_so "$i" || cross_compiling \
|
elif subpkg_provides_so "$i" \
|
||||||
|| $APK info --quiet --installed "so:$i"; then
|
|| $APK $apkroot info --quiet --installed "so:$i"; then
|
||||||
autodeps="$autodeps so:$i"
|
autodeps="$autodeps so:$i"
|
||||||
else
|
else
|
||||||
missing="$missing $i"
|
missing="$missing $i"
|
||||||
@ -1075,7 +1068,7 @@ trace_apk_deps() {
|
|||||||
if [ -f "$dir"/.rpaths ]; then
|
if [ -f "$dir"/.rpaths ]; then
|
||||||
local so_files=$(find_so_files "$dir"/.rpaths $missing) \
|
local so_files=$(find_so_files "$dir"/.rpaths $missing) \
|
||||||
|| return 1
|
|| return 1
|
||||||
deppkgs=$($APK info --quiet --who-owns $so_files) || return 1
|
deppkgs=$($APK $apkroot info --quiet --who-owns $so_files) || return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
for found in $deppkgs; do
|
for found in $deppkgs; do
|
||||||
@ -1093,9 +1086,9 @@ trace_apk_deps() {
|
|||||||
|
|
||||||
# pkg-config depends
|
# pkg-config depends
|
||||||
for i in $(sort -u "$dir"/.needs-pc 2>/dev/null); do
|
for i in $(sort -u "$dir"/.needs-pc 2>/dev/null); do
|
||||||
if subpkg_provides_pc "$i" || cross_compiling \
|
if subpkg_provides_pc "$i" \
|
||||||
|| $APK info --quiet --installed "pc:$i"; then
|
|| $APK $apkroot info --quiet --installed "pc:$i"; then
|
||||||
local provider=$(apk search --quiet "pc:$i")
|
local provider=$(apk $apkroot search --quiet "pc:$i")
|
||||||
if list_has "$provider" $depends_dev; then
|
if list_has "$provider" $depends_dev; then
|
||||||
warning "$provider should be removed from depends_dev"
|
warning "$provider should be removed from depends_dev"
|
||||||
fi
|
fi
|
||||||
@ -1104,7 +1097,7 @@ trace_apk_deps() {
|
|||||||
warning "Could not find any provider for pc:$i"
|
warning "Could not find any provider for pc:$i"
|
||||||
local pcfile=/usr/lib/pkgconfig/"${i%%[<>=]*}".pc
|
local pcfile=/usr/lib/pkgconfig/"${i%%[<>=]*}".pc
|
||||||
if [ -e "$pcfile" ]; then
|
if [ -e "$pcfile" ]; then
|
||||||
local owner=$($APK info --quiet --who-owns $pcfile)
|
local owner=$($APK $apkroot info --quiet --who-owns $pcfile)
|
||||||
warning "${owner:-package providing $pcfile} needs to be rebuilt"
|
warning "${owner:-package providing $pcfile} needs to be rebuilt"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@ -1153,7 +1146,7 @@ scan_shared_objects() {
|
|||||||
local name="$1" controldir="$2" datadir="$3"
|
local name="$1" controldir="$2" datadir="$3"
|
||||||
local opt= i=
|
local opt= i=
|
||||||
|
|
||||||
if [ "$arch" = "noarch" ] && ! [ -e "$controldir"/.arch ]; then
|
if [ "${subpkgarch:-$pkgarch}" = "noarch" ]; then
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -1300,7 +1293,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}"
|
||||||
@ -1316,15 +1308,16 @@ 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
|
||||||
|
local subpkgarch=$(pkginfo_val arch $file)
|
||||||
|
|
||||||
trace_apk_deps "$name" "$dir" || return 1
|
trace_apk_deps "$name" "$dir" "$subpkgarch" || return 1
|
||||||
msg "Package size: ${size}"
|
msg "Package size: ${size}"
|
||||||
msg "Compressing data..."
|
msg "Compressing data..."
|
||||||
(
|
(
|
||||||
@ -1349,40 +1342,10 @@ create_apks() {
|
|||||||
abuild-sign -q control.tar.gz || exit 1
|
abuild-sign -q control.tar.gz || exit 1
|
||||||
|
|
||||||
msg "Create $apk"
|
msg "Create $apk"
|
||||||
# create the final apk
|
mkdir -p "$REPODEST"/$repo/${subpkgarch/noarch/$CARCH}
|
||||||
cat control.tar.gz data.tar.gz > "$PKGDEST"/$apk
|
cat control.tar.gz data.tar.gz > "$REPODEST"/$repo/${subpkgarch/noarch/$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() {
|
||||||
@ -1394,7 +1357,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 \
|
||||||
@ -1404,33 +1367,44 @@ build_abuildrepo() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
update_abuildrepo_index() {
|
update_abuildrepo_index() {
|
||||||
clean_abuildrepo
|
local i allarch=""
|
||||||
mklinks_abuildrepo
|
for i in $allpackages; do
|
||||||
|
subpkg_set "$i"
|
||||||
|
##NOARCH: These packages are really in $CARCH and do not need their
|
||||||
|
# own repository. --rewrite-arch is used below to make sure the index
|
||||||
|
# thinks they are for $CARCH and apk-tools will fetch them from
|
||||||
|
# correct URL path. Remainder of the script uses ${subpkgarch/noarch/$CARCH}
|
||||||
|
# when expanding to the target repository path.
|
||||||
|
[ "$subpkgarch" = "noarch" ] && subpkgarch="$CARCH"
|
||||||
|
list_has "$subpkgarch" "$allarch" || allarch="$allarch $subpkgarch"
|
||||||
|
done
|
||||||
|
subpkg_unset
|
||||||
|
|
||||||
cd "$abuildrepo"
|
for i in $allarch; do
|
||||||
local index=$CARCH/APKINDEX.tar.gz
|
cd "$REPODEST/$repo/$i"
|
||||||
|
local index=$i/APKINDEX.tar.gz
|
||||||
|
|
||||||
msg "Updating the cached abuild repository index..."
|
msg "Updating the $repo/$i repository index..."
|
||||||
local sign=".SIGN.RSA.${SIGN_PUBLIC_KEY##*/}"
|
local sign=".SIGN.RSA.${SIGN_PUBLIC_KEY##*/}"
|
||||||
local oldindex=
|
local oldindex=
|
||||||
if [ -f "$index" ]; then
|
if [ -f APKINDEX.tar.gz ]; then
|
||||||
oldindex="--index $index"
|
oldindex="--index APKINDEX.tar.gz"
|
||||||
fi
|
fi
|
||||||
$APK index --quiet $oldindex --output "$index".unsigned \
|
( $APK index --quiet $oldindex --output APKINDEX.tar.gz.$$ \
|
||||||
--description "$repo $(cd $startdir && git describe)" \
|
--description "$repo $(cd $startdir && git describe)" \
|
||||||
--rewrite-arch $CARCH \
|
--rewrite-arch $i *.apk && \
|
||||||
$CARCH/*.apk || exit 1
|
msg "Signing the index..." && \
|
||||||
msg "Signing the index..."
|
abuild-sign -q APKINDEX.tar.gz.$$ && \
|
||||||
abuild-sign -q "$index".unsigned || exit 1
|
chmod 644 APKINDEX.tar.gz.$$ && \
|
||||||
mv "$index".unsigned "$index"
|
mv APKINDEX.tar.gz.$$ APKINDEX.tar.gz \
|
||||||
chmod 644 "$index"
|
) || (rm -f APKINDEX.tar.gz.$$ ; die "Failed to create index")
|
||||||
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
# predefined splitfunc doc
|
# predefined splitfunc doc
|
||||||
default_doc() {
|
default_doc() {
|
||||||
depends="$depends_doc"
|
depends="$depends_doc"
|
||||||
pkgdesc="$pkgdesc (documentation)"
|
pkgdesc="$pkgdesc (documentation)"
|
||||||
arch=${arch_doc:-"noarch"}
|
|
||||||
install_if="docs $pkgname=$pkgver-r$pkgrel"
|
install_if="docs $pkgname=$pkgver-r$pkgrel"
|
||||||
|
|
||||||
local i
|
local i
|
||||||
@ -1499,10 +1473,10 @@ default_dbg() {
|
|||||||
mkdir -p $dstdir
|
mkdir -p $dstdir
|
||||||
fi
|
fi
|
||||||
cd $srcdir
|
cd $srcdir
|
||||||
objcopy --only-keep-debug $srcfile $dstfile
|
${CROSS_COMPILE}objcopy --only-keep-debug $srcfile $dstfile
|
||||||
objcopy --add-gnu-debuglink=$dstfile $srcdir/$srcfile
|
${CROSS_COMPILE}objcopy --add-gnu-debuglink=$dstfile $srcdir/$srcfile
|
||||||
mv $dstfile $dstdir
|
mv $dstfile $dstdir
|
||||||
strip $srcfile
|
${CROSS_COMPILE}strip $srcfile
|
||||||
done
|
done
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
@ -1624,9 +1598,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
|
||||||
@ -1651,22 +1625,26 @@ 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 i s
|
local i s
|
||||||
cd "$startdir"
|
for i in $allpackages; do
|
||||||
for i in $pkgname $subpackages; do
|
subpkg_set "$i"
|
||||||
[ -f "$PKGDEST/${i%%:*}-$pkgver-r$pkgrel.apk" ] || return 1
|
if [ ! -f "$REPODEST/$repo/${subpkgarch/noarch/$CARCH}/$subpkgname-$pkgver-r$pkgrel.apk" ]; then
|
||||||
|
subpkg_unset
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
|
subpkg_unset
|
||||||
[ -n "$keep" ] && return 0
|
[ -n "$keep" ] && return 0
|
||||||
|
|
||||||
|
cd "$startdir"
|
||||||
for i in $source APKBUILD; do
|
for i in $source APKBUILD; do
|
||||||
local s
|
|
||||||
if is_remote "$i"; then
|
if is_remote "$i"; then
|
||||||
s="$SRCDEST/$(filename_from_uri $i)"
|
s="$SRCDEST/$(filename_from_uri $i)"
|
||||||
else
|
else
|
||||||
s="$startdir/${i##*/}"
|
s="$startdir/${i##*/}"
|
||||||
fi
|
fi
|
||||||
if [ "$s" -nt "$pkg" ]; then
|
if [ "$s" -nt "$REPODEST/$repo/$pkgarch/$pkgname-$pkgver-r$pkgrel.apk" ]; then
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
@ -1676,19 +1654,21 @@ apk_up2date() {
|
|||||||
abuildindex_up2date() {
|
abuildindex_up2date() {
|
||||||
local i
|
local i
|
||||||
getpkgver || return 1
|
getpkgver || return 1
|
||||||
local dir="$abuildrepo"/$CARCH
|
|
||||||
local apk="${pkgname%%:*}-$pkgver-r$pkgrel.apk"
|
|
||||||
local idx="$dir"/APKINDEX.tar.gz
|
|
||||||
local file="$dir"/$apk
|
|
||||||
|
|
||||||
# check if index is missing
|
for i in $allpackages; do
|
||||||
[ -f "$idx" ] || return 1
|
subpkg_set "$i"
|
||||||
|
local dir="$REPODEST"/$repo/${subpkgarch/noarch/$CARCH}
|
||||||
|
local idx="$dir"/APKINDEX.tar.gz
|
||||||
|
local file="$dir"/$subpkgname-$pkgver-r$pkgrel.apk
|
||||||
|
|
||||||
# if link or file is missing, then we need update abuildrepo index
|
# if any file is missing or .apk is newer then index
|
||||||
[ -f "$file" ] || return 1
|
# the index needs to be updated
|
||||||
|
if [ ! -f "$idx" -o ! -f "$file" -o "$file" -nt "$idx" ]; then
|
||||||
# if file exists and is newer than index, then we need update index
|
subpkg_unset
|
||||||
[ "$file" -nt "$idx" ] && return 1
|
return 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
subpkg_unset
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
@ -1780,33 +1760,41 @@ trace_makedepends() {
|
|||||||
'
|
'
|
||||||
}
|
}
|
||||||
|
|
||||||
# build and install dependencies
|
calcdeps() {
|
||||||
builddeps() {
|
builddeps=
|
||||||
local pkg= i= missing=
|
hostdeps=
|
||||||
local hostdeps= builddeps= installed_hostdeps= installed_builddeps=
|
|
||||||
[ -n "$nodeps" ] && return 0
|
|
||||||
msg "Analyzing dependencies..."
|
|
||||||
|
|
||||||
# add depends unless it is a subpackage or package itself
|
|
||||||
if cross_compiling && [ -n "$makedepends_build" -o -n "$makedepends_host" ]; then
|
if cross_compiling && [ -n "$makedepends_build" -o -n "$makedepends_host" ]; then
|
||||||
builddeps="$makedepends_build"
|
for i in $1 $makedepends_build; do
|
||||||
for i in $BUILD_BASE; do
|
list_has $i $hostdeps && continue
|
||||||
[ "$pkgname" = "${i%%[<>=]*}" ] && continue
|
builddeps="$builddeps $i"
|
||||||
subpackages_has ${i%%[<>=]*} || builddeps="$builddeps $i"
|
|
||||||
done
|
done
|
||||||
for i in $depends $makedepends_host; do
|
for i in $depends $makedepends_host; do
|
||||||
[ "$pkgname" = "${i%%[<>=]*}" ] && continue
|
[ "$pkgname" = "${i%%[<>=]*}" ] && continue
|
||||||
|
list_has $i $hostdeps && continue
|
||||||
subpackages_has ${i%%[<>=]*} || hostdeps="$hostdeps $i"
|
subpackages_has ${i%%[<>=]*} || hostdeps="$hostdeps $i"
|
||||||
done
|
done
|
||||||
else
|
else
|
||||||
for i in $BUILD_BASE $depends $makedepends; do
|
[ -z "$makedepends" ] && makedepends="$makedepends_build $makedepends_host"
|
||||||
|
for i in $1 $depends $makedepends; do
|
||||||
[ "$pkgname" = "${i%%[<>=]*}" ] && continue
|
[ "$pkgname" = "${i%%[<>=]*}" ] && continue
|
||||||
|
list_has $i $builddeps && continue
|
||||||
subpackages_has ${i%%[<>=]*} || builddeps="$builddeps $i"
|
subpackages_has ${i%%[<>=]*} || builddeps="$builddeps $i"
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# build and install dependencies
|
||||||
|
builddeps() {
|
||||||
|
local pkg= i= missing=
|
||||||
|
local installed_hostdeps= installed_builddeps=
|
||||||
|
[ -n "$nodeps" ] && return 0
|
||||||
|
|
||||||
|
msg "Analyzing dependencies..."
|
||||||
|
calcdeps "$BUILD_BASE"
|
||||||
|
|
||||||
installed_builddeps=$($APK info --installed $builddeps)
|
installed_builddeps=$($APK info --installed $builddeps)
|
||||||
[ -n "$hostdeps" ] && installed_hostdeps=$($APK info --root "$CBUILDROOT" --installed $hostdeps)
|
[ -n "$CBUILDROOT" -a -n "$hostdeps" ] && installed_hostdeps=$($APK info --root "$CBUILDROOT" --installed $hostdeps)
|
||||||
|
|
||||||
# find which deps are missing
|
# find which deps are missing
|
||||||
for i in $builddeps; do
|
for i in $builddeps; do
|
||||||
@ -1841,28 +1829,21 @@ 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 \
|
deps "--quiet --simulate" || return 1
|
||||||
--simulate --quiet $builddeps || return 1
|
deps || return 1
|
||||||
$SUDO_APK add --repository "$abuildrepo" $apk_opt_wait \
|
|
||||||
--virtual .makedepends-$pkgname $builddeps || return 1
|
|
||||||
if cross_compiling; then
|
|
||||||
$SUDO_APK add --root "$CBUILDROOT" --repository "$abuildrepo" $apk_opt_wait \
|
|
||||||
--simulate --quiet $hostdeps || return 1
|
|
||||||
$SUDO_APK add --root "$CBUILDROOT" --repository "$abuildrepo" $apk_opt_wait \
|
|
||||||
--no-scripts --virtual .makedepends-$pkgname $hostdeps || return 1
|
|
||||||
fi
|
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
[ -z "$recursive" ] && return 1
|
||||||
|
|
||||||
if [ -n "$CBUILDROOT" ]; then
|
if [ -n "$CBUILDROOT" ]; then
|
||||||
error "Recursive rebuilding is not supported when cross compiling."
|
error "Recursive rebuilding (-R) is not supported when cross compiling."
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
[ -z "$recursive" ] && return 1
|
|
||||||
|
|
||||||
# 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
|
||||||
@ -1890,7 +1871,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
|
||||||
}
|
}
|
||||||
@ -1927,16 +1908,24 @@ checksum() {
|
|||||||
|
|
||||||
stripbin() {
|
stripbin() {
|
||||||
local bin
|
local bin
|
||||||
if options_has "!strip" || [ "$arch" = "noarch" ]; then
|
if options_has "!strip" || [ "${subpkgarch:-$pkgarch}" = "noarch" ]; then
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
cd "${subpkgdir:-$pkgdir}" || return 1
|
cd "${subpkgdir:-$pkgdir}" || return 1
|
||||||
|
|
||||||
|
local stripcmd=strip
|
||||||
|
case "${subpkgarch:-$pkgarch}" in
|
||||||
|
$CBUILD_ARCH) stripcmd="strip" ;;
|
||||||
|
$CARCH) stripcmd="${CHOST}-strip" ;;
|
||||||
|
$CTARGET_ARCH) stripcmd="${CTARGET}-strip" ;;
|
||||||
|
esac
|
||||||
|
|
||||||
msg "Stripping binaries"
|
msg "Stripping binaries"
|
||||||
scanelf --recursive --nobanner --etype "ET_DYN,ET_EXEC" . \
|
scanelf --recursive --nobanner --etype "ET_DYN,ET_EXEC" . \
|
||||||
| sed -e 's:^ET_DYN ::' -e 's:^ET_EXEC ::' \
|
| sed -e 's:^ET_DYN ::' -e 's:^ET_EXEC ::' \
|
||||||
| while read filename; do
|
| while read filename; do
|
||||||
XATTR=$(getfattr --match="" --dump "${filename}")
|
XATTR=$(getfattr --match="" --dump "${filename}")
|
||||||
${CROSS_COMPILE}strip "${filename}"
|
"${stripcmd}" "${filename}"
|
||||||
[ -n "$XATTR" ] && (echo "$XATTR" | setfattr --restore=-)
|
[ -n "$XATTR" ] && (echo "$XATTR" | setfattr --restore=-)
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
@ -1945,9 +1934,11 @@ stripbin() {
|
|||||||
listpkg() {
|
listpkg() {
|
||||||
local name
|
local name
|
||||||
getpkgver || return 1
|
getpkgver || return 1
|
||||||
for name in $(listpkgnames) ; do
|
for name in $allpackages ; do
|
||||||
echo "$name-$pkgver-r$pkgrel.apk"
|
subpkg_set $name
|
||||||
|
echo "$subpkgname-$pkgver-r$pkgrel.apk"
|
||||||
done
|
done
|
||||||
|
subpkg_unset
|
||||||
}
|
}
|
||||||
|
|
||||||
source_has() {
|
source_has() {
|
||||||
@ -2020,42 +2011,29 @@ 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
|
[ -z "$hostdeps" -a -z "$builddeps" ] && calcdeps
|
||||||
for i in $depends $makedepends; do
|
|
||||||
[ "$pkgname" = "${i%%[<>=]*}" ] && continue
|
local _quiet="$1"
|
||||||
subpackages_has ${i%%[<>=]*} || builddeps="$builddeps $i"
|
[ -z "$_quiet" ] && msg "Installing for build:$builddeps"
|
||||||
done
|
$SUDO_APK add $_quiet $apk_opt_wait --repository "$REPODEST/$repo" \
|
||||||
$SUDO_APK add $apk_opt_wait --repository "$abuildrepo" \
|
|
||||||
--virtual .makedepends-$pkgname \
|
--virtual .makedepends-$pkgname \
|
||||||
$builddeps
|
$builddeps
|
||||||
|
if [ -n "$CBUILDROOT" ]; then
|
||||||
|
[ -z "$_quiet" ] && msg "Installing for host:$hostdeps"
|
||||||
|
$SUDO_APK add $_quiet --root "$CBUILDROOT" --repository "$REPODEST/$repo" $apk_opt_wait \
|
||||||
|
--no-scripts --virtual .makedepends-$pkgname $hostdeps || return 1
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
undeps (){
|
undeps() {
|
||||||
$SUDO_APK del $apk_opt_wait .makedepends-$pkgname
|
local _quiet="$@"
|
||||||
if cross_compiling; then
|
$SUDO_APK del $_quiet $apk_opt_wait .makedepends-$pkgname
|
||||||
$SUDO_APK del --root "$CBUILDROOT" $apk_opt_wait \
|
if [ -n "$CBUILDROOT" ]; then
|
||||||
|
$SUDO_APK del $_quiet --root "$CBUILDROOT" $apk_opt_wait \
|
||||||
--no-scripts .makedepends-$pkgname
|
--no-scripts .makedepends-$pkgname
|
||||||
fi
|
fi
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
# compat
|
# compat
|
||||||
@ -2139,8 +2117,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
|
||||||
@ -2153,8 +2130,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)
|
||||||
@ -2170,9 +2146,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
|
||||||
@ -2184,6 +2160,10 @@ Commands:
|
|||||||
up2date Compare target and sources dates
|
up2date Compare target and sources dates
|
||||||
verify Verify checksums
|
verify Verify checksums
|
||||||
|
|
||||||
|
To activate cross compilation specify in environment:
|
||||||
|
CHOST Arch or hostspec of machine to generate packages for
|
||||||
|
CTARGET Arch or hostspec of machine to generate compiler for
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
@ -2191,7 +2171,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
|
||||||
@ -2200,13 +2180,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";;
|
||||||
@ -2236,7 +2214,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}
|
||||||
@ -2246,15 +2223,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"
|
||||||
@ -2262,16 +2239,27 @@ if [ -n "$DEBUG" ] || subpackage_types_has "dbg"; then
|
|||||||
options="$options !strip"
|
options="$options !strip"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# If we are handling a sub package then reset subpackages and install
|
|
||||||
if [ -n "$subpkgname" ]; then
|
if [ -n "$subpkgname" ]; then
|
||||||
|
# If we are handling a sub package then reset subpackages and install
|
||||||
origsubpackages="$subpackages"
|
origsubpackages="$subpackages"
|
||||||
subpackages=
|
subpackages=
|
||||||
|
else
|
||||||
|
local i
|
||||||
|
allpackages="$pkgname $subpackages"
|
||||||
|
for i in $linguas; do
|
||||||
|
allpackages="$allpackages $pkgname-lang-$i::noarch"
|
||||||
|
done
|
||||||
fi
|
fi
|
||||||
|
apkbuild_arch="$arch"
|
||||||
pkgdir="$pkgbasedir/$pkgname"
|
pkgdir="$pkgbasedir/$pkgname"
|
||||||
|
if [ -z "$pkgarch" ]; then
|
||||||
|
pkgarch=$CARCH
|
||||||
|
list_has noarch $arch && pkgarch=noarch
|
||||||
|
fi
|
||||||
controldir="$pkgbasedir"/.control.${subpkgname:-$pkgname}
|
controldir="$pkgbasedir"/.control.${subpkgname:-$pkgname}
|
||||||
|
|
||||||
trap 'die "Aborted by user"' INT
|
trap 'die "Aborted by user"' INT
|
||||||
[ -z "$subpkgdir" ] && set_xterm_title "abuild: $pkgname"
|
[ -z "$subpkgdir" ] && set_xterm_title "abuild${CROSS_COMPILE+-$CARCH}: $pkgname"
|
||||||
|
|
||||||
if [ -z "$1" ]; then
|
if [ -z "$1" ]; then
|
||||||
set all
|
set all
|
||||||
@ -2282,8 +2270,4 @@ while [ $# -gt 0 ]; do
|
|||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
|
|
||||||
for i in $install_after; do
|
|
||||||
post_add $i
|
|
||||||
done
|
|
||||||
|
|
||||||
cleanup
|
cleanup
|
||||||
|
@ -3,6 +3,18 @@
|
|||||||
sysconfdir=@sysconfdir@
|
sysconfdir=@sysconfdir@
|
||||||
program=${0##*/}
|
program=${0##*/}
|
||||||
|
|
||||||
|
arch_to_hostspec() {
|
||||||
|
case "$1" in
|
||||||
|
aarch64) echo "aarch64-alpine-linux-musl" ;;
|
||||||
|
armhf) echo "armhf-alpine-linux-muslgnueabihf" ;;
|
||||||
|
armv7) echo "armv7-alpine-linux-musleabihf" ;;
|
||||||
|
s390x) echo "s390x-alpine-linux-musl" ;;
|
||||||
|
x86) echo "i586-alpine-linux-musl" ;;
|
||||||
|
x86_64) echo "x86_64-alpine-linux-musl" ;;
|
||||||
|
*) echo "unknown" ;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
hostspec_to_arch() {
|
hostspec_to_arch() {
|
||||||
case "$1" in
|
case "$1" in
|
||||||
aarch64*-*-*-*) echo "aarch64" ;;
|
aarch64*-*-*-*) echo "aarch64" ;;
|
||||||
@ -10,6 +22,7 @@ hostspec_to_arch() {
|
|||||||
armv6*-*-*-*eabihf) echo "armhf" ;;
|
armv6*-*-*-*eabihf) echo "armhf" ;;
|
||||||
armv7*-*-*-*eabihf) echo "armv7" ;;
|
armv7*-*-*-*eabihf) echo "armv7" ;;
|
||||||
i[0-9]86-*-*-*) echo "x86" ;;
|
i[0-9]86-*-*-*) echo "x86" ;;
|
||||||
|
s390x-*-*-*) echo "s390x" ;;
|
||||||
x86_64-*-*-*) echo "x86_64" ;;
|
x86_64-*-*-*) echo "x86_64" ;;
|
||||||
*) echo "unknown" ;;
|
*) echo "unknown" ;;
|
||||||
esac
|
esac
|
||||||
@ -89,11 +102,40 @@ readconfig() {
|
|||||||
[ -z "$CBUILD" ] && CBUILD="$(gcc -dumpmachine)"
|
[ -z "$CBUILD" ] && CBUILD="$(gcc -dumpmachine)"
|
||||||
[ -z "$CHOST" ] && CHOST="$CBUILD"
|
[ -z "$CHOST" ] && CHOST="$CBUILD"
|
||||||
[ -z "$CTARGET" ] && CTARGET="$CHOST"
|
[ -z "$CTARGET" ] && CTARGET="$CHOST"
|
||||||
|
[ "$(arch_to_hostspec $CBUILD)" != "unknown" ] && CBUILD="$(arch_to_hostspec $CBUILD)"
|
||||||
|
[ "$(arch_to_hostspec $CHOST)" != "unknown" ] && CHOST="$(arch_to_hostspec $CHOST)"
|
||||||
|
[ "$(arch_to_hostspec $CTARGET)" != "unknown" ] && CTARGET="$(arch_to_hostspec $CTARGET)"
|
||||||
|
|
||||||
[ -z "$CARCH" ] && CARCH="$(hostspec_to_arch $CHOST)"
|
[ -z "$CARCH" ] && CARCH="$(hostspec_to_arch $CHOST)"
|
||||||
[ -z "$CLIBC" ] && CLIBC="$(hostspec_to_libc $CHOST)"
|
[ -z "$CLIBC" ] && CLIBC="$(hostspec_to_libc $CHOST)"
|
||||||
|
[ -z "$CBUILD_ARCH" ] && CBUILD_ARCH="$(hostspec_to_arch $CBUILD)"
|
||||||
[ -z "$CTARGET_ARCH" ] && CTARGET_ARCH="$(hostspec_to_arch $CTARGET)"
|
[ -z "$CTARGET_ARCH" ] && CTARGET_ARCH="$(hostspec_to_arch $CTARGET)"
|
||||||
[ -z "$CTARGET_LIBC" ] && CTARGET_LIBC="$(hostspec_to_libc $CTARGET)"
|
[ -z "$CTARGET_LIBC" ] && CTARGET_LIBC="$(hostspec_to_libc $CTARGET)"
|
||||||
|
|
||||||
|
if [ "$CHOST" != "$CTARGET" ]; then
|
||||||
|
# setup environment for creating cross compiler
|
||||||
|
[ -z "$CBUILDROOT" ] && export CBUILDROOT="$HOME/sysroot-$CTARGET_ARCH/"
|
||||||
|
elif [ "$CBUILD" != "$CHOST" ]; then
|
||||||
|
# setup build root
|
||||||
|
[ -z "$CBUILDROOT" ] && export CBUILDROOT="$HOME/sysroot-$CTARGET_ARCH/"
|
||||||
|
# prepare pkg-config for cross building
|
||||||
|
[ -z "$PKG_CONFIG_PATH" ] && export PKG_CONFIG_PATH="${CBUILDROOT}/usr/lib/pkgconfig/"
|
||||||
|
[ -z "$PKG_CONFIG_SYSROOT_DIR" ] && export PKG_CONFIG_SYSROOT_DIR="${CBUILDROOT}"
|
||||||
|
# libtool bug workaround for extra rpaths
|
||||||
|
[ -z "$lt_cv_sys_lib_dlsearch_path_spec" ] && \
|
||||||
|
export lt_cv_sys_lib_dlsearch_path_spec="${CBUILDROOT}/lib ${CBUILDROOT}/usr/lib /usr/lib /lib /usr/local/lib"
|
||||||
|
# setup cross-compiler
|
||||||
|
if [ -z "$CROSS_COMPILE" ]; then
|
||||||
|
export CROSS_COMPILE="${CHOST}-"
|
||||||
|
export CC=${CROSS_COMPILE}gcc
|
||||||
|
export CXX=${CROSS_COMPILE}g++
|
||||||
|
export LD=${CROSS_COMPILE}ld
|
||||||
|
export CPPFLAGS="--sysroot=${CBUILDROOT} $CPPFLAGS"
|
||||||
|
export CXXFLAGS="--sysroot=${CBUILDROOT} $CXXFLAGS"
|
||||||
|
export CFLAGS="--sysroot=${CBUILDROOT} $CFLAGS"
|
||||||
|
export LDFLAGS="--sysroot=${CBUILDROOT} $LDFLAGS"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
readconfig
|
readconfig
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user