diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2020-01-14 09:20:58 -0700 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2020-01-14 09:20:58 -0700 |
commit | 2d0dca840b95edaaf45e17d7250ea16f12d51e41 (patch) | |
tree | 783d792df0fef1b49882908ebbd5cd1cc18db43b /scripts | |
parent | 639b9795c0ada8432f8b42a59509e654e1a2bc7b (diff) | |
download | dotfiles-2d0dca840b95edaaf45e17d7250ea16f12d51e41.tar.gz |
stop stowing lib/aid into homedir
It's pointless complexity, so far as I can tell right now.
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/README | 9 | ||||
-rwxr-xr-x | scripts/arizona/d2ldlrn | 22 | ||||
-rwxr-xr-x | scripts/arizona/mmg/lsumm | 15 | ||||
-rwxr-xr-x | scripts/debian/alioth-to-salsa | 23 | ||||
-rwxr-xr-x | scripts/debian/rebuild-rdeps | 34 | ||||
-rwxr-xr-x | scripts/web/goodreads_library_export.pl | 57 |
6 files changed, 160 insertions, 0 deletions
diff --git a/scripts/README b/scripts/README new file mode 100644 index 00000000..374de533 --- /dev/null +++ b/scripts/README @@ -0,0 +1,9 @@ +This is for helper scripts and programs that I don't want on PATH. +Shell pipelines, scripts for `git bisect`, and Perl one-liners turned +into files commencing `#!/usr/bin/perl -wnl`, are the sort of thing we +have in here. + +Loosely categorise the scripts, e.g. dgit/ might contain tools useful +when developing dgit. + +Note that repos other than ~/src/dotfiles might stow into ~/lib/aid. diff --git a/scripts/arizona/d2ldlrn b/scripts/arizona/d2ldlrn new file mode 100755 index 00000000..ad5b3302 --- /dev/null +++ b/scripts/arizona/d2ldlrn @@ -0,0 +1,22 @@ +#!/usr/bin/perl + +use 5.028; +use strict; +use warnings; + +die "you probably wanted to pass '*' as an additional command line argument\n" + if @ARGV == 0; + +for (@ARGV) { + my ($name, $ext) = + /\A[0-9]{6}-[0-9]{7} - ([^-]+)- [A-Z].+?\.([^.]+)\z/; + next unless defined $name and defined $ext; + + my $target = "$name.$ext"; + my $i = 2; + while (-e $target) { + $target = "$name-$i++.$ext"; + } + die "would overwrite $target" if -e $target; # check + rename $_, $target; +} diff --git a/scripts/arizona/mmg/lsumm b/scripts/arizona/mmg/lsumm new file mode 100755 index 00000000..3dee0ee6 --- /dev/null +++ b/scripts/arizona/mmg/lsumm @@ -0,0 +1,15 @@ +#!/usr/bin/perl -wl + +open my $fh, '<', '../Lecture summary.txt'; +chomp(my @summary = <$fh>); +for (glob "*") { + /^(.+)\.([a-z]+)$/; + next if $2 eq 'txt'; + my $txt = "$1.txt"; + open my $fh, '>', $txt; + print $fh $1; + print $fh ""; + print $fh $_ for @summary; + print $fh ""; + print $fh $1; +} diff --git a/scripts/debian/alioth-to-salsa b/scripts/debian/alioth-to-salsa new file mode 100755 index 00000000..e5bede91 --- /dev/null +++ b/scripts/debian/alioth-to-salsa @@ -0,0 +1,23 @@ +#!/bin/sh + +# original: http://www.df7cb.de/blog/2017/Salsa_batch_import.html +# example usage: alioth-to-salsa deft.git pkg-emacsen/pkg emacsen-team + +set -eux + + +PROJECT="${1%.git}" +DESCRIPTION="$PROJECT packaging" +ALIOTH_URL="https://anonscm.debian.org/git" +ALIOTH_GROUP="$2" +SALSA_GROUP="$3" +SALSA_URL="https://salsa.debian.org/api/v4" +SALSA_TOKEN=`cat ~/local/auth/salsa` +SALSA_NAMESPACE=$(curl $SALSA_URL/groups?private_token=$SALSA_TOKEN | jq ".[] | select(.path == \"$SALSA_GROUP\") | .id") + +curl -f "$SALSA_URL/projects?private_token=$SALSA_TOKEN" \ + --data "path=$PROJECT&namespace_id=$SALSA_NAMESPACE&description=$DESCRIPTION&import_url=$ALIOTH_URL/$ALIOTH_GROUP/$PROJECT&visibility=public" + +ssh alioth "~hertzog/bin/disable-repository /git/$ALIOTH_GROUP/$1 $SALSA_GROUP" + +git remote set-url origin salsa:$SALSA_GROUP/$PROJECT diff --git a/scripts/debian/rebuild-rdeps b/scripts/debian/rebuild-rdeps new file mode 100755 index 00000000..8dcbc7ef --- /dev/null +++ b/scripts/debian/rebuild-rdeps @@ -0,0 +1,34 @@ +#!/bin/sh + +us="$(basename $0)" + +# TODO apparently ratt (rebuild all the things) does this + +# first arg is root of dep tree. other args passed on to sbuild +# (e.g. --extra-package="$HOME/src/dh-elpa_1.0_all.deb" --add-depends="dh-elpa (>= 1.0)") +root="$1" +shift + +# ensure our sources are up-to-date +#sudo apt-get update + +# logs of failed builds will go here +mkdir -p $HOME/tmp +# need a temporary directory, as sbuild will download source packages +work=$(mktemp --tmpdir=$HOME/tmp -d ${us}XXXX) +( + cd $work + + build-rdeps --quiet $root | while read p; do + sbuild --no-apt-update --no-apt-upgrade --no-apt-distupgrade \ + --no-run-piuparts --no-run-lintian --no-run-autopkgtest \ + "$p" "$@" + if [ $? != 0 ]; then + echo "failed: $p" + mv ${p}_*Z.build $HOME/tmp + fi + done +) + +# clean up +rm -rf $work diff --git a/scripts/web/goodreads_library_export.pl b/scripts/web/goodreads_library_export.pl new file mode 100755 index 00000000..fd1a4f5a --- /dev/null +++ b/scripts/web/goodreads_library_export.pl @@ -0,0 +1,57 @@ +use 5.028; +use strict; +use warnings; + +use Text::CSV_XS qw(csv); + +open my $fh, ">:encoding(utf8)", "$ENV{HOME}/doc/org/goodreads_library_export.org"; +my $grle = csv( + in => "$ENV{HOME}/tmp/goodreads_library_export.csv", + headers => 'auto', + encoding => 'UTF-8' +); +my (@read, @to_read); +foreach my $gr (@$grle) { + my %book = ( + title => $gr->{Title}, + author => $gr->{Author}, + year => $gr->{'Original Publication Year'}, + tags => $gr->{Bookshelves} || undef, + rating => $gr->{'My Rating'}, + date_added => $gr->{'Date Added'} || undef, + date_read => $gr->{'Date Read'} || undef, + ); + if ($gr->{'Exclusive Shelf'} eq 'read') { + push @read, \%book; + } elsif ($gr->{'Exclusive Shelf'} eq 'to-read') { + push @to_read, \%book; + } +} + +# use Data::Dumper; +# print Dumper @read; +# print Dumper @to_read; + +say $fh "Warning: This file gets overwritten by a script!"; +say $fh "* To read"; +foreach my $to_read (@to_read) { + say $fh "** " . $to_read->{title} . " by " + . $to_read->{author} . " (" + . $to_read->{year} . ")"; +} +say $fh "* Read"; +foreach my $read (@read) { + say $fh "** " . $read->{title} . " by " + . $read->{author} . " (" + . $read->{year} . ")"; + say $fh "- rating :: " . $read->{rating}; + if (defined $read->{tags}) { + say $fh "- tags :: " . $read->{tags}; + } + if (defined $read->{date_added}) { + say $fh "- date added :: " . $read->{date_added}; + } + if (defined $read->{date_read}) { + say $fh "- date read :: " . $read->{date_read}; + } +} |