-
Notifications
You must be signed in to change notification settings - Fork 14
/
make-repo-html.sh
executable file
·69 lines (56 loc) · 1.87 KB
/
make-repo-html.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
#!/bin/bash
#Change directory to the directory of this script
cd "$(dirname "$0")"
mkdir -p repo
# Export all variables
set -a
# Fail on error
set -e
# Set global variables
GITHUB_REPOSITORY_OWNER="${GITHUB_REPOSITORY_OWNER:-pspdev}"
GITHUB_REPOSITORY="${GITHUB_REPOSITORY:-pspdev/pspdev}"
INDEX_TABLE_CONTENT=""
# Build the html pages
for PSPBUILD in $(find . -name "PSPBUILD" | sort); do
# Make sure optional variables are from current PSPBUILD
unset groups
unset license
unset depends
source "${PSPBUILD}"
UPDATED=$(git log -1 --format=%cd --date=short -- "${PSPBUILD}")
DOWNLOAD_URL="${pkgname}-${pkgver}-${pkgrel}-${arch}.pkg.tar.gz"
# Convert lists to strings
ARCH="${arch[*]}"
LICENSE="${license[*]}"
GROUP_LIST="${groups[*]}"
# Get file size info
FILENAME="repo/${DOWNLOAD_URL}"
if [ -f "${FILENAME}" ]; then
PKGSIZE="$(ls -l "${FILENAME}"|cut -d' ' -f5|numfmt --to iec --suffix=B --format "%.1f")"
INSTSIZE="$(gunzip -c "${FILENAME}"|grep -a '^size = '|cut -d' ' -f3|numfmt --to iec --suffix=B --format "%.1f")"
fi
# List dependencies
if [ ! -n "${depends[*]}" ]; then
DEPS="No dependencies"
else
DEPS="<ul>"
for dep in "${depends[@]}"; do
DEPS="${DEPS}<li><a href=\"${dep}.html\">${dep}</a></li>"
done
DEPS="${DEPS}</ul>"
fi
# List content of files
if [ -f "${FILENAME}" ]; then
CONTENT="<ul>"
for item in $(tar -tzf $FILENAME | grep -v '\.BUILDINFO\|\.MTREE\|\.PKGINFO\|/$'); do
CONTENT="${CONTENT}<li>${item}</li>"
done
CONTENT="${CONTENT}</ul>"
else
CONTENT="Not known"
fi
envsubst < package.html > "repo/${pkgname}.html"
INDEX_TABLE_CONTENT="${INDEX_TABLE_CONTENT}<tr><td><a href=\"${pkgname}.html\">${pkgname}</a></td><td>${pkgver}-${pkgrel}</td><td>${pkgdesc}</td><td>${GROUP_LIST}</td><td>${UPDATED}</td></tr>"
done
envsubst < index.html > repo/index.html
cp style.css repo/