Commit d95b0a29 authored by Natanael Copa's avatar Natanael Copa

abuild: install makedeps from system repo with -r and build with -R

The -r option will only install deps from system repo and fail if any is
missing.

The -R option will parse the aports tree and try build the missing packages
and then install the newly built package.
parent 9cc011dd
...@@ -22,6 +22,8 @@ SRCDEST=${SRCDEST:-$startdir} ...@@ -22,6 +22,8 @@ SRCDEST=${SRCDEST:-$startdir}
PKGDEST=${PKGDEST:-$startdir} PKGDEST=${PKGDEST:-$startdir}
BUILD_BASE="binutils gcc make patch uclibc-dev" BUILD_BASE="binutils gcc make patch uclibc-dev"
SUDO=${SUDO:-"sudo"}
default_cmds="sanitycheck builddeps clean fetch unpack rootpkg" default_cmds="sanitycheck builddeps clean fetch unpack rootpkg"
# read config # read config
...@@ -57,7 +59,7 @@ set_xterm_title() { ...@@ -57,7 +59,7 @@ set_xterm_title() {
cleanup() { cleanup() {
set_xterm_title "" set_xterm_title ""
if [ -z "$install_after" ] && [ -n "$uninstall_after" ]; then if [ -z "$install_after" ] && [ -n "$uninstall_after" ]; then
sudo apk del $uninstall_after $SUDO apk del $uninstall_after
fi fi
} }
...@@ -446,12 +448,14 @@ depparse_aports() { ...@@ -446,12 +448,14 @@ depparse_aports() {
} }
deptrace() { deptrace() {
local deps="$@"
[ -z "$deps" ] && deps="$BUILD_BASE $depends $makedepends"
( depparse_aports ( depparse_aports
if [ -z "$upgrade" ]; then if [ -z "$upgrade" ]; then
# list installed pkgs and prefix with 'i ' # list installed pkgs and prefix with 'i '
apk info -q | sort | sed 's/^/i /' apk info -q | sort | sed 's/^/i /'
fi fi
) | awk -v pkgs="$BUILD_BASE $depends $makedepends" ' ) | awk -v pkgs="$deps" '
function depgraph(pkg, a, i) { function depgraph(pkg, a, i) {
if (visited[pkg]) if (visited[pkg])
...@@ -477,17 +481,28 @@ deptrace() { ...@@ -477,17 +481,28 @@ deptrace() {
# build and install dependencies # build and install dependencies
builddeps() { builddeps() {
local deps alldeps pkg i dir ver local deps alldeps pkg i dir ver missing
msg "Building dependencies..." msg "Building dependencies..."
deps="$BUILD_BASE $depends $makedepends" deps="$BUILD_BASE $depends $makedepends"
if [ -z "$recursive" ]; then for i in $deps; do
for i in $deps; do if ! apk info -e $i; then
apk info -e $i || die "Missing dependency $i. Use -r to build recursively" if [ -z "$install_deps" ] && [ -z "$recursive" ]; then
done die "Missing dependency $i. Use -r to autoinstall or -R to build"
fi
missing="$missing $i"
fi
done
[ -z "$missing" ] && return 0
if [ -n "$install_deps" ] && $SUDO apk add $missing; then
uninstall_after="$missing $uninstall_after"
return 0 return 0
fi fi
for i in $(deptrace); do [ -z "$recursive" ] && return 1
for i in $(deptrace $missing); do
# i = pkg:dir # i = pkg:dir
local dir=${i#*:} local dir=${i#*:}
local pkg=${i%:*} local pkg=${i%:*}
...@@ -557,7 +572,7 @@ post_add() { ...@@ -557,7 +572,7 @@ post_add() {
post_add $i || return 1 post_add $i || return 1
fi fi
done done
sudo apk add -u "$pkgf" || die "Failed to install $1" $SUDO apk add -u "$pkgf" || die "Failed to install $1"
} }
# create new aport from templates # create new aport from templates
...@@ -602,9 +617,10 @@ usage() { ...@@ -602,9 +617,10 @@ usage() {
echo " -k Keep built packages, even if APKBUILD or sources are newer" echo " -k Keep built packages, even if APKBUILD or sources are newer"
echo " -p Set package destination directory" echo " -p Set package destination directory"
echo " -q Quiet" echo " -q Quiet"
echo " -r Recursively build and install missing dependencies (using sudo)" echo " -r Install missing dependencies from system repository (using sudo)"
echo " -R Recursively build and install missing dependencies (using sudo)"
echo " -s Set source package destination directory" echo " -s Set source package destination directory"
echo " -u Recursively build and upgrade dependencies (using sudo)" echo " -u Recursively build and upgrade all dependencies (using sudo)"
echo "" echo ""
echo " -n Create a new APKBUILD in a directory named PKGNAME" echo " -n Create a new APKBUILD in a directory named PKGNAME"
echo " -c Copy a sample init.d, conf.d and install script to new directory" echo " -c Copy a sample init.d, conf.d and install script to new directory"
...@@ -632,7 +648,7 @@ usage() { ...@@ -632,7 +648,7 @@ usage() {
APKBUILD="${APKBUILD:-./APKBUILD}" APKBUILD="${APKBUILD:-./APKBUILD}"
unset force unset force
unset recursive unset recursive
while getopts "cfhi:kin:p:qrs:u" opt; do while getopts "cfhi:kin:p:qrRs:u" opt; do
case $opt in case $opt in
'c') cpinitd=1;; 'c') cpinitd=1;;
'f') force=1;; 'f') force=1;;
...@@ -642,7 +658,8 @@ while getopts "cfhi:kin:p:qrs:u" opt; do ...@@ -642,7 +658,8 @@ while getopts "cfhi:kin:p:qrs:u" opt; do
'n') newname=$OPTARG;; 'n') newname=$OPTARG;;
'p') PKGDEST=$OPTARG;; 'p') PKGDEST=$OPTARG;;
'q') quiet=1;; 'q') quiet=1;;
'r') recursive=1;; 'r') install_deps=1;;
'R') recursive=1;;
's') SRCDEST=$OPTARG;; 's') SRCDEST=$OPTARG;;
'u') upgrade=1 'u') upgrade=1
recursive=1;; recursive=1;;
......
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