nix-tools/bin/build-set.in

227 lines
5.3 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-11-13 16:31:15 +01:00
[[ -r @libdir@/util-msg.sh ]] && source @libdir@/util-msg.sh
[[ -r @libdir@/util.sh ]] && source @libdir@/util.sh
[[ -r @libdir@/util-build.sh ]] && source @libdir@/util-build.sh
2014-11-13 13:33:38 +01:00
pkg_owner=${SUDO_USER:-$USER}
if [[ -n $SUDO_USER ]]; then
eval "USER_HOME=~$SUDO_USER"
else
USER_HOME=$HOME
fi
load_vars "$USER_HOME/.makepkg.conf"
load_vars /etc/makepkg.conf
2014-11-13 16:31:15 +01:00
load_config '@sysconfdir@'
2014-11-13 01:20:33 +01:00
chroot_create(){
mkdir -p "${chrootdir}"
setarch "${arch}" mkchroot \
${mkchroot_args[*]} \
"${chrootdir}/root" \
"${base_packages[*]}" || abort
}
chroot_update(){
lock 9 "${chrootdir}/root.lock" "Locking clean chroot"
chroot-run ${mkchroot_args[*]} \
"${chrootdir}/root" \
pacman -Syu --noconfirm || abort
}
2014-11-12 04:15:40 +01:00
chroot_build(){
if ${is_profile};then
msg "Start building profile: [${profile}]"
for pkg in $(cat ${profiledir}/${profile}.set); do
cd $pkg
if [[ $pkg == 'eudev' ]] || [[ $pkg == 'lib32-eudev' ]]; then
2014-11-13 01:20:33 +01:00
blacklist_pkg "${chrootdir}"
2014-11-12 04:15:40 +01:00
fi
setarch "${arch}" \
mkchrootpkg ${mkchrootpkg_args[*]} -- "${makepkg_args[*]}" || break
move_pkg "${pkg}"
cd ..
done
msg "Finished building profile: [${profile}]"
else
cd ${profile}
if [[ ${profile} == 'eudev' ]] || [[ ${profile} == 'lib32-eudev' ]]; then
2014-11-13 01:20:33 +01:00
blacklist_pkg "${chrootdir}"
2014-11-12 04:15:40 +01:00
fi
setarch "${arch}" \
mkchrootpkg ${mkchrootpkg_args[*]} -- "${makepkg_args[*]}" || abort
move_pkg "${profile}"
cd ..
fi
}
chroot_init(){
2014-11-13 01:53:11 +01:00
if ${clean_first} || [[ ! -d "${chrootdir}" ]]; then
msg "Creating chroot for [${branch}] (${arch})..."
2014-11-13 01:20:33 +01:00
chroot_clean "${chrootdir}"
chroot_create
2014-11-12 04:15:40 +01:00
else
msg "Updating chroot for [${branch}] (${arch})..."
2014-11-13 01:20:33 +01:00
chroot_update
2014-11-12 04:15:40 +01:00
fi
}
2014-11-12 02:19:58 +01:00
display_settings(){
msg "manjaro-tools version: ${version}"
msg "OPTARGS:"
msg2 "arch: ${arch}"
msg2 "branch: ${branch}"
msg2 "chroots: ${chroots}"
msg "PATHS:"
msg2 "chrootdir: ${chrootdir}"
msg2 "profiledir: ${profiledir}"
msg2 "pkgdir: ${pkgdir}"
msg2 "pacman_conf: ${pacman_conf}"
msg2 "makepkg_conf: ${makepkg_conf}"
msg2 "pm_conf: ${pm_conf}"
if ${clean_first};then
msg "PKG:"
msg2 "base_packages: ${base_packages[*]}"
fi
msg "SETS:"
msg2 "profiles: $(get_profiles)"
msg2 "profile: ${profile}"
msg2 "is_profile: ${is_profile}"
if ${is_profile};then
msg "These packages will be built:"
local list=$(cat ${profiledir}/${profile}.set)
for item in ${list[@]}; do
msg2 "$item"
done
else
msg "This package will be built:"
msg2 "${profile}"
fi
}
2014-10-06 12:55:04 +02:00
run(){
2014-11-13 01:53:11 +01:00
eval_profile "${profile}"
2014-10-06 16:20:51 +02:00
if ${pretend}; then
display_settings
exit 1
else
2014-11-13 01:53:11 +01:00
if ${wipe_clean}; then
clean_up
fi
2014-10-06 16:20:51 +02:00
display_settings
2014-11-12 04:15:40 +01:00
chroot_init
2014-10-13 20:51:53 +02:00
prepare_dir "${pkgdir}"
2014-11-12 04:15:40 +01:00
chroot_build
2014-11-13 13:33:38 +01:00
ch_owner "${pkg_owner}" "$(dirname ${pkgdir})"
2014-10-14 21:57:44 +02:00
2014-11-13 01:20:33 +01:00
if ${sign}; then
2014-11-13 13:33:38 +01:00
sign_pkgs "${pkg_owner}"
2014-11-13 01:20:33 +01:00
fi
2014-10-06 16:20:51 +02:00
fi
2014-10-06 12:55:04 +02:00
}
2014-10-04 00:46:40 +02:00
export LC_MESSAGES=C
2014-10-14 21:57:44 +02:00
arch=$(uname -m)
2014-10-08 11:11:19 +02:00
pacman_conf_arch='default'
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_profile=false
2014-10-06 23:35:01 +02:00
sign=false
2014-10-04 00:46:40 +02:00
base_packages=('base-devel')
2014-10-05 21:27:37 +02:00
mkchroot_args=()
mkchrootpkg_args=()
2014-10-04 00:46:40 +02:00
makepkg_args=()
usage() {
echo "Usage: ${0##*/} [options] -- [makepkg_args]"
2014-10-06 01:22:45 +02:00
echo " -p <profile> Set profile or pkg [default: ${profile}]"
echo " -a <arch> Set arch [default: ${arch}]"
echo " -b <branch> Set branch [default: ${branch}]"
echo " -r <dir> Chroots directory [default: ${chroots}]"
2014-11-13 01:20:33 +01:00
echo ' -c Clean up and recreate chroot'
2014-11-13 01:53:11 +01:00
echo ' -w Wipe clean pkgbuild and pkg directory'
2014-10-06 01:22:45 +02:00
echo ' -n Run namcap check'
2014-10-06 23:35:01 +02:00
echo ' -s Sign packages'
2014-10-06 02:44:40 +02:00
echo ' -q Query settings and pretend build'
2014-10-04 00:46:40 +02:00
echo ' -h This help'
echo ''
echo ''
exit 1
}
2014-11-12 04:15:40 +01:00
orig_argv=("$@")
2014-11-13 01:53:11 +01:00
opts='p:a:b:r:cwnsqh'
2014-10-04 00:46:40 +02:00
while getopts "${opts}" arg; do
case "${arg}" in
p) profile="$OPTARG" ;;
a) arch="$OPTARG" ;;
b) branch="$OPTARG" ;;
r) chroots="$OPTARG" ;;
2014-11-12 04:15:40 +01:00
c) clean_first=true ;;
2014-11-13 01:53:11 +01:00
w) wipe_clean=true ;;
2014-10-13 13:38:22 +02:00
n) namcap=true; mkchrootpkg_args+=(-n) ;;
2014-10-06 23:35:01 +02:00
s) sign=true ;;
2014-10-14 21:57:44 +02:00
q) pretend=true ;;
2014-10-04 00:46:40 +02:00
h) usage ;;
esac
done
if [[ "$arch" == 'multilib' ]]; then
pacman_conf_arch='multilib'
2014-10-23 00:47:08 +02:00
chrootdir=${chroots}/${branch}/${arch}
2014-10-04 00:46:40 +02:00
arch='x86_64'
base_packages+=('multilib-devel')
2014-10-23 00:47:08 +02:00
else
chrootdir=${chroots}/${branch}/${arch}
2014-10-04 00:46:40 +02:00
fi
pacman_conf="@pkgdatadir@/pacman-${pacman_conf_arch}.conf"
makepkg_conf="@pkgdatadir@/makepkg-${arch}.conf"
2014-11-12 02:19:58 +01:00
pm_conf="@pkgdatadir@/pacman-mirrors-${branch}.conf"
2014-10-04 00:46:40 +02:00
2014-10-10 19:35:50 +02:00
if [[ -n ${pkgdir} ]];then
2014-10-13 20:51:53 +02:00
pkgdir="${pkgdir}/${branch}/${arch}"
2014-10-10 19:35:50 +02:00
else
2014-10-13 20:51:53 +02:00
pkgdir="/var/cache/manjaro-tools/pkg/${branch}/${arch}"
2014-10-10 19:35:50 +02:00
fi
2014-10-06 23:35:01 +02:00
2014-11-12 02:19:58 +01:00
mkchroot_args+=(-C ${pacman_conf} -M ${makepkg_conf} -S ${pm_conf})
2014-10-04 00:46:40 +02:00
2014-11-12 04:15:40 +01:00
mkchrootpkg_args+=(-r ${chrootdir})
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
run $@