various: move conf-loading and i/o to functions
This commit is contained in:
parent
144ee3f113
commit
db1314ac55
@ -7,17 +7,14 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
abuild_ver=@VERSION@
|
abuild_ver=@VERSION@
|
||||||
sysconfdir=@sysconfdir@
|
datadir=@datadir@
|
||||||
|
|
||||||
abuild_conf=${ABUILD_CONF:-"$sysconfdir/abuild.conf"}
|
if ! [ -f "$datadir/functions.sh" ]; then
|
||||||
abuild_home=${ABUILD_USERDIR:-"$HOME/.abuild"}
|
echo "$datadir/functions.sh: not found" >&2
|
||||||
abuild_userconf=${ABUILD_USERCONF:-"$abuild_home/abuild.conf"}
|
exit 1
|
||||||
|
fi
|
||||||
|
. "$datadir/functions.sh"
|
||||||
|
|
||||||
# echo message unless quite mode
|
|
||||||
msg() {
|
|
||||||
[ -n "$quiet" ] && return 0
|
|
||||||
echo "$@"
|
|
||||||
}
|
|
||||||
|
|
||||||
# ask for privkey unless non-interactive mode
|
# ask for privkey unless non-interactive mode
|
||||||
# returns value in global $privkey
|
# returns value in global $privkey
|
||||||
@ -107,11 +104,6 @@ usage() {
|
|||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
# read config
|
|
||||||
[ -f "$abuild_conf" ] && . "$abuild_conf"
|
|
||||||
|
|
||||||
# read user config if exists
|
|
||||||
[ -f "$abuild_userconf" ] && . "$abuild_userconf"
|
|
||||||
|
|
||||||
while getopts "ahinq" opt; do
|
while getopts "ahinq" opt; do
|
||||||
case $opt in
|
case $opt in
|
||||||
|
@ -7,16 +7,13 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
abuild_ver=@VERSION@
|
abuild_ver=@VERSION@
|
||||||
sysconfdir=@sysconfdir@
|
datadir=@datadir@
|
||||||
|
|
||||||
abuild_conf=${ABUILD_CONF:-"$sysconfdir/abuild.conf"}
|
if ! [ -f "$datadir/functions.sh" ]; then
|
||||||
abuild_home=${ABUILD_USERDIR:-"$HOME/.abuild"}
|
echo "$datadir/functions.sh: not found" >&2
|
||||||
abuild_userconf=${ABUILD_USERCONF:-"$abuild_home/abuild.conf"}
|
|
||||||
|
|
||||||
die() {
|
|
||||||
echo "$@" >&2
|
|
||||||
exit 1
|
exit 1
|
||||||
}
|
fi
|
||||||
|
. "$datadir/functions.sh"
|
||||||
|
|
||||||
do_sign() {
|
do_sign() {
|
||||||
# we are actually only interested in the name, not the file itself
|
# we are actually only interested in the name, not the file itself
|
||||||
@ -52,12 +49,6 @@ usage() {
|
|||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
# read config
|
|
||||||
[ -f "$abuild_conf" ] && . "$abuild_conf"
|
|
||||||
|
|
||||||
# read user config if exists
|
|
||||||
[ -f "$abuild_userconf" ] && . "$abuild_userconf"
|
|
||||||
|
|
||||||
privkey="$PACKAGER_PRIVKEY"
|
privkey="$PACKAGER_PRIVKEY"
|
||||||
|
|
||||||
while getopts "hk:p:q" opt; do
|
while getopts "hk:p:q" opt; do
|
||||||
|
23
abump.in
23
abump.in
@ -6,12 +6,15 @@
|
|||||||
# Distributed under GPL-2
|
# Distributed under GPL-2
|
||||||
#
|
#
|
||||||
|
|
||||||
program=${0##*/}
|
abuild_ver=@VERSION@
|
||||||
|
datadir=@datadir@
|
||||||
|
|
||||||
die() {
|
if ! [ -f "$datadir/functions.sh" ]; then
|
||||||
echo "$@" >&2
|
echo "$datadir/functions.sh: not found" >&2
|
||||||
exit 1
|
exit 1
|
||||||
}
|
fi
|
||||||
|
. "$datadir/functions.sh"
|
||||||
|
|
||||||
|
|
||||||
# version bump a pkg
|
# version bump a pkg
|
||||||
|
|
||||||
@ -31,14 +34,14 @@ do_bump() {
|
|||||||
cve=" ($cvelist)"
|
cve=" ($cvelist)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
msg="$section/$pkgname: $upgrade to ${pkgver}${cve}"
|
message="$section/$pkgname: $upgrade to ${pkgver}${cve}"
|
||||||
if [ -n "$fixes" ]; then
|
if [ -n "$fixes" ]; then
|
||||||
msg="$msg
|
message="$message
|
||||||
|
|
||||||
fixes #${fixes#\#}
|
fixes #${fixes#\#}
|
||||||
"
|
"
|
||||||
fi
|
fi
|
||||||
echo "$msg"
|
echo "$message"
|
||||||
|
|
||||||
( . ./APKBUILD; type package | grep -q function ) || die "package() missing"
|
( . ./APKBUILD; type package | grep -q function ) || die "package() missing"
|
||||||
|
|
||||||
@ -49,12 +52,12 @@ fixes #${fixes#\#}
|
|||||||
abuild $abuild_opts checksum all || exit 1
|
abuild $abuild_opts checksum all || exit 1
|
||||||
|
|
||||||
git add APKBUILD
|
git add APKBUILD
|
||||||
git commit -m"$msg"
|
git commit -m"$message"
|
||||||
}
|
}
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
echo "$program - utility to bump pkgver in APKBUILDs"
|
echo "$prog - utility to bump pkgver in APKBUILDs"
|
||||||
echo "usage: $program [-hR] [-s CVE-1,CVE-2,...] [-f ISSUE]"
|
echo "usage: $prog [-hR] [-s CVE-1,CVE-2,...] [-f ISSUE]"
|
||||||
echo ""
|
echo ""
|
||||||
echo " -h show this help"
|
echo " -h show this help"
|
||||||
echo " -R run abuild with -R for recursive building"
|
echo " -R run abuild with -R for recursive building"
|
||||||
|
12
apkgrel.in
12
apkgrel.in
@ -6,7 +6,15 @@
|
|||||||
# Distributed under GPL-2
|
# Distributed under GPL-2
|
||||||
#
|
#
|
||||||
|
|
||||||
program=${0##*/}
|
abuild_ver=@VERSION@
|
||||||
|
datadir=@datadir@
|
||||||
|
|
||||||
|
if ! [ -f "$datadir/functions.sh" ]; then
|
||||||
|
echo "$datadir/functions.sh: not found" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
. "$datadir/functions.sh"
|
||||||
|
|
||||||
|
|
||||||
do_show() {
|
do_show() {
|
||||||
awk -F= '$1 == "pkgrel" { print $2 }' "$@"
|
awk -F= '$1 == "pkgrel" { print $2 }' "$@"
|
||||||
@ -49,7 +57,7 @@ do_nothing() {
|
|||||||
|
|
||||||
do_usage() {
|
do_usage() {
|
||||||
cat <<__EOF__
|
cat <<__EOF__
|
||||||
Usage: $program -a|-h|-s NUM|-t|-z [-f] FILE...
|
Usage: $prog -a|-h|-s NUM|-t|-z [-f] FILE...
|
||||||
Commands:
|
Commands:
|
||||||
-a Add 1 to current pkgrel
|
-a Add 1 to current pkgrel
|
||||||
-g Only do the change on files that have clean git status
|
-g Only do the change on files that have clean git status
|
||||||
|
24
checkapk.in
24
checkapk.in
@ -6,24 +6,22 @@
|
|||||||
# Distributed under GPL-2
|
# Distributed under GPL-2
|
||||||
#
|
#
|
||||||
|
|
||||||
die() {
|
abuild_ver=@VERSION@
|
||||||
echo "$@" >&2
|
datadir=@datadir@
|
||||||
|
|
||||||
|
if ! [ -f "$datadir/functions.sh" ]; then
|
||||||
|
echo "$datadir/functions.sh: not found" >&2
|
||||||
exit 1
|
exit 1
|
||||||
}
|
fi
|
||||||
|
. "$datadir/functions.sh"
|
||||||
|
|
||||||
msg() {
|
|
||||||
echo "$@"
|
|
||||||
}
|
|
||||||
|
|
||||||
have_abuild_conf=
|
|
||||||
|
|
||||||
for conf in /etc/abuild.conf ~/.abuild/abuild.conf; do
|
|
||||||
if [ -f "$conf" ]; then
|
|
||||||
. $conf && have_abuild_conf=yes
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
[ -z "$have_abuild_conf" ] && die "no abuild.conf found"
|
|
||||||
|
if ! [ -f "$abuild_conf" ] && ! [ -f "$abuild_userconf" ]; then
|
||||||
|
die "no abuild.conf found"
|
||||||
|
fi
|
||||||
|
|
||||||
if ! [ -f APKBUILD ]; then
|
if ! [ -f APKBUILD ]; then
|
||||||
die 'This must be run in the directory of a built package.'
|
die 'This must be run in the directory of a built package.'
|
||||||
|
34
functions.sh
34
functions.sh
@ -1,34 +0,0 @@
|
|||||||
|
|
||||||
#colors
|
|
||||||
if [ -n "$USE_COLORS" ]; then
|
|
||||||
NORMAL="\033[1;0m"
|
|
||||||
STRONG="\033[1;1m"
|
|
||||||
RED="\033[1;31m"
|
|
||||||
GREEN="\033[1;32m"
|
|
||||||
YELLOW="\033[1;33m"
|
|
||||||
BLUE="\033[1;34m"
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
# functions
|
|
||||||
msg() {
|
|
||||||
local prompt="$GREEN>>>${NORMAL}"
|
|
||||||
local fake="${FAKEROOTKEY:+${BLUE}*${NORMAL}}"
|
|
||||||
local name="${STRONG}${subpkgname:-$pkgname}${NORMAL}"
|
|
||||||
[ -z "$quiet" ] && printf "${prompt} ${name}${fake}: $@\n" >&2
|
|
||||||
}
|
|
||||||
|
|
||||||
warning() {
|
|
||||||
local prompt="${YELLOW}>>> WARNING:${NORMAL}"
|
|
||||||
local fake="${FAKEROOTKEY:+${BLUE}*${NORMAL}}"
|
|
||||||
local name="${STRONG}${subpkgname:-$pkgname}${NORMAL}"
|
|
||||||
printf "${prompt} ${name}${fake}: $@\n" >&2
|
|
||||||
}
|
|
||||||
|
|
||||||
error() {
|
|
||||||
local prompt="${RED}>>> ERROR:${NORMAL}"
|
|
||||||
local fake="${FAKEROOTKEY:+${BLUE}*${NORMAL}}"
|
|
||||||
local name="${STRONG}${subpkgname:-$pkgname}${NORMAL}"
|
|
||||||
printf "${prompt} ${name}${fake}: $@\n" >&2
|
|
||||||
}
|
|
||||||
|
|
76
functions.sh.in
Normal file
76
functions.sh.in
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
# /usr/share/abuild/functions.sh
|
||||||
|
|
||||||
|
sysconfdir=@sysconfdir@
|
||||||
|
prog=${0##*/}
|
||||||
|
|
||||||
|
|
||||||
|
abuild_conf=${ABUILD_CONF:-"$sysconfdir/abuild.conf"}
|
||||||
|
abuild_home=${ABUILD_USERDIR:-"$HOME/.abuild"}
|
||||||
|
abuild_userconf=${ABUILD_USERCONF:-"$abuild_home/abuild.conf"}
|
||||||
|
|
||||||
|
# read config
|
||||||
|
if [ -f "$abuild_conf" ]; then
|
||||||
|
. "$abuild_conf" || abuild_conf=
|
||||||
|
fi
|
||||||
|
|
||||||
|
# read user config if exists
|
||||||
|
if [ -f "$abuild_userconf" ]; then
|
||||||
|
. "$abuild_userconf" || abuild_userconf=
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# output functions
|
||||||
|
case $prog in
|
||||||
|
abuild)
|
||||||
|
if [ -n "$USE_COLORS" ]; then
|
||||||
|
NORMAL="\033[1;0m"
|
||||||
|
STRONG="\033[1;1m"
|
||||||
|
RED="\033[1;31m"
|
||||||
|
GREEN="\033[1;32m"
|
||||||
|
YELLOW="\033[1;33m"
|
||||||
|
BLUE="\033[1;34m"
|
||||||
|
fi
|
||||||
|
|
||||||
|
msg() {
|
||||||
|
local prompt="$GREEN>>>${NORMAL}"
|
||||||
|
local fake="${FAKEROOTKEY:+${BLUE}*${NORMAL}}"
|
||||||
|
local name="${STRONG}${subpkgname:-$pkgname}${NORMAL}"
|
||||||
|
[ -z "$quiet" ] && printf "${prompt} ${name}${fake}: $@\n" >&2
|
||||||
|
}
|
||||||
|
|
||||||
|
warning() {
|
||||||
|
local prompt="${YELLOW}>>> WARNING:${NORMAL}"
|
||||||
|
local fake="${FAKEROOTKEY:+${BLUE}*${NORMAL}}"
|
||||||
|
local name="${STRONG}${subpkgname:-$pkgname}${NORMAL}"
|
||||||
|
printf "${prompt} ${name}${fake}: $@\n" >&2
|
||||||
|
}
|
||||||
|
|
||||||
|
error() {
|
||||||
|
local prompt="${RED}>>> ERROR:${NORMAL}"
|
||||||
|
local fake="${FAKEROOTKEY:+${BLUE}*${NORMAL}}"
|
||||||
|
local name="${STRONG}${subpkgname:-$pkgname}${NORMAL}"
|
||||||
|
printf "${prompt} ${name}${fake}: $@\n" >&2
|
||||||
|
}
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
msg() {
|
||||||
|
# Here we write to stdout, but abuild's fancier messages write to stderr
|
||||||
|
[ -z "$quiet" ] && echo "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
error() {
|
||||||
|
echo "$@" >&2
|
||||||
|
}
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# caller may override
|
||||||
|
cleanup() {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
die() {
|
||||||
|
error "$@"
|
||||||
|
cleanup
|
||||||
|
exit 1
|
||||||
|
}
|
@ -6,22 +6,15 @@
|
|||||||
# Distributed under GPL-2
|
# Distributed under GPL-2
|
||||||
#
|
#
|
||||||
|
|
||||||
version=@VERSION@
|
abuild_ver=@VERSION@
|
||||||
sysconfdir=@sysconfdir@
|
|
||||||
datadir=@datadir@
|
datadir=@datadir@
|
||||||
|
|
||||||
prog=${0##*/}
|
if ! [ -f "$datadir/functions.sh" ]; then
|
||||||
|
echo "$datadir/functions.sh: not found" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
. "$datadir/functions.sh"
|
||||||
|
|
||||||
# Source $PACKAGER
|
|
||||||
for i in $sysconfdir/abuild.conf $HOME/.abuild/abuild.conf; do
|
|
||||||
if [ -f "$i" ]; then
|
|
||||||
. $i
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
error() {
|
|
||||||
echo "$@" >&2
|
|
||||||
}
|
|
||||||
|
|
||||||
is_url() {
|
is_url() {
|
||||||
case "$1" in
|
case "$1" in
|
||||||
@ -260,7 +253,7 @@ __EOF__
|
|||||||
}
|
}
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
echo "$prog $version"
|
echo "$prog $abuild_ver"
|
||||||
echo "usage: $prog [-cfh] [-d DESC] [-l LICENSE] [-n NAME] [-u URL] PKGNAME[-PKGVER]|SRCURL"
|
echo "usage: $prog [-cfh] [-d DESC] [-l LICENSE] [-n NAME] [-u URL] PKGNAME[-PKGVER]|SRCURL"
|
||||||
echo "Options:"
|
echo "Options:"
|
||||||
echo " -a Create autotools (use ./configure ...)"
|
echo " -a Create autotools (use ./configure ...)"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user