-
Notifications
You must be signed in to change notification settings - Fork 3
/
xxadopt
executable file
·63 lines (54 loc) · 1.29 KB
/
xxadopt
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
#!/bin/sh
# xxadopt [-f|-o] PKG.. - adopt packages
#
# -f : (force) adopt even if it's not orphaned
# -o : orphan the package
set -eu
_force=
_orphan=
if [ "$1" = "-f" ]; then
_force=1
shift
elif [ "$1" = "-o" ]; then
_orphan=1
shift
fi
cd "$(xdistdir)"
# make sure all templates exist
templates=
fail=
for pkg in "$@"; do
if [ -f "srcpkgs/$pkg/template" ]; then
t="srcpkgs/$pkg/template"
elif [ -f "$pkg/template" ]; then
t="$pkg/template"
elif [ -f "$pkg" ]; then
t="$pkg"
else
printf 'ERROR: could not find template for: %s\n' "$pkg" 2>&1
fail=1
continue
fi
templates="$templates $t"
done
[ -n "$fail" ] && exit 1
if [ "$_orphan" ]; then
new_maintainer="Orphaned <[email protected]>"
else
new_maintainer="$(git config user.name) <$(git config user.email)>"
fi
# patch templates
for t in $templates; do
pkg="$(printf '%s' "$t" | cut -d/ -f2)"
if [ -z "$_force" ] && [ -z "$_orphan" ] && ! grep -q -i "^maintainer=.*orphan@voidlinux.*" "$t"; then
printf -- 'Skip package (not orphaned): %s\n' "$pkg" >&2
continue
fi
hash_pre="$(md5sum "$t")"
sed -i "$t" \
-e "/^maintainer=/s/=.*/=\"${new_maintainer}\"/"
hash_post="$(md5sum "$t")"
[ "$hash_pre" != "$hash_post" ] &&
printf -- 'Changed: %s (%s)\n' "$pkg" "$new_maintainer" ||
printf -- 'Unchanged: %s\n' "$pkg" >&2
done