File tree Expand file tree Collapse file tree 1 file changed +67
-0
lines changed Expand file tree Collapse file tree 1 file changed +67
-0
lines changed Original file line number Diff line number Diff line change
1
+ #! /usr/bin/bash
2
+ # SPDX-License-Identifier: GPL-3.0
3
+ set -Eeuo pipefail
4
+ trap ' errorHandler "$?" "${FUNCNAME[0]}" "$LINENO"' ERR
5
+
6
+ error () {
7
+ echo -e " \e[0;31m[ERROR] $* \e[0m" >&2
8
+ }
9
+
10
+ die () {
11
+ error " $* "
12
+ exit 1
13
+ }
14
+
15
+ log () {
16
+ echo -e " \e[0;32m$* \e[0m" >&2
17
+ }
18
+
19
+ errorHandler () {
20
+ echo -e " \e[0;31m[BUG] Line $3 ($2 ): $1 \e[0m" >&2
21
+ exit " $1 "
22
+ }
23
+
24
+ getPkgDir () {
25
+ local path
26
+ path=" $( find . -mindepth 2 -maxdepth 2 -type d -name " $1 " -print -quit) "
27
+ echo " ${path# ./ } "
28
+ }
29
+
30
+ getPkgVer () {
31
+ (
32
+ # shellcheck source=/dev/null
33
+ source " $1 " /spec
34
+ echo " $VER "
35
+ )
36
+ }
37
+
38
+ sumAndCommit () {
39
+ local pkg=" $1 "
40
+ local pkgDir pkgVer
41
+ pkgDir=" $( getPkgDir " $pkg " ) "
42
+ pkgVer=" $( getPkgVer " $pkgDir " ) "
43
+
44
+ log " [$pkg ] Updated to $pkgVer "
45
+
46
+ log " [$pkg ] Updating checksum ..."
47
+ abbs-update-checksum " $pkg "
48
+
49
+ log " [$pkg ] Committing ..."
50
+ git add " $pkgDir "
51
+ git commit -m " $pkg : update to $pkgVer " -- " $pkgDir "
52
+
53
+ local commitLog
54
+ commitLog=" $( git -c core.abbrev=16 \
55
+ log HEAD \
56
+ --oneline -1 --no-decorate --color=always) "
57
+ log " [$pkg ] $commitLog "
58
+
59
+ log " [$pkg ] SUCCESS!"
60
+ }
61
+
62
+ readarray -t pkgs < <( git status --porcelain | cut -d' ' -f 3 | (grep -E ' /spec$' || true) | cut -d' /' -f2)
63
+ for pkg in " ${pkgs[@]} " ; do
64
+ if ! sumAndCommit " $pkg " ; then
65
+ error " [$pkg ] FAILED"
66
+ fi
67
+ done
You can’t perform that action at this time.
0 commit comments