-
Notifications
You must be signed in to change notification settings - Fork 0
/
create-source-packages
executable file
·186 lines (169 loc) · 5.59 KB
/
create-source-packages
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
#!/bin/sh -e
dist_tar_src ()
{
local dirname="$1"
local hash=
local path=
local rest=
if [ ! -f "../${dirname}.orig.tar.gz" -o "$overwrite" = "yes" ]; then
if [ -d .git ]; then
rm -f "../${dirname}.orig.tar" \
"../${dirname}.orig.tar-submodule" \
"../${dirname}.orig.tar-submodules"
git archive --format=tar "--prefix=${dirname}/" `git branch | grep '^\*' | sed -e 's%\* %%' | sed -e 's%(detached from \(.*\))%\1%' | sed -e 's%.* detached at \(.*\))%\1%'` \
>"../${dirname}.orig.tar"
git submodule status --recursive | while read hash path rest; do
( cd "$path" &&
git archive \
--format=tar "--prefix=${dirname}/$path/" \
`git branch | grep '^\*' | sed -e 's%\* %%' | sed -e 's%(detached from \(.*\))%\1%' | sed -e 's%.* detached at \(.*\))%\1%'` \
) \
>"../${dirname}.orig.tar-submodule"
if [ -f "../${dirname}.orig.tar-submodules" ]; then
tar Af "../${dirname}.orig.tar-submodules" "../${dirname}.orig.tar-submodule"
rm "../${dirname}.orig.tar-submodule"
else
mv "../${dirname}.orig.tar-submodule" "../${dirname}.orig.tar-submodules"
fi
done
if [ -f "../${dirname}.orig.tar-submodules" ]; then
tar Af "../${dirname}.orig.tar" "../${dirname}.orig.tar-submodules"
rm "../${dirname}.orig.tar-submodules"
tar --delete -f "../${dirname}.orig.tar" \
"${dirname}/.gitmodules"
fi
fi
if [ -f "../${dirname}.orig.tar" ]; then
if [ -f .gitignore ]; then
tar --delete -f "../${dirname}.orig.tar" \
"${dirname}/.gitignore"
fi
( cd .. && gzip -f "${dirname}.orig.tar" )
fi
fi
}
if [ -z "$KEY_ID" ]; then
KEY_ID="4F23A0260F19DAC5"
fi
# if [ "$1" = "tar" ]; then
# nosign="1"
# fi
if [ "$nosign" = "" ]; then
echo "Signing dummy file"
rm -f /tmp/dummy.$$*
touch /tmp/dummy.$$
gpg --default-key "$KEY_ID" --sign /tmp/dummy.$$
rm -f /tmp/dummy.$$*
fi
if [ -d .git ]; then
# rm debian/changelog debian/control
git checkout debian/changelog debian/control
fi
if [ -f Makefile.PL ]; then
rm -f Makefile
fi
rm -rf .pc
if [ "$1" = "all" ]; then
dists="debian ubuntu rpm"
elif [ -n "$1" ]; then
dists="$1"
else
id=`lsb_release -i | awk '{print $3}'`
if [ -z "$id" ]; then
echo "could not get distribution id, exit"
exit 1
fi
dists="$id"
fi
for id in $dists; do
case "$id" in
debian | Debian )
if [ -z "$releases" ]; then
releases="bookworm trixie sid"
fi
id=debian
;;
ubuntu | Ubuntu )
if [ -z "$releases" ]; then
releases="focal jammy noble"
fi
id=ubuntu
;;
rpm )
if [ -z "$releases" ]; then
releases="all"
fi
;;
# tar )
# releases="tar"
# ;;
* )
echo "Unknown distribution id $id"
exit 1
;;
esac
for what in $releases; do
case "$id" in
debian | ubuntu )
sed -i "s%~unstable%~$what%g" debian/changelog debian/control
sed -i "s%) unstable;%) $what;%g" debian/changelog
;;
esac
cur_vers=
name=
spec=
case "$id" in
debian | ubuntu )
if [ -r debian/source/format ]; then
if grep -q quilt debian/source/format; then
cur_vers=`head -n 1 debian/changelog | sed 's%.*(\([^)]*\)).*%\1%' | sed 's%-[0-9]*.*$%%'`
name=`head -n 1 debian/changelog | awk '{ print $1 }'`
fi
fi
;;
rpm )
if [ -d rpm ]; then
spec=`(cd rpm && ls -1 *.spec 2>/dev/null | head -n 1)`
if [ -f "rpm/$spec" ]; then
cur_vers=`grep ^Version: "rpm/$spec" | awk '{print $2}'`
name=`grep ^Name: "rpm/$spec" | awk '{print $2}'`
fi
fi
;;
esac
case "$id" in
debian )
if [ -n "$cur_vers" -a -n "$name" ]; then
dist_tar_src "${name}_${cur_vers}"
fi
dpkg-buildpackage -d -i -I -S "-k$KEY_ID"
;;
ubuntu )
if [ -n "$cur_vers" -a -n "$name" ]; then
dist_tar_src "${name}_${cur_vers}"
fi
dpkg-buildpackage -d -i -I -S "-k$KEY_ID"
;;
rpm )
if [ -n "$cur_vers" -a -n "$name" ]; then
dist_tar_src "${name}_${cur_vers}"
fi
;;
* )
exit 1
;;
esac
case "$id" in
debian | ubuntu )
if [ -d .git ]; then
rm debian/changelog debian/control
git checkout debian/changelog debian/control
else
sed -i "s%~$what%~unstable%g" debian/changelog debian/control
sed -i "s%) $what;%) unstable;%g" debian/changelog
fi
;;
esac
done
done
echo "ok"