blob: 6bdcd0c5cf9e191d7f0cb3ea262076e1c8d9ef4a (
about) (
plain)
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
|
#!/bin/sh
# SPDX-License-Identifier: CC0-1.0
# Copyright (C) 2023 Wojtek Kosior <koszko@koszko.org>
set -eu
cd "$(dirname "$0")"
WORKDIR=/tmp/guix-koszko-update-hashes-workdir
mkdir -p $WORKDIR
FILES_AND_URLS="$(grep -E 'url "https://git.koszko.org' gnu/packages/*.scm)"
while [ x != "x$FILES_AND_URLS" ]
do :
LINE="$(printf '%s' "$FILES_AND_URLS" | head -1)"
FILES_AND_URLS="$(printf '%s' "$FILES_AND_URLS" | tail -n +2)"
FILENAME="$(printf '%s' "$LINE" | awk -F : '{print $1}')"
REPO="$(printf '%s' "$LINE" | sed 's|.*git.koszko.org/\([^/"]*\).*|\1|')"
REPODIR=$WORKDIR/$REPO
rm -rf $REPODIR
git clone http://localhost:8098/$REPO $REPODIR
CONTENT_HASH=$(guix hash \
--hash=sha256 \
--serializer=nar \
--format=nix-base32 \
--exclude-vcs \
$REPODIR)
HEAD=$(awk '/^ref: /{print $2;}' $REPODIR/.git/HEAD)
COMMIT_HASH=$(cat $REPODIR/.git/$HEAD)
export REPO
export CONTENT_HASH
export COMMIT_HASH
gawk -F '"' \
'BEGIN {inside_right_package = 0;}
{if (inside_right_package) {
printed = 1;
if (match($0, /"[0-9a-z]{52}"/))
print(gensub(/[0-9a-z]{52}/, ENVIRON["CONTENT_HASH"], 1));
else if (match($0, /"[0-9a-z]{40}"/))
print(gensub(/[0-9a-z]{40}/, ENVIRON["COMMIT_HASH"], 1));
else
print $0;
} else {
print $0;
}
if (index($0, "git.koszko.org/" ENVIRON["REPO"]))
inside_right_package = 1;
}
/\(license/ {inside_right_package = 0;}' \
$FILENAME > $WORKDIR/modified-file.scm
mv $WORKDIR/modified-file.scm $FILENAME
done
rm -rf $WORKDIR
|