Skip to content

Commit

Permalink
Merge pull request #172 from sharkwouter/master
Browse files Browse the repository at this point in the history
Add repo index pages
  • Loading branch information
sharkwouter authored Jun 21, 2024
2 parents 4d15435 + 81734c2 commit eaae40c
Show file tree
Hide file tree
Showing 5 changed files with 138 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,17 @@ jobs:

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Download artifacts
uses: actions/download-artifact@v4
- name: Create repo files
run: |
chown -R $(id -nu):$(id -ng) .
apk add --no-cache bash coreutils
mkdir repo
cp artifact-*/*.pkg.tar.gz repo/
./make-repo-html.sh
cd repo
${PSPDEV}/share/pacman/bin/repo-add pspdev.db.tar.gz *.pkg.tar.gz
mv pspdev.db.tar.gz pspdev.db
Expand Down
15 changes: 15 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!DOCTYPE html>
<html>
<head>
<title>${GITHUB_REPOSITORY_OWNER}&#39;s package index</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<p><h1>${GITHUB_REPOSITORY_OWNER}&#39;s package index</h1></p>
<table>
<tr><th>Name</th><th>Version</th><th>Description</th><th>Last Updated</th></tr>
${INDEX_TABLE_CONTENT}
</table>
<p>Source on <a href="https://github.com/${GITHUB_REPOSITORY}/">GitHub</a></p>
</body>
</html>
62 changes: 62 additions & 0 deletions make-repo-html.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/bin/bash

#Change directory to the directory of this script
cd "$(dirname "$0")"

# 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
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[*]}"

# 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>${UPDATED}</td></tr>"
done

envsubst < index.html > repo/index.html
cp style.css repo/
32 changes: 32 additions & 0 deletions package.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<!DOCTYPE html>
<html>
<head>
<title>${pkgname} - ${GITHUB_REPOSITORY_OWNER}&#39;s package index</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<p><h1>${GITHUB_REPOSITORY_OWNER}&#39;s package index</h1></p>
<p><h2>${pkgname} ${pkgver}-${pkgrel}</h2></p>

<p>
<b>Architecture:</b> ${ARCH}</br>
<b>Description:</b> ${pkgdesc}</br>
<b>Upstream URL:</b> <a href="${url}">${url}</a></br>
<b>License:</b> ${LICENSE}</br>
<b>Last Updated:</b> ${UPDATED}</br>
<b>Package Size:</b> ${PKGSIZE}</br>
<b>Installed Size:</b> ${INSTSIZE}</br>
<b>Download:</b> <a href="${DOWNLOAD_URL}">${DOWNLOAD_URL}</a></br>
</p>

<p><h3>Dependencies</h3></p>
<p>${DEPS}</p>

<p><h3>Contents</h3></p>
<p>${CONTENT}</p>

<p><a href="index.html">Back to index</a></p>

<p>Source on <a href="https://github.com/${GITHUB_REPOSITORY}/">GitHub</a></p>
</body>
</html>
24 changes: 24 additions & 0 deletions style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
body {
font-family: sans-serif;
}

table {
border-collapse: collapse;
font-size: 0.9em;
}

table tbody tr {
border-bottom: 1px solid #dddddd;
}

table th, td {
padding: 12px 15px;
}

table tbody tr:nth-of-type(even) {
background-color: #f3f3f3;
}

table tbody tr:nth-of-type(uneven) {
background-color: #009879;
}

0 comments on commit eaae40c

Please sign in to comment.