-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpackage.sh
executable file
·485 lines (471 loc) · 18.3 KB
/
package.sh
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
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
#!/bin/sh
version=$(head -n1 extra/changelog-archive/2024 | cut -c8-)
if [ -z "$2" ]; then
revision=1
else
revision="$2"
fi
mkdir -p port-jobs/working
_create_generic_linux() {
printf '\npackaging as generic (Linux)...\n'
mkdir -p output/linuxtemp/usr/bin \
output/linuxtemp/usr/lib/sshyp/extensions \
output/linuxtemp/usr/share/man/man1 \
output/linuxtemp/usr/share/bash-completion/completions \
output/linuxtemp/usr/share/zsh/functions/Completion/Unix
# START PORT
cp lib/* port-jobs/working/
cd port-jobs
./CLIPTOOL.py LINUX
./CLIPBOARD.py LINUX
./CHOWN.py
./UNAME.py LINUX
./COMMENTS.py ALL
./BLANKS.py
./TABS.sh TABS
cd ..
mv port-jobs/working/* output/linuxtemp/usr/lib/sshyp/
# END PORT
ln -s /usr/lib/sshyp/sshyp.py output/linuxtemp/usr/bin/sshyp
cp -r share output/linuxtemp/usr/
cp extra/completion.bash output/linuxtemp/usr/share/bash-completion/completions/sshyp
cp extra/completion.zsh output/linuxtemp/usr/share/zsh/functions/Completion/Unix/_sshyp
cp extra/manpage output/linuxtemp/usr/share/man/man1/sshyp.1
gzip output/linuxtemp/usr/share/man/man1/sshyp.1
XZ_OPT=-e6 tar -C output/linuxtemp -cvJf output/GENERIC-LINUX-sshyp-"$version".tar.xz usr/
rm -rf output/linuxtemp
sha512="$(sha512sum output/GENERIC-LINUX-sshyp-"$version".tar.xz | cut -d' ' -f1)"
printf '\ngeneric (Linux) packaging complete\n\n'
} &&
_create_pkgbuild() {
printf '\ngenerating PKGBUILD...\n'
if [ "$1" = 'Deb' ]; then
local source='https://github.com/rwinkhart/sshyp/releases/download/v"$pkgver"/DEBIAN-sshyp_"$pkgver"-"$pkgrel"_all.deb'
local decomp_target='data.tar.xz'
else
local source='https://github.com/rwinkhart/sshyp/releases/download/v"$pkgver"/GENERIC-LINUX-sshyp-"$pkgver".tar.xz'
local decomp_target='GENERIC-LINUX-sshyp-"$pkgver".tar.xz'
fi
printf "# Maintainer: Randall Winkhart <idgr at tutanota dot com>
pkgname=sshyp
pkgver="$version"
pkgrel="$revision"
pkgdesc='A light-weight, self-hosted, synchronized password manager'
url='https://github.com/rwinkhart/sshyp'
arch=('any')
license=('GPL-3.0-only')
depends=(python gnupg openssh)
optdepends=(
'wl-clipboard: wayland clipboard support'
'xclip: x11 clipboard support'
'bash-completion: bash completion support'
)
source=(\""$source"\")
sha512sums=('"$sha512"')
package() {
tar -xf $decomp_target -C "\"\${pkgdir}\""
}
" > output/PKGBUILD
printf '\nPKGBUILD generated\n\n'
} &&
_create_apkbuild() {
printf '\ngenerating APKBUILD...\n'
if [ "$1" = 'Deb' ]; then
local source="https://github.com/rwinkhart/sshyp/releases/download/v\"\$pkgver\"/DEBIAN-sshyp_\"\$pkgver\"-"$revision"_all.deb"
local sumsname="DEBIAN-sshyp_\"\$pkgver\"-"$revision"_all.deb"
local processing='mkdir -p "$pkgdir"
7z x "$srcdir"/* -o"$srcdir"
tar -xf "$srcdir"/data.tar -C "$pkgdir"
mkdir -p "$pkgdir/usr/share/zsh/site-functions"
mv "$pkgdir/usr/share/zsh/functions/Completion/Unix/_sshyp" "$pkgdir/usr/share/zsh/site-functions/_sshyp"
rm -rf "$pkgdir/usr/share/zsh/functions"'
else
local source='https://github.com/rwinkhart/sshyp/releases/download/v"$pkgver"/GENERIC-LINUX-sshyp-"$pkgver".tar.xz'
local sumsname='GENERIC-LINUX-sshyp-"$pkgver".tar.xz'
local processing='mkdir -p "$pkgdir"
mkdir -p "$srcdir/usr/share/zsh/site-functions"
mv "$srcdir/usr/share/zsh/functions/Completion/Unix/_sshyp" "$srcdir/usr/share/zsh/site-functions/_sshyp"
rm -rf "$srcdir/usr/share/zsh/functions"
cp -r "$srcdir/usr/" "$pkgdir"'
fi
printf "# Maintainer: Randall Winkhart <idgr@tutanota.com>
pkgname=sshyp
pkgver="$version"
pkgrel="$((revision-1))"
pkgdesc='A light-weight, self-hosted, synchronized password manager'
options=!check
url='https://github.com/rwinkhart/sshyp'
arch='noarch'
license='GPL-3.0-only'
depends='python3 gnupg openssh'
source=\""$source"\"
package() {
$processing
}
sha512sums=\"
"$sha512" "$sumsname"
\"
" > output/APKBUILD
printf '\nAPKBUILD generated\n\n'
} &&
_create_hpkg() {
printf '\npackaging for Haiku...\n'
mkdir -p output/haikutemp/bin \
output/haikutemp/lib/sshyp/extensions \
output/haikutemp/documentation/packages/sshyp \
output/haikutemp/documentation/man/man1 \
output/haikutemp/data/bash-completion/completions \
output/haikutemp/data/zsh/site-functions
printf "name sshyp_client
version "$version"-"$revision"
architecture any
summary \"A light-weight, self-hosted, synchronized password manager (client only)\"
description \"The fully-featured client for the sshyp password manager ported for Haiku. This is just a client: server hosting functionality is only available on Linux/BSD.\"
packager \"Randall Winkhart <idgr at tutanota dot com>\"
vendor \"Randall Winkhart\"
licenses {
\"GNU GPL v3\"
}
copyrights {
\"2021-2024 Randall Winkhart\"
}
provides {
sshyp_client = "$version"
cmd:sshyp
}
requires {
gnupg
openssh
python3.11
}
urls {
\"https://github.com/rwinkhart/sshyp\"
}
" > output/haikutemp/.PackageInfo
# START PORT
cp lib/* port-jobs/working/
cd port-jobs
./SHEBANG.sh
./RMSERVER.py
./RMEXTMAN.py
./CLIPTOOL.py
./CLIPBOARD.py HAIKU
./CHOWN.py
./UNAME.py TMP
./COMMENTS.py ALL
./BLANKS.py
./TABS.sh TABS
cd ..
mv port-jobs/working/* output/haikutemp/lib/sshyp/
# END PORT
ln -s /system/lib/sshyp/sshyp.py output/haikutemp/bin/sshyp
cp -r share/licenses/sshyp/. output/haikutemp/documentation/packages/sshyp/
cp extra/completion.bash output/haikutemp/data/bash-completion/completions/sshyp
cp extra/completion.zsh output/haikutemp/data/zsh/site-functions/_sshyp
cp extra/manpage output/haikutemp/documentation/man/man1/sshyp.1
gzip output/haikutemp/documentation/man/man1/sshyp.1
cd output/haikutemp
package create -b HAIKU-sshyp_client-"$version"-"$revision"_all.hpkg
package add HAIKU-sshyp_client-"$version"-"$revision"_all.hpkg bin lib documentation data
cd ../..
mv output/haikutemp/HAIKU-sshyp_client-"$version"-"$revision"_all.hpkg output/
rm -rf output/haikutemp
printf '\nHaiku packaging complete\n\n'
} &&
_create_deb() {
printf "\npackaging for $1...\n"
mkdir -p output/debiantemp/sshyp_"$version"-"$revision"_all/DEBIAN \
output/debiantemp/sshyp_"$version"-"$revision"_all/usr/lib/sshyp/extensions \
output/debiantemp/sshyp_"$version"-"$revision"_all/usr/bin \
output/debiantemp/sshyp_"$version"-"$revision"_all/usr/share/man/man1 \
output/debiantemp/sshyp_"$version"-"$revision"_all/usr/share/bash-completion/completions \
output/debiantemp/sshyp_"$version"-"$revision"_all/usr/share/zsh/functions/Completion/Unix
# START PORT
cp lib/* port-jobs/working/
cd port-jobs
if [ "$1" = 'Debian' ]; then
./CLIPTOOL.py LINUX
./CLIPBOARD.py LINUX
special=DEBIAN
else
./CLIPTOOL.py
./CLIPBOARD.py WSL
special=WSL-ONLY-DEBIAN
fi
./CHOWN.py
./UNAME.py LINUX
./COMMENTS.py ALL
./BLANKS.py
./TABS.sh TABS
cd ..
mv port-jobs/working/* output/debiantemp/sshyp_"$version"-"$revision"_all/usr/lib/sshyp/
# END PORT
ln -s /usr/lib/sshyp/sshyp.py output/debiantemp/sshyp_"$version"-"$revision"_all/usr/bin/sshyp
cp -r share output/debiantemp/sshyp_"$version"-"$revision"_all/usr/
cp extra/completion.bash output/debiantemp/sshyp_"$version"-"$revision"_all/usr/share/bash-completion/completions/sshyp
cp extra/completion.zsh output/debiantemp/sshyp_"$version"-"$revision"_all/usr/share/zsh/functions/Completion/Unix/_sshyp
cp extra/manpage output/debiantemp/sshyp_"$version"-"$revision"_all/usr/share/man/man1/sshyp.1
gzip output/debiantemp/sshyp_"$version"-"$revision"_all/usr/share/man/man1/sshyp.1
size=$(du --block-size=1024 -s output/debiantemp/sshyp_"$version"-"$revision"_all | cut -f1)
printf "Package: sshyp
Version: $version
Section: utils
Architecture: all
Maintainer: Randall Winkhart <idgr at tutanota dot com>
Description: A light-weight, self-hosted, synchronized password manager
Priority: optional
Installed-Size: $size
Depends: python3, gnupg, openssh-client
" > output/debiantemp/sshyp_"$version"-"$revision"_all/DEBIAN/control
if [ "$1" = 'Debian' ]; then
printf "Suggests: wl-clipboard, xclip, bash-completion, openssh-server
" >> output/debiantemp/sshyp_"$version"-"$revision"_all/DEBIAN/control
else
printf "Suggests: bash-completion, openssh-server
" >> output/debiantemp/sshyp_"$version"-"$revision"_all/DEBIAN/control
fi
dpkg-deb --build --root-owner-group -z6 -Sextreme -Zxz output/debiantemp/sshyp_"$version"-"$revision"_all/
mv output/debiantemp/sshyp_"$version"-"$revision"_all.deb output/"$special"-sshyp_"$version"-"$revision"_all.deb
rm -rf output/debiantemp
sha512="$(sha512sum output/"$special"-sshyp_"$version"-"$revision"_all.deb | cut -d' ' -f1)"
printf "\n$1 packaging complete\n\n"
} &&
_create_termux() {
printf '\npackaging for Termux...\n'
mkdir -p output/termuxtemp/TERMUX-sshyp-client_"$version"-"$revision"_all_termux/DEBIAN \
output/termuxtemp/TERMUX-sshyp-client_"$version"-"$revision"_all_termux/data/data/com.termux/files/usr/lib/sshyp/extensions \
output/termuxtemp/TERMUX-sshyp-client_"$version"-"$revision"_all_termux/data/data/com.termux/files/usr/bin \
output/termuxtemp/TERMUX-sshyp-client_"$version"-"$revision"_all_termux/data/data/com.termux/files/usr/share/man/man1 \
output/termuxtemp/TERMUX-sshyp-client_"$version"-"$revision"_all_termux/data/data/com.termux/files/usr/share/bash-completion/completions \
output/termuxtemp/TERMUX-sshyp-client_"$version"-"$revision"_all_termux/data/data/com.termux/files/usr/share/zsh/site-functions
# START PORT
cp lib/* port-jobs/working/
cd port-jobs
./RMSERVER.py
./RMEXTMAN.py
./CLIPTOOL.py
./CLIPBOARD.py TERMUX
./CHOWN.py
./UNAME.py TERMUX
./COMMENTS.py ALL
./BLANKS.py
./TABS.sh TABS
cd ..
mv port-jobs/working/* output/termuxtemp/TERMUX-sshyp-client_"$version"-"$revision"_all_termux/data/data/com.termux/files/usr/lib/sshyp/
# END PORT
ln -s /data/data/com.termux/files/usr/lib/sshyp/sshyp.py output/termuxtemp/TERMUX-sshyp-client_"$version"-"$revision"_all_termux/data/data/com.termux/files/usr/bin/sshyp
cp -r share output/termuxtemp/TERMUX-sshyp-client_"$version"-"$revision"_all_termux/data/data/com.termux/files/usr/
cp extra/completion.bash output/termuxtemp/TERMUX-sshyp-client_"$version"-"$revision"_all_termux/data/data/com.termux/files/usr/share/bash-completion/completions/sshyp
cp extra/completion.zsh output/termuxtemp/TERMUX-sshyp-client_"$version"-"$revision"_all_termux/data/data/com.termux/files/usr/share/zsh/site-functions/_sshyp
cp extra/manpage output/termuxtemp/TERMUX-sshyp-client_"$version"-"$revision"_all_termux/data/data/com.termux/files/usr/share/man/man1/sshyp.1
gzip output/termuxtemp/TERMUX-sshyp-client_"$version"-"$revision"_all_termux/data/data/com.termux/files/usr/share/man/man1/sshyp.1
size=$(du --block-size=1024 -s output/termuxtemp/TERMUX-sshyp-client_"$version"-"$revision"_all_termux | cut -f1)
printf "Package: sshyp-client
Version: $version
Section: utils
Architecture: all
Maintainer: Randall Winkhart <idgr at tutanota dot com>
Description: A light-weight, self-hosted, synchronized password manager
Depends: python, gnupg, openssh, termux-api, termux-am
Suggests: bash-completion
Priority: optional
Installed-Size: $size
" > output/termuxtemp/TERMUX-sshyp-client_"$version"-"$revision"_all_termux/DEBIAN/control
dpkg-deb --build --root-owner-group -z6 -Sextreme -Zxz output/termuxtemp/TERMUX-sshyp-client_"$version"-"$revision"_all_termux/
mv output/termuxtemp/TERMUX-sshyp-client_"$version"-"$revision"_all_termux.deb output/
rm -rf output/termuxtemp
printf '\nTermux packaging complete\n\n'
} &&
_create_rpm() {
printf '\npackaging for Fedora...\n'
rm -rf ~/rpmbuild
rpmdev-setuptree
mkdir -p output/fedoratemp/usr/bin \
output/fedoratemp/usr/lib/sshyp/extensions \
output/fedoratemp/usr/share/man/man1 \
output/fedoratemp/usr/share/bash-completion/completions \
output/fedoratemp/usr/share/zsh/site-functions
printf "Name: sshyp
Version: "$version"
Release: "$revision"
Summary: A light-weight, self-hosted, synchronized password manager
BuildArch: noarch
License: GPL-3.0-only
URL: https://github.com/rwinkhart/sshyp
Source0: GENERIC-FEDORA-sshyp-"$version".tar.xz
Requires: python gnupg openssh-clients
Recommends: wl-clipboard xclip bash-completion openssh-server
%%description
sshyp is a password-store compatible CLI password manager available for UNIX(-like) systems - its primary goal is to make syncing passwords and notes across devices as easy as possible via CLI.
%%install
tar xf %%{_sourcedir}/GENERIC-FEDORA-sshyp-"$version".tar.xz -C %%{_sourcedir}
cp -r %%{_sourcedir}/usr %%{buildroot}
%%files
/usr/bin/sshyp
/usr/lib/sshyp/sshyp.py
/usr/lib/sshyp/sshync.py
/usr/lib/sshyp/stweak.py
/usr/lib/sshyp/clipclear.py
/usr/lib/sshyp/extensions/
/usr/share/bash-completion/completions/sshyp
/usr/share/zsh/site-functions/_sshyp
%%license /usr/share/licenses/sshyp/license
%%doc
/usr/share/man/man1/sshyp.1.gz
" > ~/rpmbuild/SPECS/sshyp.spec
# START PORT
cp lib/* port-jobs/working/
cd port-jobs
./CLIPTOOL.py LINUX
./CLIPBOARD.py LINUX
./CHOWN.py
./UNAME.py LINUX
./COMMENTS.py ALL
./BLANKS.py
./TABS.sh TABS
cd ..
mv port-jobs/working/* output/fedoratemp/usr/lib/sshyp/
# END PORT
ln -s /usr/lib/sshyp/sshyp.py output/fedoratemp/usr/bin/sshyp
cp -r share output/fedoratemp/usr/
cp extra/completion.bash output/fedoratemp/usr/share/bash-completion/completions/sshyp
cp extra/completion.zsh output/fedoratemp/usr/share/zsh/site-functions/_sshyp
cp extra/manpage output/fedoratemp/usr/share/man/man1/sshyp.1
gzip output/fedoratemp/usr/share/man/man1/sshyp.1
XZ_OPT=-e6 tar -C output/fedoratemp -cvJf output/GENERIC-FEDORA-sshyp-"$version".tar.xz usr/
rm -rf output/fedoratemp
cp output/GENERIC-FEDORA-sshyp-"$version".tar.xz ~/rpmbuild/SOURCES
rpmbuild -bb ~/rpmbuild/SPECS/sshyp.spec
mv ~/rpmbuild/RPMS/noarch/sshyp-"$version"-"$revision".noarch.rpm output/FEDORA-sshyp-"$version"-"$revision".noarch.rpm
rm -rf ~/rpmbuild
printf '\nFedora packaging complete\n\n'
} &&
_create_freebsd_pkg() {
printf '\npackaging for FreeBSD...\n'
mkdir -p output/freebsdtemp/usr/lib/sshyp/extensions \
output/freebsdtemp/usr/bin \
output/freebsdtemp/usr/share/man/man1 \
output/freebsdtemp/usr/local/share/bash-completion/completions \
output/freebsdtemp/usr/local/share/zsh/site-functions
printf "name: sshyp
version: \""$version"\"
abi = \"FreeBSD:13:*\";
arch = \"freebsd:13:*\";
origin: security/sshyp
comment: \"a password manager\"
desc: \"a light-weight, self-hosted, synchronized password manager\"
maintainer: <idgr at tutanota dot com>
www: https://github.com/rwinkhart/sshyp
prefix: /
\"deps\" : {
\"python3\" : {
\"origin\" : \"lang/python3\"
},
\"gnupg\" : {
\"origin\" : \"security/gnupg\"
},
},
" > output/freebsdtemp/+MANIFEST
printf "/usr/bin/sshyp
/usr/lib/sshyp/sshyp.py
/usr/lib/sshyp/sshync.py
/usr/lib/sshyp/stweak.py
/usr/lib/sshyp/clipclear.py
/usr/local/share/bash-completion/completions/sshyp
/usr/local/share/zsh/site-functions/_sshyp
/usr/share/licenses/sshyp/license
/usr/share/man/man1/sshyp.1.gz
@dir /usr/lib/sshyp/extensions/
" > output/freebsdtemp/plist
# START PORT
cp lib/* port-jobs/working/
cd port-jobs
./CLIPTOOL.py LINUX
./CLIPBOARD.py BSD
./CHOWN.py BSD
./UNAME.py TMP
./COMMENTS.py ALL
./BLANKS.py
./TABS.sh TABS
cd ..
mv port-jobs/working/* output/freebsdtemp/usr/lib/sshyp/
# END PORT
ln -s /usr/lib/sshyp/sshyp.py output/freebsdtemp/usr/bin/sshyp
cp -r share output/freebsdtemp/usr/
cp extra/completion.bash output/freebsdtemp/usr/local/share/bash-completion/completions/sshyp
cp extra/completion.zsh output/freebsdtemp/usr/local/share/zsh/site-functions/_sshyp
cp extra/manpage output/freebsdtemp/usr/share/man/man1/sshyp.1
gzip output/freebsdtemp/usr/share/man/man1/sshyp.1
pkg create -m output/freebsdtemp/ -r output/freebsdtemp/ -p output/freebsdtemp/plist -o output/
mv output/sshyp-"$version".pkg output/FREEBSD-sshyp-"$version"-"$revision".pkg
rm -rf output/freebsdtemp
printf '\nFreeBSD packaging complete\n\n'
} &&
case "$1" in
pkgbuild)
_create_generic_linux
_create_pkgbuild Generic
;;
pkgbuild-deb)
_create_deb Debian
_create_pkgbuild Deb
;;
apkbuild)
_create_generic_linux
_create_apkbuild Generic
;;
apkbuild-deb)
_create_deb Debian
_create_apkbuild Deb
;;
haiku)
_create_hpkg
;;
debian)
_create_deb Debian
;;
wsl)
_create_deb WSL
;;
termux)
_create_termux
;;
fedora)
_create_rpm
;;
freebsd)
_create_freebsd_pkg
;;
buildable-arch)
_create_generic_linux
_create_pkgbuild Generic
_create_apkbuild Generic
case "$(pacman -Q dpkg)" in
dpkg*)
_create_termux
_create_deb WSL
_create_deb Debian
;;
esac
case "$(pacman -Q freebsd-pkg)" in
freebsd-pkg*)
_create_freebsd_pkg
;;
esac
;;
buildable-arch-deb)
_create_termux
_create_deb WSL
_create_deb Debian
_create_pkgbuild Deb
_create_apkbuild Deb
case "$(pacman -Q freebsd-pkg)" in
freebsd-pkg*)
_create_freebsd_pkg
;;
esac
;;
*)
printf '\nusage: package.sh [target] <revision>\n\ntargets:\n full support: pkgbuild pkgbuild-deb apkbuild apkbuild-deb fedora debian wsl freebsd\n client-only: haiku termux\n groups: buildable-arch buildable-arch-deb\n\n'
;;
esac