nix-tools/bin/build-set.in

177 lines
3.7 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 00:12:14 +02:00
if [[ -r @libdir@/messages.sh ]];then
source @libdir@/messages.sh
fi
if [[ -r @libdir@/build-api.sh ]];then
source @libdir@/build-api.sh
2014-10-04 15:41:22 +02:00
fi
2014-10-04 00:46:40 +02:00
2014-10-06 12:55:04 +02:00
run(){
2014-10-08 11:11:19 +02:00
eval_profile
2014-10-06 16:20:51 +02:00
if ${pretend}; then
2014-10-06 18:41:49 +02:00
if ${clean_rundir}; then
git_clean "n"
fi
2014-10-06 16:20:51 +02:00
display_settings
exit 1
else
2014-10-06 18:41:49 +02:00
if ${clean_rundir}; then
git_clean "q"
fi
2014-10-06 16:20:51 +02:00
display_settings
2014-10-06 17:10:00 +02:00
chroot_init
2014-10-06 16:20:51 +02:00
chroot_build
2014-10-06 17:10:00 +02:00
if ${repo}; then
repo_create
fi
2014-10-06 23:35:01 +02:00
if ${sign}; then
sign_pkgs
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-04 23:33:40 +02:00
manjaro_tools_conf='@sysconfdir@/manjaro-tools.conf'
2014-10-04 00:46:40 +02:00
2014-10-04 23:33:40 +02:00
if [[ -f ${manjaro_tools_conf} ]]; then
2014-10-08 11:11:19 +02:00
source ${manjaro_tools_conf}
2014-10-04 00:46:40 +02:00
fi
2014-10-08 11:11:19 +02:00
if [[ -n ${profiledir} ]];then
profiledir=${profiledir}
2014-10-04 00:46:40 +02:00
else
2014-10-08 11:11:19 +02:00
profiledir='@sysconfdir@/sets'
2014-10-04 00:46:40 +02:00
fi
if [[ -n ${profile} ]];then
profile=${profile}
else
profile='default'
fi
2014-10-08 11:11:19 +02:00
arch=$(uname -m)
if [[ -n ${branch} ]];then
branch=${branch}
2014-10-04 00:46:40 +02:00
else
2014-10-08 11:11:19 +02:00
branch='stable'
2014-10-04 00:46:40 +02:00
fi
2014-10-08 11:11:19 +02:00
if [[ -n ${chroots} ]];then
chroots=${chroots}
2014-10-04 00:46:40 +02:00
else
2014-10-08 11:11:19 +02:00
chroots='/srv/manjarobuild'
2014-10-04 00:46:40 +02:00
fi
2014-10-05 21:27:37 +02:00
if [[ -n ${repodir} ]];then
repodir=${repodir}
else
2014-10-06 23:35:01 +02:00
repodir='/opt/build-repo'
2014-10-05 21:27:37 +02:00
fi
2014-10-05 00:17:23 +02:00
if [[ -r /etc/makepkg.conf ]]; then
2014-10-08 11:11:19 +02:00
source /etc/makepkg.conf
2014-10-04 00:46:40 +02:00
fi
2014-10-08 11:11:19 +02:00
pacman_conf_arch='default'
2014-10-04 00:46:40 +02:00
clean_first=false
2014-10-06 02:44:40 +02:00
clean_rundir=false
2014-10-04 00:46:40 +02:00
namcap=false
nosystemd=false
pretend=false
is_profile=false
repo=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}]"
echo ' -c Clean chroot and pkg cache'
echo ' -n Run namcap check'
echo ' -w Wipe clean pkgbuild directory'
echo ' -y Add packages to repo'
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-06 01:22:45 +02:00
echo ' -x Use classic chroot instead of systemd-nspawn'
2014-10-04 00:46:40 +02:00
echo ' Useful for testing if systemd is running to bypass autodetection'
echo ' -h This help'
echo ''
echo ''
exit 1
}
2014-10-06 23:35:01 +02:00
opts='p:a:b:r:cnwysqxh'
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" ;;
c) clean_first=true ;;
n) namcap=true;;
x) nosystemd=true ;;
2014-10-06 02:44:40 +02:00
q) pretend=true ;;
2014-10-04 00:46:40 +02:00
w) clean_rundir=true ;;
y) repo=true ;;
2014-10-06 23:35:01 +02:00
s) sign=true ;;
2014-10-04 00:46:40 +02:00
h) usage ;;
esac
done
if [[ "$arch" == 'multilib' ]]; then
pacman_conf_arch='multilib'
arch='x86_64'
branch="${branch}-multilib"
base_packages+=('multilib-devel')
fi
pacman_conf="@pkgdatadir@/pacman-${pacman_conf_arch}.conf"
makepkg_conf="@pkgdatadir@/makepkg-${arch}.conf"
chrootdir=${chroots}/${branch}-${arch}
2014-10-06 23:35:01 +02:00
set_pkgdir
2014-10-04 00:46:40 +02:00
if ${nosystemd};then
2014-10-05 21:27:37 +02:00
mkchroot_args+=(-x)
2014-10-04 00:46:40 +02:00
fi
if ${namcap};then
2014-10-05 21:27:37 +02:00
mkchrootpkg_args+=(-n)
2014-10-04 00:46:40 +02:00
fi
2014-10-05 21:27:37 +02:00
mkchroot_args+=(-C ${pacman_conf} -M ${makepkg_conf} -b ${branch})
2014-10-04 00:46:40 +02:00
2014-10-05 21:27:37 +02:00
mkchrootpkg_args+=(-b ${branch} -r ${chrootdir})
2014-10-04 00:46:40 +02:00
makepkg_args+=("${*:$OPTIND}")
if [[ $EUID != 0 ]]; then
die 'This script must be run as root.'
2014-10-06 00:02:45 +02:00
fi
2014-10-07 10:34:58 +02:00
run $@