Skip to content

Commit 7eef42f

Browse files
committed
[update] : Supported argument
1 parent 5e44b3a commit 7eef42f

File tree

3 files changed

+76
-20
lines changed

3 files changed

+76
-20
lines changed

build.sh

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ customized_password=false
2424
customized_kernel=false
2525
customized_logpath=false
2626
pkglist_args=()
27+
makepkg_script_args=()
2728
modules=()
2829
DEFAULT_ARGUMENT=""
2930
alteriso_version="3.1"
@@ -473,22 +474,12 @@ prepare_build() {
473474
eval "$(bash "${tools_dir}/locale.sh" -s -a "${arch}" get "${locale_name}")"
474475
eval "$(bash "${tools_dir}/kernel.sh" -s -c "${channel_name}" -a "${arch}" get "${kernel}")"
475476

476-
# Set username
477-
if [[ "${customized_username}" = false ]]; then
478-
username="${defaultusername}"
479-
fi
480-
481-
# Set password
482-
if [[ "${customized_password}" = false ]]; then
483-
password="${defaultpassword}"
484-
fi
477+
# Set username and password
478+
[[ "${customized_username}" = false ]] && username="${defaultusername}"
479+
[[ "${customized_password}" = false ]] && password="${defaultpassword}"
485480

486481
# gitversion
487-
if [[ "${gitversion}" = true ]]; then
488-
cd "${script_path}"
489-
iso_version="${iso_version}-$(git rev-parse --short HEAD)"
490-
cd "${OLDPWD}"
491-
fi
482+
[[ "${gitversion}" = true ]] && iso_version="${iso_version}-$(cd "${script_path}"; git rev-parse --short HEAD)"
492483

493484
# Generate iso file name.
494485
local _channel_name="${channel_name%.add}-${locale_version}"
@@ -524,11 +515,15 @@ prepare_build() {
524515

525516
# Set argument of pkglist.sh
526517
pkglist_args=("-a" "${arch}" "-k" "${kernel}" "-c" "${channel_dir}" "-l" "${locale_name}")
527-
if [[ "${boot_splash}" = true ]]; then pkglist_args+=("-b"); fi
528-
if [[ "${debug}" = true ]]; then pkglist_args+=("-d"); fi
529-
if [[ "${memtest86}" = true ]]; then pkglist_args+=("-m"); fi
530-
if (( "${#additional_exclude_pkg[@]}" >= 1 )); then pkglist_args+=("-e" "${additional_exclude_pkg[*]}"); fi
518+
[[ "${boot_splash}" = true ]] && pkglist_args+=("-b")
519+
[[ "${debug}" = true ]] && pkglist_args+=("-d")
520+
[[ "${memtest86}" = true ]] && pkglist_args+=("-m")
521+
(( "${#additional_exclude_pkg[@]}" >= 1 )) && pkglist_args+=("-e" "${additional_exclude_pkg[*]}"); fi
531522
pkglist_args+=("${modules[@]}")
523+
524+
# Set argument of aur.sh and pkgbuild.sh
525+
[[ "${bash_debug}" = true ]] && makepkg_script_args+=("-x")
526+
[[ "${pacman_debug}" = true ]] && makepkg_script_args+=("-d")
532527
}
533528

534529

@@ -595,7 +590,7 @@ make_packages_aur() {
595590
cp -rf --preserve=mode "${script_path}/system/aur.sh" "${airootfs_dir}/root/aur.sh"
596591

597592
# Run aur script
598-
_run_with_pacmanconf _chroot_run "bash $([[ "${bash_debug}" = true ]] && echo -n "-x") /root/aur.sh ${_pkglist_aur[*]}"
593+
_run_with_pacmanconf _chroot_run "bash" "/root/aur.sh" "${makepkg_script_args[@]}" "${_pkglist_aur[@]}"
599594

600595
# Remove script
601596
remove "${airootfs_dir}/root/aur.sh"
@@ -618,7 +613,7 @@ make_pkgbuild() {
618613
cp -rf --preserve=mode "${script_path}/system/pkgbuild.sh" "${airootfs_dir}/root/pkgbuild.sh"
619614

620615
# Run build script
621-
_run_with_pacmanconf _chroot_run "bash $([[ "${bash_debug}" = true ]] && echo -n "-x") /root/pkgbuild.sh /pkgbuilds"
616+
_run_with_pacmanconf _chroot_run "bash" "/root/pkgbuild.sh" "${makepkg_script_args[@]}" "/pkgbuilds"
622617

623618
# Remove script
624619
remove "${airootfs_dir}/root/pkgbuild.sh"

system/aur.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,40 @@
99
set -e -u
1010

1111
aur_username="aurbuild"
12+
pacman_debug=true
1213

1314
trap 'exit 1' 1 2 3 15
1415

16+
_help() {
17+
echo "usage ${0} [option]"
18+
echo
19+
echo "Install aur packages with yay"
20+
echo
21+
echo " General options:"
22+
echo " -d Enable pacman debug message"
23+
echo " -u [user] Set the user name to build packages"
24+
echo " -x Enable bash debug message"
25+
echo " -h This help message"
26+
}
27+
28+
while getopts "du:xh" arg; do
29+
case "${arg}" in
30+
d) pacman_debug=true ;;
31+
u) aur_username="${OPTARG}" ;;
32+
x) set -xv ;;
33+
h)
34+
_help
35+
exit 0
36+
;;
37+
*)
38+
_help
39+
exit 1
40+
;;
41+
esac
42+
done
43+
44+
shift "$((OPTIND - 1))"
45+
1546
# Show message when file is removed
1647
# remove <file> <file> ...
1748
remove() {

system/pkgbuild.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,37 @@
99
set -e
1010

1111
build_username="pkgbuild"
12+
pacman_debug=true
1213

14+
_help() {
15+
echo "usage ${0} [option]"
16+
echo
17+
echo "Build and install PKGBUILD"
18+
echo
19+
echo " General options:"
20+
echo " -d Enable pacman debug message"
21+
echo " -u [user] Set the user name to build packages"
22+
echo " -x Enable bash debug message"
23+
echo " -h This help message"
24+
}
25+
26+
while getopts "du:xh" arg; do
27+
case "${arg}" in
28+
d) pacman_debug=true ;;
29+
u) build_username="${OPTARG}" ;;
30+
x) set -xv ;;
31+
h)
32+
_help
33+
exit 0
34+
;;
35+
*)
36+
_help
37+
exit 1
38+
;;
39+
esac
40+
done
41+
42+
shift "$((OPTIND - 1))"
1343

1444
# Delete file only if file exists
1545
# remove <file1> <file2> ...

0 commit comments

Comments
 (0)