manjaro-tools/bin/buildpkg.in

172 lines
4.2 KiB
Bash

#!/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@'
DATADIR='@datadir@'
SYSCONFDIR='@sysconfdir@'
[[ -r ${LIBDIR}/util-msg.sh ]] && source ${LIBDIR}/util-msg.sh
import ${LIBDIR}/util.sh
import ${LIBDIR}/util-pkg.sh
show_pkg(){
cd $1
source PKGBUILD
for n in ${pkgname[@]}; do
msg2 "$n"
done
cd ..
}
display_settings(){
show_version
show_config
msg "PROFILE:"
msg2 "sets_dir_pkg: ${sets_dir_pkg}"
msg2 "buildsets: $(list_sets ${sets_dir_pkg})"
msg2 "buildset_pkg: ${buildset_pkg}"
msg2 "is_buildset: ${is_buildset}"
msg "OPTIONS:"
msg2 "arch: ${arch}"
msg2 "branch: ${branch}"
msg2 "chroots_pkg: ${chroots_pkg}"
msg "ARGS:"
msg2 "clean_first: ${clean_first}"
msg2 "wipe_clean: ${wipe_clean}"
msg2 "namcap: ${namcap}"
msg2 "sign: ${sign}"
msg2 "udev_root: ${udev_root}"
msg2 "mkchroot_args: ${mkchroot_args[*]}"
msg "PATHS:"
msg2 "work_dir: ${work_dir}"
msg2 "pkg_dir: ${pkg_dir}"
msg2 "build_mirror: ${build_mirror}/${branch}"
if ${clean_first};then
msg "PKG:"
msg2 "base_packages: ${base_packages[*]}"
fi
msg "BUILD QUEUE:"
run show_pkg "${buildset_pkg}"
}
load_user_info
load_config "${USERCONFDIR}/manjaro-tools.conf"
load_config "${SYSCONFDIR}/manjaro-tools.conf"
load_vars "$USER_HOME/.makepkg.conf"
load_vars /etc/makepkg.conf
install_pkgs=()
clean_first=false
wipe_clean=false
namcap=false
pretend=false
is_buildset=false
sign=false
udev_root=false
usage() {
echo "Usage: ${0##*/} [options]"
echo " -p <pkg> Buildset or pkg [default: ${buildset_pkg}]"
echo " -a <arch> Arch [default: ${arch}]"
echo " -b <branch> Branch [default: ${branch}]"
echo ' -r <dir> Chroots directory'
echo " [default: ${chroots_pkg}]"
echo ' -i <pkg> Install a package into the working copy of the chroot'
echo ' -c Recreate chroot'
echo ' -w Clean up cache and sources'
echo ' -n Install and run namcap check'
echo ' -s Sign packages'
echo ' -u Udev base-devel group (no systemd)'
echo ' -q Query settings and pretend build'
echo ' -h This help'
echo ''
echo ''
exit $1
}
orig_argv=("$@")
opts='p:a:b:r:i:cwnsuqh'
while getopts "${opts}" arg; do
case "${arg}" in
p) buildset_pkg="$OPTARG" ;;
a) arch="$OPTARG" ;;
b) branch="$OPTARG" ;;
r) chroots_pkg="$OPTARG" ;;
i) install_pkgs+="$OPTARG"; mkchrootpkg_args+=(-I ${install_pkgs[*]}) ;;
c) clean_first=true; mkchroot_args+=(-L) ;;
w) wipe_clean=true ;;
n) namcap=true; mkchrootpkg_args+=(-n) ;;
s) sign=true ;;
u) udev_root=true ;;
q) pretend=true ;;
h|?) usage 0 ;;
*) echo "invalid argument '${arg}'"; usage 1 ;;
esac
done
if [[ "${arch}" == 'multilib' ]]; then
pacman_conf_arch=${arch}
work_dir=${chroots_pkg}/${branch}/${arch}
pkg_dir=${cache_dir_pkg}/${branch}/${arch}
arch='x86_64'
is_multilib=true
else
pacman_conf_arch='default'
work_dir=${chroots_pkg}/${branch}/${arch}
pkg_dir=${cache_dir_pkg}/${branch}/${arch}
is_multilib=false
fi
pacman_conf="${DATADIR}/pacman-${pacman_conf_arch}.conf"
makepkg_conf="${DATADIR}/makepkg-${arch}.conf"
mirrors_conf="${DATADIR}/pacman-mirrors-${branch}.conf"
mkchroot_args+=(-C ${pacman_conf} -M ${makepkg_conf} -S ${mirrors_conf} -B "${build_mirror}/${branch}")
mkchrootpkg_args+=(-r ${work_dir})
check_root "$0" "${orig_argv[@]}"
timer_start=$(get_timer)
eval_buildset "${sets_dir_pkg}" "${buildset_pkg}"
check_requirements
prepare_dir "${pkg_dir}"
init_base_devel
${pretend} && display_settings && exit
${wipe_clean} && clean_up
#[[ -d ${work_dir}/root ]] && check_chroot_version "${work_dir}/root"
chroot_init
run make_pkg "${buildset_pkg}"