#!/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 run(){ eval "case ${profile} in $profiles) is_profile=true if ${pretend}; then display_settings exit 1 else display_settings chroot_build_set fi ;; *) if ${pretend}; then display_settings exit 1 else display_settings chroot_build fi ;; esac" } export LC_MESSAGES=C shopt -s nullglob version=20141006 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 [[ -n ${repodir} ]];then repodir=${repodir} else repodir='/opt' 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 clean_rundir=false namcap=false nosystemd=false pretend=false is_profile=false repo=false base_packages=('base-devel') mkchroot_args=() mkchrootpkg_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 and pkg cache' echo ' -n Run namcap check' echo ' -w Wipe clean pkgbuild directory' echo ' -y Add packages to repo' echo ' -q Query settings and pretend build' echo ' -x Use classic chroot instead of systemd-nspawn' echo ' Useful for testing if systemd is running to bypass autodetection' echo ' -h This help' echo '' echo '' exit 1 } opts='p:a:b:r:cnxqwyh' 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 ;; q) pretend=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 mkchroot_args+=(-x) fi if ${namcap};then mkchrootpkg_args+=(-n) fi mkchroot_args+=(-C ${pacman_conf} -M ${makepkg_conf} -b ${branch}) mkchrootpkg_args+=(-b ${branch} -r ${chrootdir}) makepkg_args+=("${*:$OPTIND}") if ${clean_rundir}; then git_clean fi if [[ $EUID != 0 ]]; then die 'This script must be run as root.' else run $@ if ${repo}; then repo_create fi fi