Skip to content

Commit 8194eaf

Browse files
committed
[update] : use common function to use pacman in chroot
1 parent ada1302 commit 8194eaf

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

build.sh

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -280,13 +280,21 @@ for_module(){
280280
for module in "${modules[@]}"; do eval "$(echo "${@}" | sed "s|{}|${module}|g")"; done
281281
}
282282

283-
# パッケージをインストールする
284-
_pacman(){
283+
# pacstrapを実行
284+
_pacstrap(){
285285
msg_info "Installing packages to ${airootfs_dir}/'..."
286-
pacstrap -C "${build_dir}/pacman-${arch}.conf" -c -G -M -- "${airootfs_dir}" ${*}
286+
pacstrap -C "${build_dir}/pacman-${arch}.conf" -c -G -M -- "${airootfs_dir}" "${@}"
287287
msg_info "Packages installed successfully!"
288288
}
289289

290+
# chroot環境でpacmanコマンドを実行
291+
# /etc/alteriso-pacman.confを準備してコマンドを実行します
292+
_run_with_pacmanconf(){
293+
sed "s|^CacheDir =|#CacheDir =|g" "${build_dir}/pacman-${arch}.conf" > "${airootfs_dir}/etc/alteriso-pacman.conf"
294+
"${@}"
295+
remove "${airootfs_dir}/etc/alteriso-pacman.conf"
296+
}
297+
290298
# コマンドをchrootで実行する
291299
_chroot_run() {
292300
msg_debug "Run command in chroot\nCommand: ${*}"
@@ -584,12 +592,10 @@ make_packages_repo() {
584592
printf "%s\n" "${_pkglist[@]}" >> "${build_dir}/packages.list"
585593

586594
# Install packages on airootfs
587-
_pacman "${_pkglist[@]}"
595+
_pacstrap "${_pkglist[@]}"
588596

589597
# Upgrade cached package
590-
#sed "s|^CacheDir =|#CacheDir =|g" "${build_dir}/pacman-${arch}.conf" > "${airootfs_dir}/etc/alteriso-pacman.conf"
591-
#_chroot_run pacman -Syy --noconfirm --config "/etc/alteriso-pacman.conf"
592-
# remove "${airootfs_dir}/etc/alteriso-pacman.conf"
598+
# _run_with_pacmanconf _chroot_run pacman -Syy --noconfirm --config "/etc/alteriso-pacman.conf"
593599
}
594600

595601
make_packages_aur() {
@@ -601,10 +607,9 @@ make_packages_aur() {
601607

602608
# prepare for yay
603609
cp -rf --preserve=mode "${script_path}/system/aur.sh" "${airootfs_dir}/root/aur.sh"
604-
sed "s|^CacheDir =|#CacheDir =|g" "${build_dir}/pacman-${arch}.conf" > "${airootfs_dir}/etc/alteriso-pacman.conf"
605610

606611
# Run aur script
607-
_chroot_run "bash $([[ "${bash_debug}" = true ]] && echo -n "-x") /root/aur.sh ${_pkglist_aur[*]}"
612+
_run_with_pacmanconf _chroot_run "bash $([[ "${bash_debug}" = true ]] && echo -n "-x") /root/aur.sh ${_pkglist_aur[*]}"
608613

609614
# Remove script
610615
remove "${airootfs_dir}/root/aur.sh"
@@ -623,10 +628,9 @@ make_pkgbuild() {
623628

624629
#-- ビルドスクリプトの実行 --#
625630
cp -rf --preserve=mode "${script_path}/system/pkgbuild.sh" "${airootfs_dir}/root/pkgbuild.sh"
626-
sed "s|^CacheDir =|#CacheDir =|g" "${build_dir}/pacman-${arch}.conf" > "${airootfs_dir}/etc/alteriso-pacman.conf"
627631

628632
# Run build script
629-
_chroot_run "bash $([[ "${bash_debug}" = true ]] && echo -n "-x") /root/pkgbuild.sh /pkgbuilds"
633+
_run_with_pacmanconf _chroot_run "bash $([[ "${bash_debug}" = true ]] && echo -n "-x") /root/pkgbuild.sh /pkgbuilds"
630634

631635
# Remove script
632636
remove "${airootfs_dir}/root/pkgbuild.sh"

0 commit comments

Comments
 (0)