#!/bin/sh # Copyright (C) 2015 Daniel Baumann # # 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, either version 3 of the License, or # (at your option) any later version. # # 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. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . set -e case "$(basename ${0})" in p*) MODE="progress-linux" ;; b*) MODE="bfh" ;; esac PROGRAM="${0}" case "$(dpkg --print-architecture)" in # arm64) # CPUS="1" # export DEB_BUILD_OPTIONS=parallel=${CPUS} # ;; *) CPUS="$(nproc)" export DEB_BUILD_OPTIONS=parallel=${CPUS} ;; esac Parameters() { LONG_OPTIONS="auto,build:,distribution:,interactive,nocheck,only-missing-builds,package:,tag:,upload," OPTIONS="a,b:,d:,i,n,o,p:,t:,u," PARAMETERS="$(getopt --longoptions ${LONG_OPTIONS} --name=${PROGRAM} --options ${OPTIONS} --shell sh -- ${@})" if [ "${?}" != "0" ] then echo "${PROGRAM}: getopt exit" >&2 exit 1 fi eval set -- "${PARAMETERS}" while true do case "${1}" in -a|--auto) AUTO="true" shift 1 ;; -b|--build) BUILD="${2}" shift 2 ;; -d|--distribution) DISTRIBUTION="${2}" shift 2 ;; -i|--interactive) INTERACTIVE="true" shift 1 ;; -n|--nocheck) NOCHECK="true" shift 1 ;; -p|--package) PACKAGE="$(echo ${2} | sed -e 's|/$||g')" shift 2 ;; -o|--only-missing-builds) ONLY_MISSING_BUILDS="true" shift 1 ;; -t|--tag) TAG="${2}" shift 2 ;; -u|--upload) UPLOAD="true" shift ;; --) shift break ;; *) echo "${PROGRAM}: getopt error" >&2 exit 1 ;; esac done } Parameters "${@}" if [ -z "${DISTRIBUTION}" ] || [ -z "${PACKAGE}" ] then echo "Usage: ${PROGRAM} -a|--auto [-b|--build BUILD] -d|--distribution DISTRIBUTION -n|--nocheck -p|--package PACKAGE -o|--only-missing-builds -t|--tag ALL|TAG[,TAG,...] -u|--upload" >&2 exit 1 fi INTERACTIVE="${INTERACTIVE:=false}" if [ -e "${PACKAGE}" ] then echo "${PACKAGE}: directory already exists" exit 1 fi TAGS="$(echo ${TAG} | sed -e 's|,| |g')" case "${TAGS}" in ALL) TAGS="$(wget -q https://git.progress-linux.org/packages/${DISTRIBUTION}/${PACKAGE}/refs/ -O - | grep "> debian/rules fi done ;; esac case "${AUTO}" in true) case "${DISTRIBUTION}" in engywuck-backports) if grep -qs 'debhelper (>= 13' debian/control || \ grep -qs 'debhelper-compat (= 13' debian/control then sudo apt install -t engywuck-backports -y debhelper fi ;; graograman-backports) if grep -qs 'debhelper (>= 13.14' debian/control || \ grep -qs dh-sequence-movetousr debian/control then sudo apt install -t graograman-backports -y debhelper fi if grep -qs 'dpkg-dev (>= 1.22' debian/control then sudo apt install -t graograman-backports -y dpkg-dev fi ;; esac sudo apt build-dep -y . ;; esac case "${INTERACTIVE}" in true) echo "${PROGRAM}: WAITING... " read waiting ;; esac case "${BUILD}" in binary-any) dpkg-buildpackage -sa -us -uc ;; binary-arch) dpkg-buildpackage -B -us -uc ;; binary-indep) dpkg-buildpackage -A -us -uc ;; esac cd "${OLDPWD}" rm -rf "${SOURCE}" # upload case "${UPLOAD}" in true) FILES="$(sed -e '1,/^Files:$/ d' ${TARGET}_${SOURCE_VERSION}_*.changes | sed -e '/^[0-1a-zA-Z]/,$d' | awk '{ print $5 }')" rsync -aP ${FILES} ${TARGET}_${SOURCE_VERSION}_*.changes apt.progress-linux.org::upload rm -f ${FILES} ${TARGET}_${SOURCE_VERSION}_*.changes ;; esac ;; esac done done