-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck.sh
More file actions
executable file
·336 lines (314 loc) · 13.1 KB
/
check.sh
File metadata and controls
executable file
·336 lines (314 loc) · 13.1 KB
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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
#!/usr/bin/env bash
# email=debian-desktop@tmiland.com
GH_TOKEN=$(cat "${HOME}"/.credentials/.ghtoken)
GH_USER=tmiland
# Detect absolute and full path as well as filename of this script
cd "$(dirname "$0")" || exit
CURRDIR=$(pwd)
cd - > /dev/null || exit
download_release() {
cd "${CURRDIR}" || exit
URL=$(curl --user "$GH_USER:$GH_TOKEN" -sSL https://api.github.com/repos/$REPO/releases 2>/dev/null \
| grep -i -m 1 "browser_download_url.*$APP_NAME.*deb" \
| cut -d'"' -f4)
DEB_FILE="${URL##*/}"
wget --quiet --continue --show-progress --progress=bar:force:noscroll "${URL}" -O "${DEB_FILE}"
if [[ $(stat -c%s "$DEB_FILE" 2>/dev/null) -gt 25000000 ]]
then
# https://www.baeldung.com/linux/package-deb-change-repack
mkdir ./debtmp
dpkg-deb -R "$DEB_FILE" ./debtmp
cp -rp ./postinst ./debtmp/DEBIAN/postinst
sed -i "s|REPO=|REPO=$REPO|g" ./debtmp/DEBIAN/postinst
sed -i "s|APP_NAME=|APP_NAME=$APP_NAME|g" ./debtmp/DEBIAN/postinst
cd ./debtmp/
find . -type f -not -path "./DEBIAN/*" -exec md5sum {} + | sort -k 2 | sed 's/\.\/\(.*\)/\1/' > DEBIAN/md5sums
# Remove everything but leave DEBIAN folder
find . -mindepth 1 -maxdepth 1 -type d -not -name DEBIAN \
-exec rm -rf '{}' \;
cd .. || exit 0
dpkg-deb -b --root-owner-group ./debtmp "$DEB_FILE"
rm -rf ./debtmp
fi
mv "$DEB_FILE" ./debian/
}
publish_release() {
. ./update.sh
git add -A
git commit -m "Update $APP_NAME version to $NEW_VERSION"
git push -u origin master
#git tag -a "$NEW_VERSION" -m "Update $APP_NAME version from $CUR_VERSION to $NEW_VERSION"
git push --tags origin master
}
get_release() {
for APP in 01-main/packages/*; do
if [ -f "$APP" ]; then
# shellcheck source="$APP_NAME"
. "$APP"
if [ -z $NEW_VERSION ]; then
NEW_VERSION="$(curl --user "$GH_USER:$GH_TOKEN" -sSL https://api.github.com/repos/$REPO/releases | grep '"tag_name":' | sed -n 's/[^0-9.]*\([0-9.]*\).*/\1/p' | head -n 1)"
fi
APP_NAME=$(echo "$(basename "$APP")")
cd "${CURRDIR}" || exit
CUR_VERSION="$(ls ./debian | grep -i "$APP_NAME.*deb" | grep -Eo '[0-9]{1,}\.[0-9]{1,}\.[0-9]{1,}' | sort -rnk3 | head -n 1)"
echo "Current $APP_NAME Version: $CUR_VERSION => New Version: $NEW_VERSION"
if [[ "$CUR_VERSION" < "$NEW_VERSION" ]]; then
echo "Downloading new $APP_NAME version $NEW_VERSION"
if [ "$APP_NAME" == "timeshift" ]; then
curl --user "$GH_USER:$GH_TOKEN" -sSL https://api.github.com/repos/"$REPO"/releases |
jq -r '.[] | select(.tag_name == "master.lmde6") | .assets[] | .browser_download_url' |
head -n 1 |
wget -qi -
tar -xzvf packages.tar.gz 2>/dev/null
DEB_FILE="$(find ./packages -type f -name ""$APP_NAME"_"$NEW_VERSION"_amd64.deb" 2>/dev/null)"
mv "$DEB_FILE" ./debian/
rm -rf ./packages
rm ./packages.tar.gz
# elif [ "$APP_NAME" == "snapclient-with-pulse" ]
# then
# curl --user "$GH_USER:$GH_TOKEN" -sSL https://api.github.com/repos/$REPO/releases \
# | grep "browser_download_url.*snapclient.*_with-pulse.deb" \
# | cut -d : -f 2,3 \
# | tr -d \" \
# | head -n 1 \
# | wget -qi -
# DEB_FILE="$(find . -name "snapclient_"$NEW_VERSION"-1_amd64_*_with-pulse.deb" 2>/dev/null)"
# # https://www.baeldung.com/linux/package-deb-change-repack
# # Change package name to "snapclient-with-pulse"
# mkdir ./debtmp
# dpkg-deb -R "$DEB_FILE" ./debtmp
# sed -i "s|Package: snapclient|Package: snapclient-with-pulse|g" ./debtmp/DEBIAN/control
# cd ./debtmp/
# find . -type f -not -path "./DEBIAN/*" -exec md5sum {} + | sort -k 2 | sed 's/\.\/\(.*\)/\1/' > DEBIAN/md5sums
# cd .. || exit 0
# dpkg-deb -b ./debtmp "$DEB_FILE"
# rm -rf ./debtmp
# ###############
# mv "$DEB_FILE" ./debian/
else
download_release
fi
publish_release
else
echo "Latest $APP_NAME version already downloaded..."
fi
fi
sleep 0.5
done
}
# GitHubDesktop() {
# github_dektop_repo=shiftkey/desktop
# cd "${CURRDIR}" || exit
# github_desktop_CUR_VERSION="$(find ./debian/ -name "GitHubDesktop-linux-*.deb" | sed 's/.*-\([0-9\.][0-9\.]*\).*/\1/' | sort -rnk3 | head -n 1)"
# github_desktop_NEW_VERSION="$(curl -sSL https://api.github.com/repos/$github_dektop_repo/releases | grep '"tag_name":' | sed -n 's/[^0-9.]*\([0-9.]*\).*/\1/p' | head -n 1)"
# echo "Current GitHub Desktop Version: $github_desktop_CUR_VERSION => New Version: $github_desktop_NEW_VERSION"
#
# if [[ "$github_desktop_CUR_VERSION" < "$github_desktop_NEW_VERSION" ]]; then
#
# echo "Downloading new github-desktop version $github_desktop_NEW_VERSION" | mail -s "Downloading new github-desktop version $github_desktop_NEW_VERSION" $email
# cd "${CURRDIR}" || exit
# curl -sSL https://api.github.com/repos/$github_dektop_repo/releases \
# | grep "browser_download_url.*deb" \
# | cut -d : -f 2,3 \
# | tr -d \" \
# | head -n 1 \
# | wget -qi -
#
# DEB_FILE="$(find . -name "GitHubDesktop-linux*-$github_desktop_NEW_VERSION-linux*.deb" 2>/dev/null)"
# mv "$DEB_FILE" ./debian/
# . ./update.sh
# git add -A
# git commit -m "Update github-desktop version to $github_desktop_NEW_VERSION"
# git push -u origin master
# #git tag -a "$github_desktop_NEW_VERSION" -m "Update github-desktop version from $github_desktop_CUR_VERSION to $github_desktop_NEW_VERSION"
# git push --tags origin master
# exit
#
# else
# echo "Latest GitHub Desktop version already installed"
# fi
# }
gnuzilla() {
APP_NAME=Icecat
ICECAT_REPO_DIR="../GNU-IceCat"
cd "${CURRDIR}" || exit
ICECAT_CUR_VERSION=$(echo $(grep -Poh "(?<=Version: )([0-9]|\.)*(?=\s|$)" "${ICECAT_REPO_DIR}"/amd64/DEBIAN/*))
ICECAT_NEW_VERSION=$(curl -s https://icecatbrowser.org/all_downloads.html |
grep -Po 'b>\K.*(?=</b)' |
head -n 1 |
sed -n 's/[^0-9.]*\([0-9.]*\).*/\1/p' |
# Stript trailing .
sed 's/.$//')
echo "Current $APP_NAME Version: $ICECAT_CUR_VERSION => New Version: $ICECAT_NEW_VERSION"
if dpkg --compare-versions "$ICECAT_CUR_VERSION" lt "$ICECAT_NEW_VERSION"
then
echo "Downloading new $APP_NAME version $ICECAT_NEW_VERSION"
cd "${ICECAT_REPO_DIR}" || exit
./package.sh
cd - || exit 1
DEB_FILE="$(find "${ICECAT_REPO_DIR}" -name "icecat_${ICECAT_NEW_VERSION}_amd64.deb" 2>/dev/null)"
mv "$DEB_FILE" ./debian/
publish_release
exit
else
echo "Latest $APP_NAME version already installed"
fi
}
# snapweb() {
# APP_NAME=snapweb
# REPO=badaix/$APP_NAME
# cd "${CURRDIR}" || exit
# CUR_VERSION="$(find . -name ""$APP_NAME"_*.deb" | sed 's/.*_\([0-9\.][0-9\.]*\).*/\1/' | sort -rnk3 | head -n 1)"
# NEW_VERSION="$(curl --user "$GH_USER:$GH_TOKEN" -sSL https://api.github.com/repos/$REPO/releases | grep '"tag_name":' | sed -n 's/[^0-9.]*\([0-9.]*\).*/\1/p' | head -n 1)"
# echo "Current $APP_NAME Version: $CUR_VERSION => New Version: $NEW_VERSION"
# if [[ "$CUR_VERSION" < "$NEW_VERSION" ]]; then
# echo "Downloading new $APP_NAME version $NEW_VERSION"
# cd "${CURRDIR}" || exit
# curl --user "$GH_USER:$GH_TOKEN" -sSL https://api.github.com/repos/$REPO/releases \
# | grep "browser_download_url.*$APP_NAME.*deb" \
# | cut -d : -f 2,3 \
# | tr -d \" \
# | head -n 1 \
# | wget -qi -
# DEB_FILE="$(ls -l | grep -oP "$APP_NAME"_"$NEW_VERSION.*\.deb" 2>/dev/null)"
# mv "$DEB_FILE" ./debian/
# publish_release
# exit
# else
# echo "Latest $APP_NAME version already downloaded..."
# fi
# }
# snapserver() {
# cd "${CURRDIR}" || exit
# echo "Current $APP_NAME Version: $CUR_VERSION => New Version: $NEW_VERSION"
# if [[ "$CUR_VERSION" < "$NEW_VERSION" ]]; then
# echo "Downloading new $APP_NAME version $NEW_VERSION"
# cd "${CURRDIR}" || exit
# curl --user "$GH_USER:$GH_TOKEN" -sSL https://api.github.com/repos/$REPO/releases \
# | grep "browser_download_url.*$APP_NAME.*deb" \
# | cut -d : -f 2,3 \
# | tr -d \" \
# | head -n 1 \
# | wget -qi -
# DEB_FILE="$(find . -name "\"$APP_NAME\"_$NEW_VERSION-1_amd64_$(lsb_release -sc).deb" 2>/dev/null)"
# mv "$DEB_FILE" ./debian/
# publish_release
# exit
# else
# echo "Latest $APP_NAME version already downloaded..."
# fi
# }
# snapclient() {
# APP_NAME=snapclient
# REPO=badaix/snapcast
# cd "${CURRDIR}" || exit
# CUR_VERSION="$(find . -name ""$APP_NAME"_*.deb" | sed 's/.*_\([0-9\.][0-9\.]*\).*/\1/' | sort -rnk3 | head -n 1)"
# NEW_VERSION="$(curl --user "$GH_USER:$GH_TOKEN" -sSL https://api.github.com/repos/$REPO/releases | grep '"tag_name":' | sed -n 's/[^0-9.]*\([0-9.]*\).*/\1/p' | head -n 1)"
# echo "Current $APP_NAME Version: $CUR_VERSION => New Version: $NEW_VERSION"
# if [[ "$CUR_VERSION" < "$NEW_VERSION" ]]; then
# echo "Downloading new $APP_NAME version $NEW_VERSION"
# cd "${CURRDIR}" || exit
# curl --user "$GH_USER:$GH_TOKEN" -sSL https://api.github.com/repos/$REPO/releases \
# | grep "browser_download_url.*$APP_NAME.*deb" \
# | cut -d : -f 2,3 \
# | tr -d \" \
# | head -n 1 \
# | wget -qi -
# DEB_FILE="$(find . -name "\"$APP_NAME\"_$NEW_VERSION-1_amd64_$(lsb_release -sc).deb" 2>/dev/null)"
# mv "$DEB_FILE" ./debian/
# publish_release
# exit
# else
# echo "Latest $APP_NAME version already downloaded..."
# fi
# }
# snapclient_with_pulse() {
# APP_NAME=snapclient-with-pulse
# REPO=badaix/snapcast
# cd "${CURRDIR}" || exit
# CUR_VERSION="$(find . -name "snapclient_*with-pulse.deb" | sed 's/.*_\([0-9\.][0-9\.]*\).*/\1/' | sort -rnk3 | head -n 1)"
# NEW_VERSION="$(curl --user "$GH_USER:$GH_TOKEN" -sSL https://api.github.com/repos/$REPO/releases | grep '"tag_name":' | sed -n 's/[^0-9.]*\([0-9.]*\).*/\1/p' | head -n 1)"
# echo "Current $APP_NAME Version: $CUR_VERSION => New Version: $NEW_VERSION"
# if [[ "$CUR_VERSION" < "$NEW_VERSION" ]]; then
# echo "Downloading new $APP_NAME version $NEW_VERSION"
# cd "${CURRDIR}" || exit
# curl --user "$GH_USER:$GH_TOKEN" -sSL https://api.github.com/repos/$REPO/releases \
# | grep "browser_download_url.*snapclient.*_with-pulse.deb" \
# | cut -d : -f 2,3 \
# | tr -d \" \
# | head -n 1 \
# | wget -qi -
# DEB_FILE="$(find . -name "snapclient_"$NEW_VERSION"-1_amd64_*_with-pulse.deb" 2>/dev/null)"
# # https://www.baeldung.com/linux/package-deb-change-repack
# # Change package name to "snapclient-with-pulse"
# mkdir ./debtmp
# dpkg-deb -R "$DEB_FILE" ./debtmp
# sed -i "s|Package: snapclient|Package: snapclient-with-pulse|g" ./debtmp/DEBIAN/control
# cd ./debtmp/
# find . -type f -not -path "./DEBIAN/*" -exec md5sum {} + | sort -k 2 | sed 's/\.\/\(.*\)/\1/' > DEBIAN/md5sums
# cd .. || exit 0
# dpkg-deb -b ./debtmp "$DEB_FILE"
# rm -rf ./debtmp
# ###############
# mv "$DEB_FILE" ./debian/
# publish_release
# exit
# else
# echo "Latest $APP_NAME version already downloaded..."
# fi
# }
# timeshift() {
# APP_NAME=timeshift
# FILE_NAME=packages.tar.gz
# REPO=linuxmint/$APP_NAME
# cd "${CURRDIR}" || exit
#
# CUR_VERSION="$(find . -type f -name "$APP_NAME*.deb" | sed 's/.*_\([0-9\.][0-9\.]*\).*/\1/' | sort -rnk3 | head -n 1)"
# NEW_VERSION="$(curl --user "$GH_USER:$GH_TOKEN" -sSL https://api.github.com/repos/"$REPO"/releases |
# grep -oP '"browser_download_url":.*amd64.changes' |
# head -n 1 |
# sed 's/.*_\([0-9\.][0-9\.]*\).*/\1/')"
#
# if [ -z "$CUR_VERSION" ]; then
# echo "Downloading Latest $APP_NAME version..."
# curl --user "$GH_USER:$GH_TOKEN" -sSL https://api.github.com/repos/"$REPO"/releases |
# jq -r '.[] | select(.tag_name == "master.lmde6") | .assets[] | .browser_download_url' |
# head -n 1 |
# wget -qi -
# tar -xzvf packages.tar.gz
# DEB_FILE="$(find ./packages -type f -name "\"$APP_NAME\"_\"$NEW_VERSION\"_amd64.deb" 2>/dev/null)"
# mv "$DEB_FILE" ./debian/
# rm -rf ./packages
# publish_release
# exit
# else
# echo "Current $APP_NAME Version: $CUR_VERSION => New Version: $NEW_VERSION"
# if [[ "$CUR_VERSION" < "$NEW_VERSION" ]]
# then
# echo "Downloading $APP_NAME version $NEW_VERSION"
# cd "${CURRDIR}" || exit
# curl --user "$GH_USER:$GH_TOKEN" -sSL https://api.github.com/repos/"$REPO"/releases |
# jq -r '.[] | select(.tag_name == "master.lmde6") | .assets[] | .browser_download_url' |
# head -n 1 |
# wget -qi -
# tar -xzvf packages.tar.gz
# DEB_FILE="$(find ./packages -type f -name "\"$APP_NAME\"_\"$NEW_VERSION\"_amd64.deb" 2>/dev/null)"
# mv "$DEB_FILE" ./debian/
# rm -rf ./packages
# rm ./packages.tar.gz
# publish_release
# exit
# else
# echo "Latest $APP_NAME version already downloaded..."
# fi
# fi
# }
#GitHubDesktop
gnuzilla
# snapweb
# snapserver
# snapclient
# snapclient_with_pulse
# timeshift
get_release
exit 0