-
Notifications
You must be signed in to change notification settings - Fork 19
/
make-ppa
executable file
·130 lines (114 loc) · 3.43 KB
/
make-ppa
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#!/usr/bin/env bash
#
# Packaging Scripts
# Copyright (C) 2002-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
COPR=0
DPUT=0
# NOTE: These are the supported distributions by Ubuntu Launchpad and Debian:
DPUT_DISTRIBUTIONS="precise trusty xenial bionic focal jammy lunar mantic noble unstable"
while [ $# -gt 0 ] ; do
if [ "$1" == "dput" ] ; then
DPUT=1
elif [ "$1" == "copr" ] ; then
COPR=1
elif [ "$1" == "all" ] ; then
DPUT=1
COPR=1
else
echo >&2 "Usage: $0 [dput] [copr] [all]"
exit 1
fi
shift
done
if [ ${DPUT} -eq 0 -a ${COPR} -eq 0 ] ; then
COPR=1
DPUT=1
fi
if [ ! -e debian/ ] ; then
DPUT=0
fi
if [ ! -e rpm/ ] ; then
COPR=0
fi
# ====== Build source packages ==============================================
./clean-deb
if [ ${DPUT} -ne 0 ] ; then
. ./packaging.conf
if [ "${NOT_TARGET_DISTRIBUTIONS}" == "" ] ; then
echo >&2 "ERROR: Define NOT_TARGET_DISTRIBUTIONS in packaging.conf!"
exit 1
fi
buildForDistribution=""
for dputDistribution in ${DPUT_DISTRIBUTIONS} ; do
notATarget=0
for notTargetDistribution in ${NOT_TARGET_DISTRIBUTIONS} ; do
if [ "${notTargetDistribution}" == "${dputDistribution}" ] ; then
notATarget=1
break
fi
done
if [ $notATarget -eq 0 ] ; then
buildForDistribution="${buildForDistribution} ${dputDistribution}"
fi
done
echo "Building for distributions:${buildForDistribution}"
./make-deb ${buildForDistribution}
fi
if [ ${COPR} -ne 0 ] ; then
if [ -e rpm -o -e ./make-srpm ] ; then
./make-srpm || exit 1
else
echo >&2 "ERROR: RPM files not found!"
exit 1
fi
fi
# ====== dput ===============================================================
if [ ${DPUT} -ne 0 ] ; then
changeFiles=`find . -mindepth 1 -maxdepth 1 -name "*.changes"`
for changeFile in ${changeFiles} ; do
if [[ ${changeFile} =~ -[0-9]_source.changes$ ]] ; then
dput mentors ${changeFile}
else
dput ppa ${changeFile}
fi
done
fi
# ====== COPR ===============================================================
if [ ${COPR} -ne 0 ] ; then
PACKAGE=`grep "^Name:" rpm/*.spec | head -n1 | sed -e "s/Name://g" -e "s/[ \t]*//g"`
SRPM=`find ${HOME}/rpmbuild/SRPMS -name "${PACKAGE}-*.src.rpm"`
if [ ! -e "${SRPM}" ] ; then
echo >&2 "ERROR: ${PACKAGE}-*.src.rpm not found!"
exit 1
fi
COPR_CLI=""
for directory in /usr/bin /usr/local/bin ~/.local/bin ; do
if [ -x "${directory}/copr-cli" ] ; then
COPR_CLI="${directory}/copr-cli"
break
fi
done
if [ "${COPR_CLI}" == "" ] ; then
echo >&2 "ERROR: copr-cli not found!"
exit 1
fi
echo "Using ${COPR_CLI}"
${COPR_CLI} build --nowait ppa ${SRPM}
fi