manjaro-tools/bin/buildpkg.in

187 lines
5 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@'
import ${LIBDIR}/util-msg.sh
2015-06-09 00:01:31 +02:00
import ${LIBDIR}/util.sh
2017-04-19 21:30:38 +02:00
import ${LIBDIR}/util-chroot.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
2017-05-08 00:47:29 +02:00
# msg "PROFILE:"
# msg2 "build_lists: %s" "$(show_build_lists ${list_dir_pkg})"
# msg2 "build_list_pkg: %s" "${build_list_pkg}"
2016-09-15 23:58:18 +02:00
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 "create_first: %s" "${create_first}"
msg2 "delete_first: %s" "${delete_first}"
2016-09-15 23:58:18 +02:00
msg2 "clean_first: %s" "${clean_first}"
msg2 "update_first: %s" "${update_first}"
msg2 "purge: %s" "${purge}"
2016-09-15 23:58:18 +02:00
msg2 "namcap: %s" "${namcap}"
msg2 "sign: %s" "${sign}"
msg2 "udev_root: %s" "${udev_root}"
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
if ${create_first};then
2016-09-15 23:58:18 +02:00
msg "PKG:"
msg2 "packages: %s" "${packages[*]}"
2016-09-15 23:58:18 +02:00
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
load_config "${MT_USERCONFDIR}/manjaro-tools.conf" || load_config "${SYSCONFDIR}/manjaro-tools.conf"
load_vars "${PAC_USERCONFDIR}/makepkg.conf" || load_vars "$USER_HOME/.makepkg.conf"
load_vars /etc/makepkg.conf
2014-11-14 23:33:53 +01:00
create_first=false
delete_first=false
clean_first=false
update_first=false
purge=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
udev_root=false
is_multilib=false
mkchroot_args=()
mkchrootpkg_args=()
install_pkgs=()
prepare_build(){
local pac_arch='default'
if [[ "${target_arch}" == 'multilib' ]];then
pac_arch='multilib'
is_multilib=true
fi
local pacman_conf="${DATADIR}/pacman-$pac_arch.conf"
work_dir="${chroots_pkg}/${target_branch}/${target_arch}"
pkg_dir="${cache_dir_pkg}/${target_branch}/${target_arch}"
local makepkg_conf=$(get_makepkg_conf "${target_arch}")
[[ "$pac_arch" == 'multilib' ]] && target_arch='x86_64'
mkchroot_args+=(-C ${pacman_conf} -M ${makepkg_conf} -U "${build_mirror}/" -B "${target_branch}")
mkchrootpkg_args+=(-r ${work_dir})
2017-06-06 17:58:43 +02:00
prepare_dir "${work_dir}"
eval_build_list "${list_dir_pkg}" "${build_list_pkg}"
init_base_devel
timer_start=$(get_timer)
}
2014-10-04 00:46:40 +02:00
usage() {
2016-09-15 23:58:18 +02:00
echo "Usage: ${0##*/} [options]"
echo " -p <pkg> Build list or pkg [default: ${build_list_pkg}]"
echo " -a <arch> Arch [default: ${target_arch}]"
echo " -b <branch> Branch [default: ${target_branch}]"
echo ' -r <dir> Chroots directory'
echo " [default: ${chroots_pkg}]"
2017-02-21 18:34:07 +01:00
echo ' -i <pkgs> Install packages into the working copy of the chroot'
echo ' -o Create chroot'
echo ' -d Delete chroot'
echo ' -c Clean chroot copy'
echo ' -u Update chroot copy'
2016-09-15 23:58:18 +02:00
echo ' -w Clean up cache and sources'
echo ' -n Install and run namcap check'
echo ' -s Sign packages'
echo ' -x Udev base-devel group (no systemd)'
2016-09-15 23:58:18 +02:00
echo ' -q Query settings and pretend build'
echo ' -h This help'
echo ''
echo ''
exit $1
2014-10-04 00:46:40 +02:00
}
orig_argv=("$0" "$@")
2014-11-12 04:15:40 +01:00
2017-04-30 09:13:19 +02:00
opts='p:a:b:r:i:odcuwnsxqh'
2014-10-04 00:46:40 +02:00
while getopts "${opts}" arg; do
2016-09-15 23:58:18 +02:00
case "${arg}" in
p) build_list_pkg="$OPTARG" ;;
a) target_arch="$OPTARG" ;;
b) target_branch="$OPTARG" ;;
r) chroots_pkg="$OPTARG" ;;
i) install_pkgs+=("$OPTARG"); mkchrootpkg_args+=(-I "${install_pkgs[*]}") ;;
o) create_first=true ;;
d) delete_first=true ;;
c) clean_first=true ; mkchrootpkg_args+=(-c) ;;
u) update_first=true ; mkchrootpkg_args+=(-u) ;;
2017-04-30 09:13:19 +02:00
w) purge=true ;;
2016-09-15 23:58:18 +02:00
n) namcap=true; mkchrootpkg_args+=(-n) ;;
s) sign=true ;;
2017-04-30 09:13:19 +02:00
x) udev_root=true ;;
2016-09-15 23:58:18 +02:00
q) pretend=true ;;
h|?) usage 0 ;;
*) echo "invalid argument '%s'" "${arg}"; usage 1 ;;
2016-09-15 23:58:18 +02:00
esac
2014-10-04 00:46:40 +02:00
done
shift $(($OPTIND - 1))
check_root
prepare_build
2014-11-16 23:18:01 +01:00
${pretend} && display_settings && exit
2017-05-04 18:10:06 +02:00
${delete_first} && delete_chroot "${work_dir}/root" "${work_dir}"
${create_first} && create_chroot "${mkchroot_args[@]}" "${work_dir}/root" "${packages[@]}"
2016-06-09 18:03:38 +02:00
run make_pkg "${build_list_pkg}"