abuild: add option -C DIR to allow change directory

Add option to change directory before executing commands.
This commit is contained in:
Natanael Copa 2024-12-30 15:33:52 +01:00
parent 857d4c5896
commit 74ac8ef3e6
2 changed files with 8 additions and 3 deletions

View File

@ -6,7 +6,7 @@ abuild(1)
# SYNOPSIS # SYNOPSIS
*abuild* [options] [-P _REPODEST_] [-s _SRCDEST_] [-D _DESCRIPTION_] [cmd] ... *abuild* [options] [-C DIR] [-P _REPODEST_] [-s _SRCDEST_] [-D _DESCRIPTION_] [cmd] ...
# DESCRIPTION # DESCRIPTION
@ -21,6 +21,9 @@ other related operations.
*-c* *-c*
Enable colored output Enable colored output
*-C DIR*
Change directory to DIR before running any commands
*-d* *-d*
Disable dependency checking Disable dependency checking

View File

@ -2834,11 +2834,12 @@ snapshot() {
usage() { usage() {
cat <<-EOF cat <<-EOF
usage: $program [options] [-P REPODEST] [-s SRCDEST] [-D DESCRIPTION] [cmd] ... usage: $program [options] [-C DIR] [-P REPODEST] [-s SRCDEST] [-D DESC] [cmd] ...
$program [-c] -n PKGNAME[-PKGVER] $program [-c] -n PKGNAME[-PKGVER]
Options: Options:
-A Print CARCH and exit -A Print CARCH and exit
-c Enable colored output -c Enable colored output
-C Change directory before running any commands
-d Disable dependency checking -d Disable dependency checking
-D Set APKINDEX description (default: \$repo \$(git describe)) -D Set APKINDEX description (default: \$repo \$(git describe))
-f Force specified cmd (skip checks: apk up to date, arch) -f Force specified cmd (skip checks: apk up to date, arch)
@ -2887,11 +2888,12 @@ usage() {
APKBUILD="${APKBUILD:-./APKBUILD}" APKBUILD="${APKBUILD:-./APKBUILD}"
unset color_opt force forceroot install_deps keep keep_build nodeps quiet verbose unset color_opt force forceroot install_deps keep keep_build nodeps quiet verbose
while getopts ":AcdD:fFhkKmnP:qrRs:uvV" opt; do while getopts ":AcC:dD:fFhkKmnP:qrRs:uvV" opt; do
case $opt in case $opt in
'A') echo "$CARCH"; exit 0;; 'A') echo "$CARCH"; exit 0;;
'c') enable_colors 'c') enable_colors
color_opt="-c";; color_opt="-c";;
'C') chdir "$OPTARG";;
'd') nodeps="-d";; 'd') nodeps="-d";;
'D') DESCRIPTION=$OPTARG;; 'D') DESCRIPTION=$OPTARG;;
'f') force="-f";; 'f') force="-f";;