#!/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. if [[ -r @libdir@/functions.sh ]];then source @libdir@/functions.sh fi export LC_MESSAGES=C shopt -s nullglob version=20141005 arch=$(uname -m) pacman_conf_arch='default' manjaro_tools_conf='@sysconfdir@/manjaro-tools.conf' if [[ -f ${manjaro_tools_conf} ]]; then . ${manjaro_tools_conf} fi if [[ -n ${branch} ]];then branch=${branch} else branch='stable' fi if [[ -n ${profile} ]];then profile=${profile} else profile='default' fi if [[ -n ${chroots} ]];then chroots=${chroots} else chroots='/srv/manjarobuild' fi if [[ -n ${profiledir} ]];then profiledir=${profiledir} else profiledir='@sysconfdir@/sets' fi if [[ -r /etc/makepkg.conf ]]; then . /etc/makepkg.conf fi if [[ -n ${pkgdir} ]];then pkgdir=${pkgdir} elif [[ -n $PKGDEST ]];then pkgdir=$PKGDEST else pkgdir=/var/cache/manjaro-tools/pkg if ! [[ -d ${pkgdir} ]];then mkdir -p ${pkgdir} fi fi clean_first=false namcap=false sign=false verbose=false nosystemd=false pretend=false is_profile=false clean_rundir=false repo=false base_packages=('base-devel') mkmanjaroroot_args=() makechrootpkg_args=() makepkg_args=() profiles=$(get_profiles) 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 [default ${clean_first}]" echo " -n Run namcap check [default ${namcap}]" echo ' -s Sign packages' echo ' -v Verbose' echo " -x Use classic chroot instead of systemd-nspawn [default ${nosystemd}]" echo ' Useful for testing if systemd is running to bypass autodetection' echo " -q Pretend build [default ${pretend}]" echo ' -w Wipe clean pkgbuild directory' echo ' -y Add package to repo' echo ' -h This help' echo '' echo '' exit 1 } opts='p:a:b:r:cnsvxqwyh' 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;; s) sign=true ;; v) verbose=true ;; x) nosystemd=true ;; q) pretend=true; verbose=true ;; w) clean_rundir=true ;; y) repo=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 ${nosystemd};then mkmanjaroroot_args+=(-x) fi if ${namcap};then makechrootpkg_args+=(-n) fi # if ${repo};then # makechrootpkg_args+=(-d) # fi mkmanjaroroot_args+=(-C ${pacman_conf} -M ${makepkg_conf} -b ${branch}) makechrootpkg_args+=(-b ${branch} -r ${chrootdir}) makepkg_args+=("${*:$OPTIND}") if ${verbose};then msg "OPTARGS:" msg2 "arch: $arch" msg2 "branch: $branch" msg2 "chroots: $chroots" msg "PATHS:" msg2 "chrootdir: $chrootdir" msg2 "profiledir: $profiledir" msg2 "pacman_conf: ${pacman_conf}" msg2 "makepkg_conf: $makepkg_conf" msg "mkmanjaroroot:" msg2 "args: ${mkmanjaroroot_args[*]}" msg "makechrootpkg:" msg2 "args: ${makechrootpkg_args[*]}" msg "makepkg:" msg2 "args: ${makepkg_args[*]}" msg "FLAGS:" msg2 "clean_first: $clean_first" msg2 "namcap: ${namcap}" msg2 "sign: $sign" msg2 "nosystemd: $nosystemd" msg2 "clean_rundir: $clean_rundir" msg2 "repo: ${repo}" msg "PKG:" msg2 "base_packages: ${base_packages[*]}" msg2 "pkgdir: ${pkgdir}" msg2 "PKGDEST: ${PKGDEST}" fi if ${clean_rundir}; then if ${pretend};then msg "Files to be cleaned ${rundir} ..." git clean -dfxn else msg "Cleaning ${rundir} ..." if ${verbose};then git clean -dfx else git clean -dfxq fi fi fi if [[ $EUID != 0 ]]; then die 'This script must be run as root.' else if ${pretend};then run_pretend $@ else run $@ fi fi if [[ -r @libdir@/build-set-helper.sh ]];then source @libdir@/build-set-helper.sh fi