manjaro-tools/bin/buildpkg.in

194 lines
4.6 KiB
Text
Raw Normal View History

2014-10-04 00:46:40 +02:00
#!/bin/bash
2014-10-08 11:11:19 +02:00
#
2014-10-04 15:41:22 +02:00
# 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.
2014-10-08 13:14:28 +02:00
version=@version@
shopt -s nullglob
2014-12-14 03:48:46 +01:00
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
2014-11-13 13:33:38 +01:00
show_build_queue(){
if ${is_buildset};then
local list=$(cat ${sets_dir_pkg}/${buildset_pkg}.set)
for item in ${list[@]}; do
msg2 "$item"
done
else
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 "${buildset_pkg}"
fi
fi
}
2014-11-16 23:18:01 +01:00
display_settings(){
2015-02-13 15:17:00 +01:00
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 "PROFILE:"
msg2 "buildsets: $(load_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 "makepkg_args: ${makepkg_args[*]}"
msg "PATHS:"
msg2 "work_dir: ${work_dir}"
msg2 "sets_dir_pkg: ${sets_dir_pkg}"
msg2 "cache_dir_pkg: ${cache_dir_pkg}"
msg2 "build_mirror: ${build_mirror}/${branch}"
msg "BLACKLIST:"
msg2 "blacklist_trigger: ${blacklist_trigger[*]}"
msg2 "blacklist: ${blacklist[*]}"
if ${clean_first};then
msg "PKG:"
msg2 "base_packages: ${base_packages[*]}"
fi
msg "BUILD QUEUE:"
show_build_queue
2014-11-16 23:18:01 +01:00
}
2015-01-13 13:41:28 +01:00
load_user_info
2014-12-14 03:48:46 +01:00
load_config "${USER_CONFIG}/manjaro-tools.conf"
2014-12-14 03:48:46 +01:00
load_config "${SYSCONFDIR}/manjaro-tools.conf"
2014-12-08 22:58:38 +01:00
load_vars "$USER_HOME/.makepkg.conf"
2014-11-14 23:33:53 +01:00
load_vars /etc/makepkg.conf
2014-10-08 11:11:19 +02:00
pacman_conf_arch='default'
2014-11-16 23:18:01 +01:00
base_packages=('base-devel')
2014-10-08 11:11:19 +02:00
clean_first=false
2014-11-13 01:53:11 +01:00
wipe_clean=false
2014-10-04 00:46:40 +02:00
namcap=false
pretend=false
is_buildset=false
2014-10-06 23:35:01 +02:00
sign=false
2014-10-04 00:46:40 +02:00
usage() {
2015-02-13 15:17:00 +01:00
echo "Usage: ${0##*/} [options] [--] [makepkg args]"
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 ' -c Recreate chroot'
echo ' -w Clean up cache and sources'
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
2014-10-04 00:46:40 +02:00
}
2014-11-12 04:15:40 +01:00
orig_argv=("$@")
2014-11-14 23:33:53 +01:00
opts='p:a:b:r:cwnsqh'
2014-10-04 00:46:40 +02:00
while getopts "${opts}" arg; do
2015-02-13 15:17:00 +01:00
case "${arg}" in
p) buildset_pkg="$OPTARG" ;;
a) arch="$OPTARG" ;;
b) branch="$OPTARG" ;;
r) chroots_pkg="$OPTARG" ;;
c) clean_first=true; mkchroot_args+=(-L) ;;
w) wipe_clean=true ;;
n) namcap=true; mkchrootpkg_args+=(-n) ;;
s) sign=true ;;
q) pretend=true ;;
h|?) usage 0 ;;
*) echo "invalid argument '${arg}'"; usage 1 ;;
esac
2014-10-04 00:46:40 +02:00
done
if [[ "${arch}" == 'multilib' ]]; then
2015-02-13 15:17:00 +01:00
pacman_conf_arch='multilib'
base_packages+=('multilib-devel')
2015-02-13 15:17:00 +01:00
work_dir=${chroots_pkg}/${branch}/${arch}
cache_dir_pkg=${cache_dir}/${branch}/${arch}
arch='x86_64'
is_multilib=true
else
2015-02-13 15:17:00 +01:00
work_dir=${chroots_pkg}/${branch}/${arch}
cache_dir_pkg=${cache_dir}/${branch}/${arch}
is_multilib=false
2014-10-04 00:46:40 +02:00
fi
2014-12-31 01:02:43 +01:00
pacman_conf="${PKGDATADIR}/pacman-${pacman_conf_arch}.conf"
2014-12-14 03:48:46 +01:00
makepkg_conf="${PKGDATADIR}/makepkg-${arch}.conf"
mirrors_conf="${PKGDATADIR}/pacman-mirrors-${branch}.conf"
2014-10-04 00:46:40 +02:00
mkchroot_args+=(-C ${pacman_conf} -M ${makepkg_conf} -S ${mirrors_conf} -B "${build_mirror}/${branch}")
2014-10-04 00:46:40 +02:00
mkchrootpkg_args+=(-r ${work_dir})
2014-10-04 00:46:40 +02:00
2014-11-12 04:15:40 +01:00
makepkg_args+=("${@:$OPTIND}")
2014-10-04 00:46:40 +02:00
2014-11-12 04:15:40 +01:00
check_root "$0" "${orig_argv[@]}"
2014-10-07 10:34:58 +02:00
2015-02-18 20:08:59 +01:00
timer_start=$(get_timer)
2015-01-15 02:49:21 +01:00
prepare_cachedir
2014-11-13 22:43:07 +01:00
eval_buildset "${buildset_pkg}" "${sets_dir_pkg}"
2014-11-13 22:43:07 +01:00
2014-11-16 23:18:01 +01:00
${pretend} && display_settings && exit
${wipe_clean} && clean_up
[[ -d ${work_dir}/root ]] && check_chroot_pkg_version
chroot_init
2014-11-16 23:18:01 +01:00
chroot_build
2014-11-17 00:36:14 +01:00
${sign} && sign_pkgs