-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathupdate.sh
executable file
·124 lines (105 loc) · 3.48 KB
/
update.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
#!/bin/sh
# pkgs.void - web catalog of Void Linux packages.
# Copyright (C) 2019 Piotr Wójcik <[email protected]>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, version 3.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# This script updates packages database and published source tarball.
download=yes
repodata=yes
templates=yes
updates=
popularity=yes
builddate=yes
path="$(realpath "$(dirname "$0")")"
dir="$(basename "$path")"
cd $path || exit 1
[ -d venv ] && . venv/bin/activate
while true
do
case "$1" in
-B) builddate= ;;
-D) download= ;;
-P) popularity= ;;
-R) repodata= ;;
-T) templates= ;;
-t) templates=yes ;;
-u) updates=yes ;;
*) break
esac
shift
done
mirror="$(./settings.py REPODATA_MIRROR)"
rsyncmirror="$(./settings.py RSYNC_MIRROR)"
popcornmirror="$(./settings.py POPCORN_MIRROR)"
generated="$(./settings.py GENERATED_FILES_PATH)"
newindex="$(./settings.py DATASOURCE_ARGUMENTS_TEMPORARY | sed 's/,.*//')"
index="$(./settings.py DATASOURCE_ARGUMENTS | sed 's/,.*//')"
if ! [ -e "$index" ]; then
./initemptydb.py
mv "$newindex" "$index"
fi
mkdir -p "$generated"
cd .. || exit 1
tar cjf "$dir/$generated/tmp.tar.bz2" --exclude-ignore tar-exclude "$dir" || exit 1
cd "$dir" || exit 1
mv "$generated"/tmp.tar.bz2 "$generated"/pkgs.void.tar.bz2 || exit 1
if [ "$templates" ]
then
: "${XBPS_DISTDIR:=$(xdistdir)}"
( cd "$XBPS_DISTDIR" || exit $?
if [ "$download" ]
then
git fetch -q origin || exit $?
fi
git checkout -q origin/master || exit $?
) || exit $?
fi
mkdir -p data
cd data || exit 1
repos=$(cat ../repos.list)
for path in $repos; do
extract_dir=$(cd ..; ./repopaths.py directory_name "$path")
[ -e "$extract_dir" ] && rm -r "$extract_dir"
done
for path in $repos; do
arch="$(echo "$path" | tr / _)"
filename="$arch-repodata.tar.xz"
extract_dir=$(cd ..; ./repopaths.py directory_name "$path")
[ "$download" ] && wget -q -O "$filename" "$mirror/current/$path-repodata"
if ! [ -s "$filename" ]; then
continue
fi
mkdir "$extract_dir" || exit $?
tar xf "$filename" -C "$extract_dir"
done
if [ "$builddate" ]; then
for path in $repos; do
echo "$(cd ..; ./repopaths.py rsync_path "$path")"
done | sort -u | while read dir; do
filename="$(cd ..; ./repopaths.py rsync_filename "$dir")"
[ "$download" ] && rsync --list-only "${rsyncmirror}${dir}" --include '*.xbps' --exclude='*' > "${filename}"
done
fi
[ "$download" ] && [ "$updates" ] && wget -q -O void-updates.txt "$mirror/void-updates/void-updates.txt"
[ "$download" ] && [ "$popularity" ] &&
wget -q -O popcorn.today.json "$popcornmirror/popcorn_$(date +%Y-%m-%d).json" &&
mv popcorn.today.json popcorn.json
cd .. || exit 1
rm -f "$newindex"
[ "$repodata" ] && ./builddb.py $repos
[ "$templates" ] && ./dbfromrepo.py $repos
[ "$updates" ] && ./updates.py $repos
[ "$popularity" ] && ./popularity.py
[ "$builddate" ] && ./rsyncdata.py $repos
mv "$newindex" "$index"
python -c 'import voidhtml; print(voidhtml.list_all())' > "$generated"/all.html