-
Notifications
You must be signed in to change notification settings - Fork 19
/
make-upstream-package
executable file
·103 lines (91 loc) · 3.44 KB
/
make-upstream-package
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#!/usr/bin/env bash
#
# Packaging Scripts
# Copyright (C) 2017-2024 by Thomas Dreibholz
#
# 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 <http://www.gnu.org/licenses/>.
#
# Contact: [email protected]
# Bash options:
set -e
# ---------------------------------------------------------------------------
# USAGE:
# ./make-upstream-package package_name version [-skip-signing]
# ---------------------------------------------------------------------------
# ====== Check arguments ====================================================
if [ $# -lt 3 ] ; then
echo >&2 "Usage: $0 package_name version make_dist [-skip-signing]"
exit 1
fi
PACKAGE="$1"
UPSTREAM_VERSION="$2"
MAKE_DIST="$3"
SKIP_PACKAGE_SIGNING=0
shift ; shift ; shift
while [ $# -gt 0 ] ; do
if [ "$1" == "-skip-signing" ] ; then
SKIP_PACKAGE_SIGNING=1
else
echo >&2 "ERROR: Bad argument $0!"
exit 1
fi
shift
done
# ====== Create upstream source package =====================================
echo -e ""
echo -e "\x1b[34m`date +%FT%H:%M:%S`: ====== Creating upstream package ======================================\x1b[0m"
echo -e ""
for UPSTREAM_PACKAGE_TYPE in xz bz2 gz ; do
printf "Looking for ${PACKAGE}-*.tar.${UPSTREAM_PACKAGE_TYPE} ... "
UPSTREAM_PACKAGE="`find . -maxdepth 1 -name "${PACKAGE}-*.tar.${UPSTREAM_PACKAGE_TYPE}" -printf '%f'`"
if [ -e "${UPSTREAM_PACKAGE}" ] ; then
echo "found!"
break
else
echo "not found"
fi
done
if [ ! -e "${UPSTREAM_PACKAGE}" ]; then
rm -f ${PACKAGE}-*.gz ${PACKAGE}"_"*.gz ${PACKAGE}-*.bz2 ${PACKAGE}"_"*.bz2 ${PACKAGE}-*.xz ${PACKAGE}"_"*.xz
echo -e "\x1b[34m------ Running MAKE_DIST ... ------\x1b[0m"
echo "\$ $MAKE_DIST"
eval "$MAKE_DIST"
echo -e "\x1b[34m------ Looking for upstream package ... ------\x1b[0m"
for UPSTREAM_PACKAGE_TYPE in xz bz2 gz ; do
UPSTREAM_PACKAGE="`find . -maxdepth 1 -name "${PACKAGE}-*.tar.${UPSTREAM_PACKAGE_TYPE}" -printf '%f'`"
if [ -e "${UPSTREAM_PACKAGE}" ] ; then
break
fi
done
if [ ! -e "${UPSTREAM_PACKAGE}" ] ; then
echo -e "\x1b[34mERROR: No upstream package (${PACKAGE}-*.tar.*) found!\x1b[0m"
exit 1
fi
rm -f "${UPSTREAM_PACKAGE}.asc" # Ensure that old signature file is removed!
echo -e ""
fi
echo -e "\x1b[34m==> Upstream package is ${UPSTREAM_PACKAGE} (type is ${UPSTREAM_PACKAGE_TYPE})\x1b[0m"
echo -e ""
# ====== Sign upstream source package =======================================
if [ ! -e "${UPSTREAM_PACKAGE}.asc" ] ; then
if [ ! ${SKIP_PACKAGE_SIGNING} == "1" -a ! "${OVERRIDE_SKIP_PACKAGE_SIGNING}" == "1" ] ; then
echo -e ""
echo -e "\x1b[34m`date +%FT%H:%M:%S`: ====== Sign upstream package ==========================================\x1b[0m"
echo -e ""
echo -e "\x1b[34mSigning upstream package ${UPSTREAM_PACKAGE} ...\x1b[0m"
gpg -sab "${UPSTREAM_PACKAGE}"
else
rm -f "${UPSTREAM_PACKAGE}.asc"
fi
fi