diff options
Diffstat (limited to 'admin/populate-boneyard')
| -rwxr-xr-x | admin/populate-boneyard | 181 |
1 files changed, 181 insertions, 0 deletions
diff --git a/admin/populate-boneyard b/admin/populate-boneyard new file mode 100755 index 0000000..d24e30d --- /dev/null +++ b/admin/populate-boneyard @@ -0,0 +1,181 @@ +#!/bin/bash + +set -u + +# 20260714 bkw: Populate the boneyard. + +# local paths +OUTDIR=~/boneyard +STATEDIR=~/boneyard-state +TREE=$STATEDIR/slackbuilds +OUTFILE=$OUTDIR/index.html + +# git stuff +CLONEURL=git://git.slackbuilds.org/slackbuilds.git +# this is the first commit of the 15.0 series: +START_COMMIT=15.0-20220311.1 +SLACKVER="$( echo $START_COMMIT | cut -d- -f1 )" + +# during script development/testing, set this to make +# test runs faster (but very incomplete of course): +#DEBUG_LIMIT="-n 10" +# for production, set this: +DEBUG_LIMIT="" + +# global variables: +catprg="" # e.g. "system/someapp" +categ="" # e.g. "system" +prg="" # e.g. "someapp" +tarball="" +gitlog="" +rm_log="" +last_log="" +tarcommit="" +descfile="" +desc="" +logfile="" + +# sets global variables. sorry, purists. +get_log_lines() { + catprg="$@" + prg="$( basename $catprg )" + categ="$( dirname $catprg )" + tarball=$OUTDIR/$prg.tar.gz + logfile=$STATEDIR/$categ-$prg.log + + if [ ! -e "$logfile" ]; then + git log -n2 --date=format:%Y-%m-%d --pretty=format:"%h%x09%ad%x09%s" -- "$catprg/$prg.SlackBuild" > $logfile + fi + + gitlog="$( cat $logfile )" + + rm_log="$( echo "$gitlog" | head -n 1 )" + last_log="$( echo "$gitlog" | tail -n 1 )" + tarcommit="$( echo $last_log | cut -d' ' -f1 )" + descfile=$STATEDIR/$categ-$prg.desc + + echo " $catprg last commit before removal: $tarcommit" +} + +mktarball() { + if [ -e "$tarball" -a -e "$descfile" ]; then + echo " - tarball and .desc already exist" + desc="$( cat $descfile )" + else + git checkout $tarcommit + ( cd $categ ; tar cvfz $tarball $prg ) + desc="$( grep "^$prg: " $catprg/slack-desc | head -n 1 | cut -d: -f2 )" + echo "$desc" > "$descfile" + git checkout master + fi +} + +p() { + echo "<p />" >> $OUTFILE.new +} + +br() { + echo "<br />" >> $OUTFILE.new +} + +htmlprint() { + echo "$@" | sed -e 's,<,%lt,g' -e 's,>,>,g' >> $OUTFILE.new +} + +print_report_line() { + local tarfile="$( basename $tarball )" + size="$( stat -c '%s' $tarball )" + if [ "$size" -ge 1024 ]; then + size="$(( size / 1024 ))K" + fi + echo "<a href=\"$tarfile\">$catprg</a> $size" >> $OUTFILE.new + br + htmlprint "$desc" ; br + htmlprint "$rm_log" ; br + htmlprint "$last_log" ; br + p +} + +get_all_removed() { + git log $DEBUG_LIMIT --pretty=oneline --grep="Removed" $START_COMMIT.. | \ + cut -d' ' -f2 | cut -d: -f1 | sort +} + +# main() +mkdir -p $OUTDIR $STATEDIR + +if [ -d "$TREE" ]; then + cd $TREE + git checkout master + git pull +else + rm -rf $TREE + git clone $CLONEURL $TREE + cd $TREE +fi + +removed=$( get_all_removed ) +total=$( echo $removed | wc -w ) +skipped=0 + +cat <<EOF >$OUTFILE.new +<html><head><title>SlackBuilds.org Removed Builds</title></head> +<!-- start of run: $( date ) --> +<body> +These are all the builds that have been removed from SlackBuilds.org +since the $SLACKVER repository was started (git tag $START_COMMIT). +<p /> +Note that this is purely a personal project of B. Watson +<a href="mailto:urchlay@slackware.uk"><urchlay@slackware.uk></a>. +It is NOT part of the SlackBuilds.org project or website. +<p /> +To search for a build, use your browser's "Search within page" feature +(commonly control-F or F3). +<p /> +Some of these builds were removed because they were broken or +nonfunctional (e.g. a client for a service that no longer exists). Others +were removed because they no longer had a maintainer, and got outdated. +If you find anything here that's useful, you can submit it to +SBo under your own name, after fixing any problems with it and/or +version-updating it. +<p /> +EOF + +count=0 +for i in $removed; do + : $(( count ++ )) + echo $count/$total: $i + get_log_lines $i + if [ -d "$catprg" ]; then + # If the dir exists, the build got re-added, skip it + : $(( skipped ++ )) + echo " -> skipped because $catprg exists" + continue + fi + mktarball + print_report_line +done + +cat <<EOF >>$OUTFILE.new +<p /> +Boneyard populated $( date ) with $(( total - skipped )) builds. +</body></html> +EOF + +mv $OUTFILE.new $OUTFILE + +echo +echo "If everything's OK:" +echo +echo "rsync -r -v -e ssh $OUTDIR sluk:/home/urchlay/public_html/html/boneyard/" + +# Tarball contents will be a regular SBo tarball. + +# Output should show... + +# category/build (<size>KB) category-build.tar.gz +# Removed YYYYMMDD (hash): log msg +# Last updated YYYYMMDD (hash): log msg + +# *Don't* show maintainer name/email. If someone wants to know, +# let them download the tarball. |
