@@ -74,6 +74,9 @@ getclm() { cut -d " " -f "${1}"; }
74
74
# 指定されたぶんの半角空白文字を出力します
75
75
echo_blank (){ yes " " 2> /dev/null | head -n " ${1} " | tr -d " \n" ; }
76
76
77
+ # cpコマンドのラッパー
78
+ _cp (){ cp -af --no-preserve=ownership,mode -- " ${@ } " ; }
79
+
77
80
_usage () {
78
81
cat " ${script_path} /docs/build.sh/help.1"
79
82
local blank=" 29" _arch _dirname _type _output _first
@@ -379,6 +382,7 @@ prepare_build() {
379
382
for_module load_config " ${module_dir} /{}/config.any" " ${module_dir} /{}/config.${arch} "
380
383
msg_debug " Loaded modules: ${modules[*]} "
381
384
! printf " %s\n" " ${modules[@]} " | grep -x " share" > /dev/null 2>&1 && msg_warn " The share module is not loaded."
385
+ ! printf " %s\n" " ${modules[@]} " | grep -x " base" > /dev/null 2>&1 && msg_error " The base module is not loaded." 1
382
386
383
387
# Set kernel
384
388
[[ " ${customized_kernel} " = false ]] && kernel=" ${defaultkernel} "
@@ -424,7 +428,7 @@ prepare_build() {
424
428
mkdir -p " $( dirname " ${logging} " ) " && touch " ${logging} "
425
429
msg_warn " Re-run sudo ${0} ${ARGUMENT[*]} --nodepend --nolog --nocolor --rerun 2>&1 | tee ${logging} "
426
430
sudo " ${0} " " ${ARGUMENT[@]} " --nolog --nocolor --nodepend --rerun 2>&1 | tee " ${logging} "
427
- exit " ${? } "
431
+ exit " ${PIPESTATUS[0] } "
428
432
fi
429
433
430
434
# Set argument of pkglist.sh
@@ -438,7 +442,7 @@ prepare_build() {
438
442
439
443
# Set argument of aur.sh and pkgbuild.sh
440
444
[[ " ${bash_debug} " = true ]] && makepkg_script_args+=(" -x" )
441
- [[ " ${pacman_debug} " = true ]] && makepkg_script_args+=(" -d " )
445
+ [[ " ${pacman_debug} " = true ]] && makepkg_script_args+=(" -c " )
442
446
443
447
return 0
444
448
}
@@ -502,7 +506,7 @@ make_packages_repo() {
502
506
if printf " %s\n" " ${repopkgs[@]} " | grep -qx " ${_pkg} " ; then
503
507
_pkglist_install+=(" ${_pkg} " )
504
508
else
505
- msg_info " ${_pkg} was not found. Install it with yay from AUR"
509
+ msg_info " ${_pkg} was not found. Install it from AUR"
506
510
norepopkg+=(" ${_pkg} " )
507
511
fi
508
512
done
@@ -521,17 +525,23 @@ make_packages_repo() {
521
525
make_packages_aur () {
522
526
readarray -t _pkglist_aur < <( " ${tools_dir} /pkglist.sh" --aur " ${pkglist_args[@]} " )
523
527
_pkglist_aur=(" ${_pkglist_aur[@]} " " ${norepopkg[@]} " )
528
+ _aursh_args=(
529
+ " -a" " ${aur_helper_command} " -e " ${aur_helper_package} "
530
+ " -d" " $( printf " %s\n" " ${aur_helper_depends[@]} " | tr " \n" " ," ) "
531
+ " -p" " $( printf " %s\n" " ${_pkglist_aur[@]} " | tr " \n" " ," ) "
532
+ " ${makepkg_script_args[@]} " -- " ${aur_helper_args[@]} "
533
+ )
524
534
525
535
# Create a list of packages to be finally installed as packages.list directly under the working directory.
526
536
echo -e " \n# AUR packages.\n#\n" >> " ${build_dir} /packages.list"
527
537
printf " %s\n" " ${_pkglist_aur[@]} " >> " ${build_dir} /packages.list"
528
538
529
- # prepare for yay
530
- cp -rf --preserve=mode " ${script_path} /system/aur.sh" " ${airootfs_dir} /root/aur.sh"
531
- _pacstrap --asdeps --needed " go " # --asdepsをつけているのでaur.shで削除される --neededをつけているので明示的にインストールされている場合削除されない
539
+ # prepare for aur helper
540
+ _cp " ${script_path} /system/aur.sh" " ${airootfs_dir} /root/aur.sh"
541
+ _pacstrap --asdeps --needed " ${aur_helper_depend[@]} "
532
542
533
543
# Run aur script
534
- _run_with_pacmanconf _chroot_run " bash" " /root/aur.sh" " ${makepkg_script_args[@]} " " ${_pkglist_aur [@]}"
544
+ _run_with_pacmanconf _chroot_run " bash" " /root/aur.sh" " ${_aursh_args [@]} "
535
545
536
546
# Remove script
537
547
remove " ${airootfs_dir} /root/aur.sh"
@@ -548,11 +558,11 @@ make_pkgbuild() {
548
558
mkdir -p " ${airootfs_dir} /pkgbuilds/"
549
559
for _dir in $( find " ${_pkgbuild_dirs[@]} " -type f -name " PKGBUILD" -print0 2> /dev/null | xargs -0 -I{} realpath {} | xargs -I{} dirname {}) ; do
550
560
msg_info " Find $( basename " ${_dir} " ) "
551
- cp -r " ${_dir} " " ${airootfs_dir} /pkgbuilds/"
561
+ _cp " ${_dir} " " ${airootfs_dir} /pkgbuilds/"
552
562
done
553
563
554
564
# copy buold script
555
- cp -rf --preserve=mode " ${script_path} /system/pkgbuild.sh" " ${airootfs_dir} /root/pkgbuild.sh"
565
+ _cp " ${script_path} /system/pkgbuild.sh" " ${airootfs_dir} /root/pkgbuild.sh"
556
566
557
567
# Run build script
558
568
_run_with_pacmanconf _chroot_run " bash" " /root/pkgbuild.sh" " ${makepkg_script_args[@]} " " /pkgbuilds"
@@ -574,15 +584,15 @@ make_customize_airootfs() {
574
584
for _airootfs in " ${_airootfs_list[@]} " ; do
575
585
if [[ -d " ${_airootfs} " ]]; then
576
586
msg_debug " Copying airootfs ${_airootfs} ..."
577
- cp -af " ${_airootfs} " /* " ${airootfs_dir} "
587
+ _cp " ${_airootfs} " /* " ${airootfs_dir} "
578
588
fi
579
589
done
580
590
581
591
# Replace /etc/mkinitcpio.conf if Plymouth is enabled.
582
592
if [[ " ${boot_splash} " = true ]]; then
583
- cp -f " ${script_path} /mkinitcpio/mkinitcpio-plymouth.conf" " ${airootfs_dir} /etc/mkinitcpio.conf"
593
+ install -m 0644 -- " ${script_path} /mkinitcpio/mkinitcpio-plymouth.conf" " ${airootfs_dir} /etc/mkinitcpio.conf"
584
594
else
585
- cp -f " ${script_path} /mkinitcpio/mkinitcpio.conf" " ${airootfs_dir} /etc/mkinitcpio.conf"
595
+ install -m 0644 -- " ${script_path} /mkinitcpio/mkinitcpio.conf" " ${airootfs_dir} /etc/mkinitcpio.conf"
586
596
fi
587
597
588
598
# customize_airootfs options
@@ -646,15 +656,15 @@ make_setup_mkinitcpio() {
646
656
mkdir -p " ${airootfs_dir} /etc/initcpio/hooks" " ${airootfs_dir} /etc/initcpio/install"
647
657
648
658
for _hook in " archiso" " archiso_shutdown" " archiso_pxe_common" " archiso_pxe_nbd" " archiso_pxe_http" " archiso_pxe_nfs" " archiso_loop_mnt" ; do
649
- cp " ${script_path} /system/initcpio/hooks/${_hook} " " ${airootfs_dir} /etc/initcpio/hooks"
650
- cp " ${script_path} /system/initcpio/install/${_hook} " " ${airootfs_dir} /etc/initcpio/install"
659
+ install -m 0644 -- " ${script_path} /system/initcpio/hooks/${_hook} " " ${airootfs_dir} /etc/initcpio/hooks"
660
+ install -m 0644 -- " ${script_path} /system/initcpio/install/${_hook} " " ${airootfs_dir} /etc/initcpio/install"
651
661
done
652
662
653
663
sed -i " s|%COWSPACE%|${cowspace} |g" " ${airootfs_dir} /etc/initcpio/hooks/archiso"
654
664
sed -i " s|/usr/lib/initcpio/|/etc/initcpio/|g" " ${airootfs_dir} /etc/initcpio/install/archiso_shutdown"
655
- cp " ${script_path} /system/initcpio/install/archiso_kms" " ${airootfs_dir} /etc/initcpio/install"
656
- cp " ${script_path} /system/initcpio/script/archiso_shutdown" " ${airootfs_dir} /etc/initcpio"
657
- cp " ${script_path} /mkinitcpio/mkinitcpio-archiso.conf" " ${airootfs_dir} /etc/mkinitcpio-archiso.conf"
665
+ install -m 0644 -- " ${script_path} /system/initcpio/install/archiso_kms" " ${airootfs_dir} /etc/initcpio/install"
666
+ install -m 0755 -- " ${script_path} /system/initcpio/script/archiso_shutdown" " ${airootfs_dir} /etc/initcpio"
667
+ install -m 0644 -- " ${script_path} /mkinitcpio/mkinitcpio-archiso.conf" " ${airootfs_dir} /etc/mkinitcpio-archiso.conf"
658
668
[[ " ${boot_splash} " = true ]] && cp " ${script_path} /mkinitcpio/mkinitcpio-archiso-plymouth.conf" " ${airootfs_dir} /etc/mkinitcpio-archiso.conf"
659
669
660
670
if [[ " ${gpg_key} " ]]; then
@@ -672,8 +682,8 @@ make_setup_mkinitcpio() {
672
682
# Prepare kernel/initramfs ${install_dir}/boot/
673
683
make_boot () {
674
684
mkdir -p " ${isofs_dir} /${install_dir} /boot/${arch} "
675
- cp " ${airootfs_dir} /boot/archiso.img" " ${isofs_dir} /${install_dir} /boot/${arch} /archiso.img"
676
- cp " ${airootfs_dir} /boot/${kernel_filename} " " ${isofs_dir} /${install_dir} /boot/${arch} /${kernel_filename} "
685
+ install -m 0644 -- " ${airootfs_dir} /boot/archiso.img" " ${isofs_dir} /${install_dir} /boot/${arch} /archiso.img"
686
+ install -m 0644 -- " ${airootfs_dir} /boot/${kernel_filename} " " ${isofs_dir} /${install_dir} /boot/${arch} /${kernel_filename} "
677
687
678
688
return 0
679
689
}
@@ -710,7 +720,7 @@ make_syslinux() {
710
720
711
721
# 一時ディレクトリに設定ファイルをコピー
712
722
mkdir -p " ${build_dir} /syslinux/"
713
- cp -a " ${script_path} /syslinux/" * " ${build_dir} /syslinux/"
723
+ _cp " ${script_path} /syslinux/" * " ${build_dir} /syslinux/"
714
724
[[ -d " ${channel_dir} /syslinux" ]] && [[ " ${customized_syslinux} " = true ]] && cp -af " ${channel_dir} /syslinux" * " ${build_dir} /syslinux/"
715
725
716
726
# copy all syslinux config to work dir
@@ -734,8 +744,8 @@ make_syslinux() {
734
744
done
735
745
736
746
# Set syslinux wallpaper
737
- cp " ${script_path} /syslinux/splash.png" " ${isofs_dir} /syslinux"
738
- [[ -f " ${channel_dir} /splash.png" ]] && cp -f " ${channel_dir} /splash.png" " ${isofs_dir} /syslinux"
747
+ install -m 0644 -- " ${script_path} /syslinux/splash.png" " ${isofs_dir} /syslinux/ "
748
+ [[ -f " ${channel_dir} /splash.png" ]] && install -m 0644 -- " ${channel_dir} /splash.png" " ${isofs_dir} /syslinux"
739
749
740
750
# remove config
741
751
local _remove_config
@@ -748,9 +758,9 @@ make_syslinux() {
748
758
[[ " ${memtest86} " = false ]] && _remove_config memtest86.cfg
749
759
750
760
# copy files
751
- cp " ${airootfs_dir} /usr/lib/syslinux/bios/" * .c32 " ${isofs_dir} /syslinux"
752
- cp " ${airootfs_dir} /usr/lib/syslinux/bios/lpxelinux.0" " ${isofs_dir} /syslinux"
753
- cp " ${airootfs_dir} /usr/lib/syslinux/bios/memdisk" " ${isofs_dir} /syslinux"
761
+ install -m 0644 -- " ${airootfs_dir} /usr/lib/syslinux/bios/" * .c32 " ${isofs_dir} /syslinux/ "
762
+ install -m 0644 -- " ${airootfs_dir} /usr/lib/syslinux/bios/lpxelinux.0" " ${isofs_dir} /syslinux/ "
763
+ install -m 0644 -- " ${airootfs_dir} /usr/lib/syslinux/bios/memdisk" " ${isofs_dir} /syslinux/ "
754
764
755
765
756
766
if [[ -e " ${isofs_dir} /syslinux/hdt.c32" ]]; then
@@ -786,8 +796,8 @@ make_efi() {
786
796
install -d -m 0755 -- " ${isofs_dir} /loader/entries"
787
797
sed " s|%ARCH%|${arch} |g;" " ${script_path} /efiboot/${_use_config_name} /loader.conf" > " ${isofs_dir} /loader/loader.conf"
788
798
789
- readarray -t _efi_config_list < <( find " ${script_path} /efiboot/${_use_config_name} /" -mindepth 1 -maxdepth 1 -type f -name " archiso-usb*.conf" -printf " %f\n" | grep -v " rescue" )
790
- [[ " ${norescue_entry} " = false ]] && readarray -t _efi_config_list < <( find " ${script_path} /efiboot/${_use_config_name} /" -mindepth 1 -maxdepth 1 -type f -name " archiso-usb*.conf" -printf " %f\n" )
799
+ readarray -t _efi_config_list < <( find " ${script_path} /efiboot/${_use_config_name} /" -mindepth 1 -maxdepth 1 -type f -name " *- archiso-usb*.conf" -printf " %f\n" | grep -v " rescue" )
800
+ [[ " ${norescue_entry} " = false ]] && readarray -t _efi_config_list < <( find " ${script_path} /efiboot/${_use_config_name} /" -mindepth 1 -maxdepth 1 -type f -name " *- archiso-usb*.conf" -printf " %f\n" )
791
801
792
802
for _efi_config in " ${_efi_config_list[@]} " ; do
793
803
sed " s|%ARCHISO_LABEL%|${iso_label} |g;
@@ -825,26 +835,26 @@ make_efiboot() {
825
835
mount " ${build_dir} /efiboot.img" " ${build_dir} /efiboot"
826
836
827
837
mkdir -p " ${build_dir} /efiboot/EFI/alteriso/${arch} " " ${build_dir} /efiboot/EFI/boot" " ${build_dir} /efiboot/loader/entries"
828
- cp " ${isofs_dir} /${install_dir} /boot/${arch} /${kernel_filename} " " ${build_dir} /efiboot/EFI/alteriso/${arch} /${kernel_filename} .efi"
829
- cp " ${isofs_dir} /${install_dir} /boot/${arch} /archiso.img" " ${build_dir} /efiboot/EFI/alteriso/${arch} /archiso.img"
838
+ _cp " ${isofs_dir} /${install_dir} /boot/${arch} /${kernel_filename} " " ${build_dir} /efiboot/EFI/alteriso/${arch} /${kernel_filename} .efi"
839
+ _cp " ${isofs_dir} /${install_dir} /boot/${arch} /archiso.img" " ${build_dir} /efiboot/EFI/alteriso/${arch} /archiso.img"
830
840
831
841
local _ucode_image _efi_config _use_config_name=" nosplash" _bootfile
832
842
for _ucode_image in " ${airootfs_dir} /boot/" {intel-uc.img,intel-ucode.img,amd-uc.img,amd-ucode.img,early_ucode.cpio,microcode.cpio}; do
833
- [[ -e " ${_ucode_image} " ]] && cp " ${_ucode_image} " " ${build_dir} /efiboot/EFI/alteriso/"
843
+ [[ -e " ${_ucode_image} " ]] && _cp " ${_ucode_image} " " ${build_dir} /efiboot/EFI/alteriso/"
834
844
done
835
845
836
- cp " ${airootfs_dir} /usr/share/efitools/efi/HashTool.efi" " ${build_dir} /efiboot/EFI/boot/"
846
+ _cp " ${airootfs_dir} /usr/share/efitools/efi/HashTool.efi" " ${build_dir} /efiboot/EFI/boot/"
837
847
838
848
_bootfile=" $( basename " $( ls " ${airootfs_dir} /usr/lib/systemd/boot/efi/systemd-boot" * " .efi" ) " ) "
839
- cp " ${airootfs_dir} /usr/lib/systemd/boot/efi/${_bootfile} " " ${build_dir} /efiboot/EFI/boot/${_bootfile# systemd-} "
849
+ _cp " ${airootfs_dir} /usr/lib/systemd/boot/efi/${_bootfile} " " ${build_dir} /efiboot/EFI/boot/${_bootfile# systemd-} "
840
850
841
851
[[ " ${boot_splash} " = true ]] && _use_config_name=" splash"
842
852
sed " s|%ARCH%|${arch} |g;" " ${script_path} /efiboot/${_use_config_name} /loader.conf" > " ${build_dir} /efiboot/loader/loader.conf"
843
853
844
854
find " ${isofs_dir} /loader/entries/" -maxdepth 1 -mindepth 1 -name " uefi-shell*" -type f -printf " %p\0" | xargs -0 -I{} cp {} " ${build_dir} /efiboot/loader/entries/"
845
855
846
- readarray -t _efi_config_list < <( find " ${script_path} /efiboot/${_use_config_name} /" -mindepth 1 -maxdepth 1 -type f -name " archiso-cd*.conf" -printf " %f\n" | grep -v " rescue" )
847
- [[ " ${norescue_entry} " = false ]] && readarray -t _efi_config_list < <( find " ${script_path} /efiboot/${_use_config_name} /" -mindepth 1 -maxdepth 1 -type f -name " archiso-cd*.conf" -printf " %f\n" )
856
+ readarray -t _efi_config_list < <( find " ${script_path} /efiboot/${_use_config_name} /" -mindepth 1 -maxdepth 1 -type f -name " *- archiso-cd*.conf" -printf " %f\n" | grep -v " rescue" )
857
+ [[ " ${norescue_entry} " = false ]] && readarray -t _efi_config_list < <( find " ${script_path} /efiboot/${_use_config_name} /" -mindepth 1 -maxdepth 1 -type f -name " *- archiso-cd*.conf" -printf " %f\n" )
848
858
849
859
for _efi_config in " ${_efi_config_list[@]} " ; do
850
860
sed " s|%ARCHISO_LABEL%|${iso_label} |g;
0 commit comments