nix-tools/bin/buildpkg.in

159 lines
3.9 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@'
2015-12-08 12:33:28 +01:00
DATADIR='@datadir@'
2014-12-14 03:48:46 +01:00
SYSCONFDIR='@sysconfdir@'
[[ -r ${LIBDIR}/util-msg.sh ]] && source ${LIBDIR}/util-msg.sh
2015-06-09 00:01:31 +02:00
import ${LIBDIR}/util.sh
2015-06-12 03:25:28 +02:00
import ${LIBDIR}/util-pkg.sh
2017-03-27 18:07:26 +02:00
import ${LIBDIR}/util-pkg-chroot.sh
2014-11-13 13:33:38 +01:00
2015-11-28 17:37:13 +01:00
show_pkg(){
2016-09-15 23:58:18 +02:00
check_build "$1"
cd $1
source PKGBUILD
for n in ${pkgname[@]}; do
msg2 "%s" "$n"
done
cd ..
}
2014-11-16 23:18:01 +01:00
display_settings(){
2016-09-15 23:58:18 +02:00
show_version
show_config
msg "PROFILE:"
msg2 "build_lists: %s" "$(show_build_lists ${list_dir_pkg})"
msg2 "build_list_pkg: %s" "${build_list_pkg}"
msg2 "is_build_list: %s" "${is_build_list}"
2015-02-13 15:17:00 +01:00
2016-09-15 23:58:18 +02:00
msg "OPTIONS:"
msg2 "arch: %s" "${target_arch}"
msg2 "branch: %s" "${target_branch}"
msg2 "chroots_pkg: %s" "${chroots_pkg}"
2015-02-13 15:17:00 +01:00
2016-06-09 21:58:18 +02:00
2016-09-15 23:58:18 +02:00
msg "ARGS:"
msg2 "clean_first: %s" "${clean_first}"
msg2 "wipe_clean: %s" "${wipe_clean}"
msg2 "namcap: %s" "${namcap}"
msg2 "sign: %s" "${sign}"
2015-02-13 15:17:00 +01:00
2016-09-15 23:58:18 +02:00
msg "PATHS:"
msg2 "pkg_dir: %s" "${pkg_dir}"
2015-02-13 15:17:00 +01:00
2018-04-14 00:07:43 +02:00
if ${clean_first}; then
2016-09-15 23:58:18 +02:00
msg "PKG:"
msg2 "base_packages: %s" "${base_packages[*]}"
fi
2015-02-13 15:17:00 +01:00
2016-09-15 23:58:18 +02:00
msg "BUILD QUEUE:"
run show_pkg "${build_list_pkg}"
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
2016-06-14 17:54:44 +02:00
load_config "${USERCONFDIR}/manjaro-tools.conf" || load_config "${SYSCONFDIR}/manjaro-tools.conf"
load_vars "$USER_HOME/.makepkg.conf" || load_vars /etc/makepkg.conf
2014-11-14 23:33:53 +01:00
2015-05-29 00:31:59 +02:00
install_pkgs=()
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
2016-06-09 18:03:38 +02:00
is_build_list=false
2014-10-06 23:35:01 +02:00
sign=false
is_multilib=false
2014-10-04 00:46:40 +02:00
usage() {
2016-09-15 23:58:18 +02:00
echo "Usage: ${0##*/} [options]"
echo " -a <arch> Arch [default: ${target_arch}]"
echo " -b <branch> Branch [default: ${target_branch}]"
echo ' -c Recreate chroot'
2018-04-14 01:09:07 +02:00
echo ' -h This help'
echo ' -i <pkgs> Install packages into the working copy of the chroot'
2016-09-15 23:58:18 +02:00
echo ' -n Install and run namcap check'
2018-04-14 01:09:07 +02:00
echo " -p <pkg> Build list or pkg [default: ${build_list_pkg}]"
2016-09-15 23:58:18 +02:00
echo ' -q Query settings and pretend build'
2018-04-14 01:09:07 +02:00
echo ' -r <dir> Chroots directory'
echo " [default: ${chroots_pkg}]"
echo ' -s Sign packages'
echo ' -w Clean up cache and sources'
2016-09-15 23:58:18 +02:00
echo ''
echo ''
exit $1
2014-10-04 00:46:40 +02:00
}
2014-11-12 04:15:40 +01:00
orig_argv=("$@")
opts='p:a:b:r:i:cwnsuqh'
2014-10-04 00:46:40 +02:00
while getopts "${opts}" arg; do
2016-09-15 23:58:18 +02:00
case "${arg}" in
a) target_arch="$OPTARG" ;;
b) target_branch="$OPTARG" ;;
c) clean_first=true ;;
2018-04-14 01:09:07 +02:00
h|?) usage 0 ;;
i) install_pkgs+=("$OPTARG"); mkchrootpkg_args+=(-I ${install_pkgs[*]}) ;;
2016-09-15 23:58:18 +02:00
n) namcap=true; mkchrootpkg_args+=(-n) ;;
2018-04-14 01:09:07 +02:00
p) build_list_pkg="${OPTARG%/}" ;;
2016-09-15 23:58:18 +02:00
q) pretend=true ;;
2018-04-14 01:09:07 +02:00
r) chroots_pkg="$OPTARG" ;;
s) sign=true ;;
w) wipe_clean=true ;;
2016-09-15 23:58:18 +02:00
*) echo "invalid argument '${arg}'"; usage 1 ;;
esac
2014-10-04 00:46:40 +02:00
done
shift $(($OPTIND - 1))
check_root "$0" "${orig_argv[@]}"
prepare_dir "${log_dir}"
2017-10-23 23:31:50 +02:00
user_own "${log_dir}"
2016-06-11 20:38:44 +02:00
prepare_dir "${tmp_dir}"
prepare_conf "${target_arch}"
mirrors_conf=$(get_pac_mirrors_conf "${target_branch}")
2014-10-04 00:46:40 +02:00
mkchroot_args+=(-C ${pacman_conf} -M ${makepkg_conf} -S ${mirrors_conf} -B "${build_mirror}/${target_branch}")
2014-10-04 00:46:40 +02:00
mkchrootpkg_args+=(-r ${work_dir})
2014-10-04 00:46:40 +02:00
2015-02-18 20:08:59 +01:00
timer_start=$(get_timer)
2016-06-09 18:03:38 +02:00
eval_build_list "${list_dir_pkg}" "${build_list_pkg}"
2014-11-13 22:43:07 +01:00
prepare_dir "${pkg_dir}"
2016-09-15 00:33:42 +02:00
user_own "${pkg_dir}"
init_base_devel
2014-11-16 23:18:01 +01:00
${pretend} && display_settings && exit
${wipe_clean} && clean_up
chroot_init
2016-06-09 18:03:38 +02:00
run make_pkg "${build_list_pkg}"