OSDN Git Service

[update] : Fully customizable AUR helper
authorhayao <hayao@fascode.net>
Sat, 6 Nov 2021 11:08:06 +0000 (20:08 +0900)
committerhayao <hayao@fascode.net>
Sat, 6 Nov 2021 11:08:06 +0000 (20:08 +0900)
build.sh
default.conf
modules/base/config.i686 [new file with mode: 0644]
system/aur.sh
system/pkgbuild.sh

index 742d305..0d4f84f 100755 (executable)
--- a/build.sh
+++ b/build.sh
@@ -382,6 +382,7 @@ prepare_build() {
     for_module load_config "${module_dir}/{}/config.any" "${module_dir}/{}/config.${arch}"
     msg_debug "Loaded modules: ${modules[*]}"
     ! printf "%s\n" "${modules[@]}" | grep -x "share" >/dev/null 2>&1 && msg_warn "The share module is not loaded."
+    ! printf "%s\n" "${modules[@]}" | grep -x "base" >/dev/null 2>&1 && msg_error "The base module is not loaded." 1
 
     # Set kernel
     [[ "${customized_kernel}" = false ]] && kernel="${defaultkernel}"
@@ -440,9 +441,8 @@ prepare_build() {
     pkglist_args+=("${modules[@]}")
 
     # Set argument of aur.sh and pkgbuild.sh
-    makepkg_script_args+=("-a" "${aur_helper}" "-p" "$(printf "%s\n" "${aur_helper_depends[@]}" | tr "\n" ",")" )
     [[ "${bash_debug}"   = true ]] && makepkg_script_args+=("-x")
-    [[ "${pacman_debug}" = true ]] && makepkg_script_args+=("-d")
+    [[ "${pacman_debug}" = true ]] && makepkg_script_args+=("-c")
 
     return 0
 }
@@ -525,6 +525,12 @@ make_packages_repo() {
 make_packages_aur() {
     readarray -t _pkglist_aur < <("${tools_dir}/pkglist.sh" --aur "${pkglist_args[@]}")
     _pkglist_aur=("${_pkglist_aur[@]}" "${norepopkg[@]}")
+    _aursh_args=(
+        "-a" "${aur_helper_command}" -e "${aur_helper_package}"
+        "-d" "$(printf "%s\n" "${aur_helper_depends[@]}" | tr "\n" ",")"
+        "-p" "$(printf "%s\n" "${_pkglist_aur[@]}" | tr "\n" ",")"
+        "${makepkg_script_args[@]}" -- "${aur_helper_args[@]}"
+    )
 
     # Create a list of packages to be finally installed as packages.list directly under the working directory.
     echo -e "\n# AUR packages.\n#\n" >> "${build_dir}/packages.list"
@@ -535,7 +541,7 @@ make_packages_aur() {
     _pacstrap --asdeps --needed "${aur_helper_depend[@]}"
 
     # Run aur script
-    _run_with_pacmanconf _chroot_run "bash" "/root/aur.sh" -a "${aur_helper}"  "${makepkg_script_args[@]}" "${_pkglist_aur[@]}"
+    _run_with_pacmanconf _chroot_run "bash" "/root/aur.sh" "${_aursh_args[@]}"
 
     # Remove script
     remove "${airootfs_dir}/root/aur.sh"
index 55b769d..4da8f25 100644 (file)
@@ -134,8 +134,21 @@ norescue_entry=false
 #modules=("share")
 
 # AUR Helper config
-aur_helper="yay"
+aur_helper_command="yay"
+aur_helper_package="yay"
 aur_helper_depends=("go")
+aur_helper_args=(
+    --useask
+    --mflags "-AcC"
+    --aur
+    --nocleanmenu
+    --nodiffmenu
+    --noeditmenu
+    --noupgrademenu
+    --noprovides
+    --removemake
+    --mflags "--skippgpcheck"
+)
 
 #-- kernel config --#
 # Set the kernel that live session use.
diff --git a/modules/base/config.i686 b/modules/base/config.i686
new file mode 100644 (file)
index 0000000..f591495
--- /dev/null
@@ -0,0 +1,26 @@
+#!/usr/bin/env bash
+#
+# Yamada Hayao
+# Twitter: @Hayao0819
+# Email  : hayao@fascode.net
+#
+# (c) 2019-2021 Fascode Network.
+#
+# Config files for all i686 channel
+#
+
+aur_helper_command="pikaur"
+aur_helper_package="pikaur"
+aur_helper_depends=(
+       'pyalpm'
+       'git'
+       'python-commonmark'
+       'asp'
+)
+aur_helper_args=(
+    #--useask
+    --mflags "-AcC,--skippgpcheck"
+    --aur
+    --noedit
+    --nodiff
+)
index 255458b..2eaa284 100755 (executable)
@@ -14,31 +14,38 @@ pacman_args=()
 failedpkg=()
 remove_list=()
 aur_helper_depends=("go")
-aur_helper="yay"
+aur_helper_command="yay"
+aur_helper_package="yay"
+aur_helper_args=()
+pkglist=()
 
 trap 'exit 1' 1 2 3 15
 
 _help() {
-    echo "usage ${0} [option] [package1] [package2] ..."
+    echo "usage ${0} [option] [aur helper args] ..."
     echo
-    echo "Install aur packages with ${aur_helper}" 
+    echo "Install aur packages with ${aur_helper_command}" 
     echo
     echo " General options:"
     echo "    -a [command]             Set the command of aur helper"
-    echo "    -p [pkg1,pkg2...]        Set the oackage of the depends of aur helper"
-    echo "    -d                       Enable pacman debug message"
+    echo "    -c                       Enable pacman debug message"
+    echo "    -e [pkg]                 Set the package name of aur helper"
+    echo "    -d [pkg1,pkg2...]        Set the oackage of the depends of aur helper"
+    echo "    -p [pkg1,pkg2...]        Set the AUR package to install"
     echo "    -u [user]                Set the user name to build packages"
     echo "    -x                       Enable bash debug message"
     echo "    -h                       This help message"
 }
 
-while getopts "a:p:du:xh" arg; do
+while getopts "a:cd:e:p:u:xh" arg; do
     case "${arg}" in
         a) aur_helper="${OPTARG}" ;;
-        d) pacman_debug=true ;;
+        c) pacman_debug=true ;;
+        e) aur_helper_command="${OPTARG}" ;;
+        p) readarray -t pkglist < <(tr "," "\n" <<< "${OPTARG}") ;;
+        d) readarray -t aur_helper_depends < <(tr "," "\n" <<< "${OPTARG}") ;;
         u) aur_username="${OPTARG}" ;;
         x) set -xv ;;
-        p) readarray -t aur_helper_depends < <(tr "," "\n" <<< "${OPTARG}") ;;
         h) 
             _help
             exit 0
@@ -51,6 +58,8 @@ while getopts "a:p:du:xh" arg; do
 done
 
 shift "$((OPTIND - 1))"
+aur_helper_args=("${@}")
+eval set -- "${pkglist[@]}"
 
 # Show message when file is removed
 # remove <file> <file> ...
@@ -88,7 +97,7 @@ if [[ "${pacman_debug}" = true ]]; then
 fi
 
 # Install
-if ! pacman -Qq "${aur_helper}" 1> /dev/null 2>&1; then
+if ! pacman -Qq "${aur_helper_package}" 1> /dev/null 2>&1; then
     # Update database
     _oldpwd="$(pwd)"
     pacman -Syy "${pacman_args[@]}"
@@ -98,13 +107,13 @@ if ! pacman -Qq "${aur_helper}" 1> /dev/null 2>&1; then
         if ! pacman -Qq "${_pkg}" > /dev/null 2>&1 | grep -q "${_pkg}"; then
             # --asdepsをつけているのでaur.shで削除される --neededをつけているので明示的にインストールされている場合削除されない
             pacman -S --asdeps --needed "${pacman_args[@]}" "${_pkg}"
-            remove_list+=("${_pkg}")
+            #remove_list+=("${_pkg}")
         fi
     done
 
     # Build
-    sudo -u "${aur_username}" git clone "https://aur.archlinux.org/${aur_helper}.git" "/tmp/${aur_helper}"
-    cd "/tmp/${aur_helper}"
+    sudo -u "${aur_username}" git clone "https://aur.archlinux.org/${aur_helper_package}.git" "/tmp/${aur_helper_package}"
+    cd "/tmp/${aur_helper_package}"
     sudo -u "${aur_username}" makepkg --ignorearch --clean --cleanbuild --force --skippgpcheck --noconfirm
 
     # Install
@@ -114,31 +123,22 @@ if ! pacman -Qq "${aur_helper}" 1> /dev/null 2>&1; then
 
     # Remove debtis
     cd ..
-    remove "/tmp/${aur_helper}"
+    remove "/tmp/${aur_helper_package}"
     cd "${_oldpwd}"
 fi
 
-if ! type -p "${aur_helper}" > /dev/null; then
-    echo "Failed to install ${aur_helper}"
+if ! type -p "${aur_helper_command}" > /dev/null; then
+    echo "Failed to install ${aur_helper_package}"
     exit 1
 fi
 
 installpkg(){
     yes | sudo -u "${aur_username}" \
-        "${aur_helper}" -Sy \
-            --mflags "-AcC" \
-            --aur \
-            --nocleanmenu \
-            --nodiffmenu \
-            --noeditmenu \
-            --noupgrademenu \
-            --noprovides \
-            --removemake \
-            --useask \
+        "${aur_helper_command}" -Sy \
             --color always \
-            --mflags "--skippgpcheck" \
-            "${pacman_args[@]}" \
             --cachedir "/var/cache/pacman/pkg/" \
+            "${pacman_args[@]}" \
+            "${aur_helper_args[@]}" \
             "${@}" || true
 }
 
@@ -169,7 +169,7 @@ readarray -t -O "${#remove_list[@]}" remove_list < <(pacman -Qttdq)
 (( "${#remove_list[@]}" != 0 )) && pacman -Rsnc "${remove_list[@]}" "${pacman_args[@]}"
 
 # Clean up
-"${aur_helper}" -Sccc "${pacman_args[@]}"
+"${aur_helper_command}" -Sccc "${pacman_args[@]}"
 
 # remove user and file
 userdel "${aur_username}"
index e813c7f..e1af63f 100755 (executable)
@@ -19,15 +19,15 @@ _help() {
     echo "Build and install PKGBUILD" 
     echo
     echo " General options:"
-    echo "    -d                       Enable pacman debug message"
+    echo "    -c                       Enable pacman debug message"
     echo "    -u [user]                Set the user name to build packages"
     echo "    -x                       Enable bash debug message"
     echo "    -h                       This help message"
 }
 
-while getopts "du:xh" arg; do
+while getopts "cu:xh" arg; do
     case "${arg}" in
-        d) pacman_debug=true ;;
+        c) pacman_debug=true ;;
         u) build_username="${OPTARG}" ;;
         x) set -xv ;;
         h)