#!/bin/sh -e rm -rf public mkdir -p public html_escape() { sed 's/\&/\&/g;s//\>/g;s/"/\"/g' } port_version() { grep '^version=' "$1/abuild" | cut -d = -f2- || true } port_release() { grep '^release=' "$1/abuild" | cut -d = -f2- || true } port_depends() { [ -f "$1/depends" ] || return 0 grep -Ev '^(#|$)' "$1/depends" | tr '\n' ' ' | sed 's/[[:space:]]*$//' || true } generate_ports_page() { { sed "s/@TITLE@/ports/g" files/header echo "

Package ports generated from repos/core, repos/extra, and repos/community.

" echo "
" echo "" echo "" echo "" echo "" echo "" echo "
" echo "
0 / 0 ports
" echo "" echo "" echo "" for repo in core extra community; do for port in repos/$repo/*; do [ -f "$port/abuild" ] || continue name=${port##*/} version=$(port_version "$port") release=$(port_release "$port") depends=$(port_depends "$port") [ "$release" ] && version=$version-$release printf '\n' \ "$(printf '%s' "$repo" | html_escape)" \ "$(printf '%s' "$repo" | html_escape)" \ "$(printf '%s' "$repo" | html_escape)" \ "$(printf '%s' "$name" | html_escape)" \ "$(printf '%s' "$name" | html_escape)" \ "$(printf '%s' "$version" | html_escape)" \ "$(printf '%s' "$depends" | html_escape)" done done echo "" echo "
reponameversiondependencies
%s%s%s%s
" cat << 'EOF' EOF cat files/footer } > public/ports.html } for i in $(find . -type f -name "*.html" | sed 's|^\./||'); do dir=${i%/*} file=${i##*/} title=${dir##*/} [ "$dir" = "$file" ] && { title=home; dir= } mkdir -p public/$dir echo "copy html for $i..." { sed "s/@TITLE@/$title/g" files/header cat $i cat files/footer } > public/$dir/$file done generate_ports_page generate_commits_page() { { sed "s/@TITLE@/commits/g" files/header cat << 'EOF'

Recent commits from codeberg.org/emmett1/alicelinux.

loading…
EOF cat files/footer } > public/commits.html } generate_commits_page generate_download_page() { { sed "s/@TITLE@/download/g" files/header listing=$(curl -sL --max-time 10 https://dl.alicelinux.org/ 2>/dev/null || true) cat << 'EOF'
loading…
EOF if [ -n "$listing" ]; then echo "$listing" | sed -n '//,/<\/tbody>/p' | while IFS= read -r row; do case $row in *''*) href=$(printf '%s' "$row" | sed 's/.*.*/\1/') name=$(printf '%s' "$row" | sed 's/.*\([^<]*\)<.*/\1/') size=$(printf '%s' "$row" | sed 's/.*\n' \ "$(printf '%s' "$url" | html_escape)" \ "$(printf '%s' "$name" | html_escape)" \ "$(printf '%s' "$size" | html_escape)" \ "$(printf '%s' "$date" | html_escape)" else printf '\n' \ "$(printf '%s' "$url" | html_escape)" \ "$(printf '%s' "$name" | html_escape)" \ "$(printf '%s' "$size" | html_escape)" \ "$(printf '%s' "$date" | html_escape)" fi ;; esac done fi cat << 'EOF'
]*>\([^<]*\)<.*/\1/') date=$(printf '%s' "$row" | sed 's/.*\([^<]*\)<.*/\1/') type=$(printf '%s' "$row" | sed 's/.*\([^<]*\)<.*/\1/') [ "$name" = "../" ] && continue url="https://dl.alicelinux.org/$href" if [ "$type" = "Directory" ]; then printf '
%s/%s%s
%s%s%s
EOF cat files/footer } > public/download.html } generate_download_page # docs cat docs/readme.md > docs/index.md for f in docs/*.md; do case $f in */readme.md|*/index.md) continue;; esac title=$(head -n1 $f) file=${f##*/} echo "- [$title](./${file%.md}.html)" >> docs/index.md done for i in $(find . -type f -name "*.md" | sed 's|^\./||'); do dir=${i%/*} file=${i##*/} title=${dir##*/} [ "$dir" = "$file" ] && { title=home; dir= } mkdir -p public/$dir echo "generating html for $i..." { sed "s/@TITLE@/$title/g" files/header cmark $i cat files/footer } > public/${i%.md}.html done # mv readme.html to index.html for i in $(find public -type f -name "readme.html" | sed 's|^\./||'); do mv -n $i ${i%/*}/index.html done rm -f docs/index.md if [ -d files ]; then cp -ra files public/ fi echo alicelinux.org > public/.domains echo alicelinux.emmett1.my >> public/.domains exit 0