#!/bin/bash # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; version 2 of the License. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. version=@version@ shopt -s nullglob LIBDIR='@libdir@' PKGDATADIR='@pkgdatadir@' SYSCONFDIR='@sysconfdir@' [[ -r ${LIBDIR}/util-msg.sh ]] && source ${LIBDIR}/util-msg.sh [[ -r ${LIBDIR}/util.sh ]] && source ${LIBDIR}/util.sh [[ -r ${LIBDIR}/util-pkg.sh ]] && source ${LIBDIR}/util-pkg.sh display_settings(){ msg "manjaro-tools" msg2 "version: ${version}" if [[ -f ${USER_CONFIG}/manjaro-tools.conf ]]; then msg2 "user_config: ${USER_CONFIG}/manjaro-tools.conf" else msg2 "manjaro_tools_conf: ${manjaro_tools_conf}" fi msg "OPTIONS:" msg2 "arch: ${arch}" msg2 "branch: ${branch}" msg2 "chroots: ${chroots}" msg "ARGS:" msg2 "mkchrootpkg_args: ${mkchrootpkg_args[*]}" msg2 "makepkg_args: ${makepkg_args[*]}" msg2 "clean_first: ${clean_first}" msg2 "wipe_clean: ${wipe_clean}" msg2 "namcap: ${namcap}" msg2 "sign: ${sign}" msg "PATHS:" msg2 "chrootdir: ${chrootdir}" msg2 "profiledir: ${profiledir}" msg2 "pkg_dir: ${pkg_dir}" msg2 "pacman_conf: ${pacman_conf}" msg2 "makepkg_conf: ${makepkg_conf}" msg2 "mirrors_conf: ${mirrors_conf}" msg "BLACKLIST:" msg2 "blacklist_trigger: ${blacklist_trigger[*]}" msg2 "blacklist: ${blacklist[*]}" if ${clean_first};then msg "PKG:" msg2 "base_packages: ${base_packages[*]}" fi msg "SETS:" msg2 "profiles: $(load_sets)" msg2 "profile: ${profile}" msg2 "is_profile: ${is_profile}" if ${is_profile};then msg "Build queue:" local list=$(cat ${profiledir}/${profile}.set) for item in ${list[@]}; do msg2 "$item" done else msg "Build queue:" for arg in "${makepkg_args[@]}"; do case ${arg} in --pkg) continue ;; -*) continue ;; *) local split_arg=${arg} ;; esac done if [[ -n ${split_arg} ]]; then local IFS=',' for item in ${split_arg}; do msg2 "$item" done unset IFS else msg2 "${profile}" fi fi } export LC_MESSAGES=C pkg_owner=${SUDO_USER:-$USER} if [[ -n $SUDO_USER ]]; then eval "USER_HOME=~$SUDO_USER" else USER_HOME=$HOME fi USER_CONFIG="$USER_HOME/.config" load_config "${USER_CONFIG}/manjaro-tools.conf" load_config "${SYSCONFDIR}/manjaro-tools.conf" load_vars "$USER_HOME/.makepkg.conf" load_vars /etc/makepkg.conf pacman_conf_arch='default' base_packages=('base-devel') clean_first=false wipe_clean=false namcap=false pretend=false is_profile=false sign=false usage() { echo "Usage: ${0##*/} [options] [--] [makepkg args]" echo " -p Set profile or pkg [default: ${profile}]" echo " -a Set arch [default: ${arch}]" echo " -b Set branch [default: ${branch}]" echo " -r Chroots directory [default: ${chroots}]" echo ' -c Recreate chroot' echo ' -w Clean up' echo ' -n Install and run namcap check' echo ' -s Sign packages' echo ' -q Query settings and pretend build' echo ' -h This help' echo '' echo '' exit 1 } orig_argv=("$@") opts='p:a:b:r:cwnsqh' while getopts "${opts}" arg; do case "${arg}" in p) profile="$OPTARG" ;; a) arch="$OPTARG" ;; b) branch="$OPTARG" ;; r) chroots="$OPTARG" ;; c) clean_first=true ;; w) wipe_clean=true ;; n) namcap=true; mkchrootpkg_args+=(-n) ;; s) sign=true ;; q) pretend=true ;; h) usage ;; esac done if [[ "$arch" == 'multilib' ]]; then pacman_conf_arch='multilib' base_packages+=('multilib-devel') arch='x86_64' fi chrootdir=${chroots}/${branch}/${arch} pkg_dir_loaded=${pkg_dir} pkg_dir="${pkg_dir}/${branch}/${arch}" pacman_conf="${PKGDATADIR}/pacman-${pacman_conf_arch}.conf" makepkg_conf="${PKGDATADIR}/makepkg-${arch}.conf" mirrors_conf="${PKGDATADIR}/pacman-mirrors-${branch}.conf" mkchroot_args+=(-C ${pacman_conf} -M ${makepkg_conf} -S ${mirrors_conf}) mkchrootpkg_args+=(-r ${chrootdir}) makepkg_args+=("${@:$OPTIND}") check_root "$0" "${orig_argv[@]}" [[ -d "${pkg_dir}" ]] || prepare_cachedir eval_profile "${profile}" ${pretend} && display_settings && exit ${wipe_clean} && clean_up chroot_init chroot_build ${sign} && sign_pkgs