#!/bin/bash # # 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. version=@version@ if [[ -r @libdir@/messages.sh ]];then source @libdir@/messages.sh fi if [[ -r @libdir@/build-api.sh ]];then source @libdir@/build-api.sh fi run(){ eval_profile if ${pretend}; then if ${wipe_clean}; then git_clean "n" fi display_settings exit 1 else if ${wipe_clean}; then msg "Cleaning up ..." git_clean "q" clean_dir "${pkgdir}" fi display_settings chroot_init prepare_dir "${pkgdir}" chroot_build ch_owner "$(dirname ${pkgdir})" if ${sign}; then sign_pkgs fi fi } export LC_MESSAGES=C arch=$(uname -m) manjaro_tools_conf='@sysconfdir@/manjaro-tools.conf' if [[ -r ${manjaro_tools_conf} ]]; then source ${manjaro_tools_conf} fi if [[ -n ${profiledir} ]];then profiledir=${profiledir} else profiledir='@sysconfdir@/sets' fi if [[ -n ${profile} ]];then profile=${profile} else profile='default' fi if [[ -n ${branch} ]];then branch=${branch} else branch='stable' fi if [[ -n ${chroots} ]];then chroots=${chroots} else chroots='/srv/manjarobuild' fi pacman_conf_arch='default' clean_first=false wipe_clean=false namcap=false pretend=false is_profile=false sign=false base_packages=('base-devel') mkchroot_args=() mkchrootpkg_args=() makepkg_args=() usage() { echo "Usage: ${0##*/} [options] -- [makepkg_args]" echo " -p Set profile or pkg [default: ${profile}]" echo " -a Set arch [default: ${arch}]" echo " -b Set branch [default: ${branch}]" echo " -r Chroots directory [default: ${chroots}]" echo ' -c Clean chroot' echo ' -w Wipe clean pkgbuild and pkg directory' echo ' -n Run namcap check' echo ' -s Sign packages' echo ' -q Query settings and pretend build' echo ' -h This help' echo '' echo '' exit 1 } opts='p:a:b:r:cwnsqh' while getopts "${opts}" arg; do case "${arg}" in p) profile="$OPTARG" ;; a) arch="$OPTARG" ;; b) branch="$OPTARG" ;; r) chroots="$OPTARG" ;; c) clean_first=true ;; w) wipe_clean=true ;; n) namcap=true; mkchrootpkg_args+=(-n) ;; s) sign=true ;; q) pretend=true ;; 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} if [[ -n ${pkgdir} ]];then pkgdir="${pkgdir}/${branch}/${arch}" else pkgdir="/var/cache/manjaro-tools/pkg/${branch}/${arch}" fi mkchroot_args+=(-C ${pacman_conf} -M ${makepkg_conf} -b ${branch}) mkchrootpkg_args+=(-b ${branch} -r ${chrootdir}) makepkg_args+=("${*:$OPTIND}") if [[ $EUID != 0 ]]; then die 'This script must be run as root.' fi run $@