diff options
author | B. Watson <yalhcru@gmail.com> | 2020-06-10 19:42:04 -0400 |
---|---|---|
committer | B. Watson <yalhcru@gmail.com> | 2020-06-10 19:42:04 -0400 |
commit | c3238e690a1f3254d282623e047f0124206de9b9 (patch) | |
tree | aad4069d37a258d2d641fef67abd7a3317fde111 | |
parent | fdab64c728d172419b3cc3f8a566a3fd134ab366 (diff) | |
download | sbostuff-c3238e690a1f3254d282623e047f0124206de9b9.tar.gz |
cleanup, wip for eventual release
-rw-r--r-- | README | 4 | ||||
-rwxr-xr-x | checkpkg | 44 | ||||
-rwxr-xr-x | mkslackinfo | 10 | ||||
-rwxr-xr-x | sbolint | 83 | ||||
-rwxr-xr-x | sbonewmaint | 38 | ||||
-rw-r--r-- | sbostuff.cfg | 15 | ||||
-rw-r--r-- | sbostuff.sh | 102 | ||||
-rwxr-xr-x | sboul | 4 | ||||
-rwxr-xr-x | sbrun | 4 | ||||
-rwxr-xr-x | slackpkgdiff (renamed from pkgdiff) | 10 | ||||
-rwxr-xr-x | upkg | 21 |
11 files changed, 316 insertions, 19 deletions
@@ -1,13 +1,16 @@ sbostuff - Miscellaneous tools for working with SlackBuild.org (SBo) build scripts. Included tools: +checkpkg - check that an installed package's files are still present mkslackdesc - make a valid slack-desc from a README mkslackinfo - generate .info and template SlackBuild sbodeps - generate a queue file based on .info file contents sbodl - download the sources (from the .info file) +sbofindsrc - search for missing source files in various archives sbofixdesc - try to fix malformed slack-desc files sbofixinfo - try to fix malformed .info files sbolint - examine a SBo tarball or dir, look for common errors +sbonewmaint - change MAINTAINER and EMAIL in .info file sbosearch - search local SBo repo sboul - submit slackbuild tarballs to SBo, from command line sbrename - rename a build @@ -15,6 +18,7 @@ sbrun - run a build, with filesystem tracking and without network sbosrc - simple client script for sbosrcarch archives sbosrcarch - create/maintain an archive of SBo sources sbofindsrc - attempt to find missing SBo sources +slackpkgdiff - compare contents of 2 Slackware packages without installing them upkg - .info file aware wrapper for "upgradepkg --reinstall --install-new" Most scripts support a --help option. Further documentation will be in diff --git a/checkpkg b/checkpkg new file mode 100755 index 0000000..b596e72 --- /dev/null +++ b/checkpkg @@ -0,0 +1,44 @@ +#!/bin/sh + +# check one or more package lists from /var/log/packages to see if the +# files listed there actually exist on the filesystem. +# ROOT variable is respected, same as installpkg. +# .new config files are checked for without their .new ending. +# known issue: any file whose name has a colon in it, won't be checked. + +# exit status of this script will be 0 for OK, non-zero if one or +# more file was missing. +exitstatus=0 + +# package filenames are ASCII, this will speed things up slightly. +LANG="C" +LC_ALL="C" +export LANG LC_ALL + +check_pkg() { + if [ ! -e "$1" ]; then + echo "$0: $1 not found" 1>&2 + exitstatus=1 + return + fi + + grep -v -e ":" -e "^install" "$1" | sed 's,\.new$,,' > "$tmpfile" + + ( while read line; do + [ -e "$ROOT"/"$line" ] || ( exitstatus=1 && echo "$1: missing $line" ) + done ) < "$tmpfile" +} + +if [ -z "$*" -o "$1" = "--help" ]; then + cat <<EOF +Usage: $0 [ package-list-file(s) ] +EOF + exit 0 +fi + +for pkg in "$@"; do + tmpfile="$( mktemp -t checkpkg.XXXXXX )" + check_pkg "$pkg" + rm -f "$tmpfile" +done +exit $exitstatus diff --git a/mkslackinfo b/mkslackinfo index db11244..c4d99ce 100755 --- a/mkslackinfo +++ b/mkslackinfo @@ -1,18 +1,20 @@ #!/usr/bin/perl -w -# Create a SB.o compliant .info file +# Create a SBo compliant .info file # (and a .SlackBuild from a template, if one doesn't already exist, # and a slack-desc if a README exists) +($SELF = $0) =~ s,.*/,,; + # Fill in your name and email address here: -$name = 'B. Watson'; -$email = 'yalhcru@gmail.com'; +$name = $ENV{SBO_NAME} || die "$SELF: please source ~/.sbostuff.cfg"; +$email = $ENV{SBO_EMAIL} || die "$SELF: please source ~/.sbostuff.cfg"; use LWP::Simple; use Digest::MD5 'md5_hex'; sub usage { - die "usage: mkslackinfo url [homepage] [version]\n"; + die "usage: $SELF url [homepage] [version]\n"; } $url = shift || &usage; @@ -2,6 +2,9 @@ # ChangeLog: +# 0.3 20200420 bkw: +# - Check github URLs for validity. + # 0.2 20200103 bkw: # - Use "git rev-parse" to decide if we're in a git repo, because # "git status" traverses the whole repo looking for untracked files. @@ -19,7 +22,7 @@ # 0.1 20141114 bkw, Initial release. -$VERSION="0.2"; +$VERSION="0.3"; # generate man page with: # pod2man --stderr -r0.2 -s1 -c"SBo Maintainer Tools" sbolint > sbolint.1 @@ -300,6 +303,8 @@ $tempdir = 0; our %info = (); # has to be global, check_info sets it, check_script needs it # main() { +#check_github_url("testing", $_) for @ARGV; +#exit 0; while(@ARGV && ($ARGV[0] =~ /^-/)) { my $opt = shift; @@ -842,7 +847,7 @@ sub check_info { # use a HEAD request for homepage, even if downloading other files if($url_head || $url_download) { - curl_head_request($info{HOMEPAGE}) || do { + curl_head_request($file, $info{HOMEPAGE}) || do { log_warning("$file: HOMEPAGE URL broken?"); }; } @@ -877,17 +882,19 @@ sub check_dl_and_md5 { log_error("$file: we have " . @dlurls . " $dlkey URLs but " . @md5s . " $md5key" . " values"); } - for(@dlurls) { - if(!check_url($_)) { - log_error("$file: $dlkey URL '$_' doesn't look like a valid URL (http, https, or ftp)"); + for my $u (@dlurls) { + if(!check_url($u)) { + log_error("$file: $dlkey URL '$u' doesn't look like a valid URL (http, https, or ftp)"); + next; } + #check_github_url($file, $u); + if($url_head) { - for(@dlurls) { - curl_head_request($_) || do { - log_warning("$file: $dlkey URL '$_' broken?"); - }; - } + curl_head_request($file, $u) || do { + warn '$u is '. $u; + log_warning("$file: $dlkey URL '$u' broken?"); + }; } elsif($url_download) { warn "$SELF: -d option not yet implemented\n"; } @@ -912,9 +919,63 @@ sub check_url { } sub curl_head_request { - return !system("curl --head --location --silent --fail $_[0] >/dev/null"); + #return !system("curl --head --location --silent --fail $_[0] >/dev/null"); + #warn $_[1]; + my $file = $_[0]; + my $client_filename = $_[1]; + $client_filename =~ s,.*/,,; + my $curlcmd = "curl -m20 --head --location --silent --fail $_[1]"; + open my $pipe, "$curlcmd|"; + #warn "$curlcmd"; + while(<$pipe>) { + chomp; + s/\r//; + if(/^content-disposition:\s+attachment;\s+filename=["']?(.*?)["']?$/i) { + #warn $1; + if(defined($client_filename) && ($client_filename ne $1)) { + log_warning("$file: download filename varies based on content disposition: '$1' vs. '$client_filename'"); + } + } + } + return close($pipe); } +# WIP, maybe no longer needed +## sub check_github_url { +## my $file = shift; +## my $url = shift; +## return unless $url =~ m{(https?:)//github\.com}; +## +## if($1 eq "http:") { +## log_warning("$file: github URL $url should be https"); +## } +## +## (my $expect_filename = $url) =~ s,.*/,,; +## my(undef, undef, undef, $user, $prog, $archive, $ver, $filename) = split /\//, $url; +## warn "user $user, prog $prog, archive $archive, ver $ver, filename $filename, expect_filename $expect_filename\n"; +## +## # assume these are correct, for now +## return if $user eq 'downloads'; +## return if $archive eq 'releases'; +## +## # TODO: work out what to do about /raw/ +## return if $archive eq 'raw'; +## +## if($archive ne 'archive') { +## log_warning("$file: unknown github URL type: $url"); +## return; +## } +## +## # OK, good URLs look like this: +## # https://github.com/jeetsukumaran/DendroPy/archive/v4.4.0/DendroPy-4.4.0.tar.gz +## # ...and bad ones look like this: +## # https://github.com/haiwen/seafile-client/archive/v4.4.2.tar.gz +## # Corrected version of the bad one would be: +## # https://github.com/haiwen/seafile-client/archive/v4.4.2/seafile-client-4.4.2.tar.gz +## # Notice the "v" isn't part of the version number. It's not always there, +## # and sometimes it's a different letter (r, or g, or capital V, etc). +## } + # NOT going to police the script too much. Would end up rewriting most of # the shell, in perl. Plus, it'd become a straitjacket. Here's what I'll # implement: diff --git a/sbonewmaint b/sbonewmaint new file mode 100755 index 0000000..189bc23 --- /dev/null +++ b/sbonewmaint @@ -0,0 +1,38 @@ +#!/bin/sh + +if [ -e ~/.sbostuff.cfg ]; then + source ~/.sbostuff.cfg +else + echo "$( basename $0 ): warning: can't find ~/.sbostuff.cfg" +fi + +NAME="$1" +EMAIL="$2" + +if [ "$NAME" = "me" -a "$EMAIL" = "" ]; then + NAME="$SBO_NAME" + EMAIL="$SBO_EMAIL" +elif [ "$NAME" = "nobody" -o "$NAME" = "orphaned" ]; then + NAME="orphaned - no maintainer" + EMAIL="nobody@nowhere.com" +fi + +if [ "$NAME" = "" -o "$NAME" = "--help" -o "$EMAIL" = "" ]; then + echo "Usage: $( basename $0 ) 'Full Name' email@domain.com" 1>&2 + echo " $( basename $0 ) me" 1>&2 + echo " $( basename $0 ) nobody" 1>&2 + exit 1 +fi + +INFO="$( echo *.info )" +if [ ! -e "$INFO" ]; then + echo "No (or multiple) .info file in current dir" 1>&2 + exit 1 +fi + +sed -i "/^MAINTAINER=/s,\"[^\"]*\",\"$NAME\"," "$INFO" +sed -i "/^EMAIL=/s,\"[^\"]*\",\"$EMAIL\"," "$INFO" + +PAGER=cat git diff . + +echo "git commit -a -m'New maintainer'" diff --git a/sbostuff.cfg b/sbostuff.cfg new file mode 100644 index 0000000..31cfdf1 --- /dev/null +++ b/sbostuff.cfg @@ -0,0 +1,15 @@ +# Config file for sbostuff. Copy to ~/.sbostuff.cfg and edit as needed. + +# Your "real" name (as seen in MAINTAINER= in .info files) +SBO_NAME="Your Name" + +# Your email address (as seen in .info files; obfuscate if you want) +SBO_EMAIL="user@domain.com" + +# Root of git tree (clone of git.slackbuilds.org:slackbuilds.git) +SBO_GITROOT=~/slackbuilds + +# Your branch, where you push changes if you're a committer. Something +# like users/yourname/updates, usually. If you're not a committer, +# just pick something you like here, or maybe use master. +SBO_GITBRANCH="users/yourname/updates" diff --git a/sbostuff.sh b/sbostuff.sh new file mode 100644 index 0000000..bd40a24 --- /dev/null +++ b/sbostuff.sh @@ -0,0 +1,102 @@ +# sbostuff.sh + +# bash functions for sbostuff. And I do mean *bash*: I don't know a +# completely portable way to write this stuff, and I don't use other +# shells. Patches accepted, if you're really motivated to make this +# work in your favorite shell. + +# Source this file from your ~/.bashrc or similar: +# source /path/to/sbostuff/functions.sh +# ...or place this file in /etc/profile.d/ with +x permission. + +if [ -e ~/.sbostuff.cfg ]; then + source ~/.sbostuff.cfg +else + echo "sbostuff: No ~/.sbostuff.cfg, please create one." +fi + +_run_editor() { + local editor + if [ -n "$VISUAL" ]; then + editor="$VISUAL" + elif [ -n "$EDITOR" ]; then + editor="$EDITOR" + else + editor="vim" + fi + eval "$editor" $@ +} + +visl() { + local file + local editor_opts + + case "$1" in + -h|--help) + cat <<EOF +visl - edit the .SlackBuild, .info, README, and slack-desc in the + current directory. + +Usage: visl <opts> + +The editor used is controlled by environment variables. If VISUAL +is set, it's used as the editor. Otherwise, if EDITOR is set, it's +used. If neither are set, the default is "vim". + +If given, <opts> are passed to the editor as options. +EOF + return 0 ;; + *) editor_opts="$@" ;; + esac + + file="$( basename "$( pwd )" )".SlackBuild + [ ! -e "$file" ] && file="*.SlackBuild" + _run_editor $editor_opts "$file" "${file/SlackBuild/info}" README slack-desc "$@" +} + +_cdsbexp() { + /bin/ls -d1 "$@" 2>/dev/null | grep -v /local/ | head -1 +} + +cdsb() { + # FIXME: get from config file + local dir + local oldshopt + + case "$1" in + -h|--help) + cat <<EOF +cdsb - change directory to a SlackBuild. + +Usage: cdsb <build> + +With no <build> argument, changes to the root of the SBo tree. + +<build> may be a complete build name (with or without a category), or a +partial name, which will be matched case-insensitively. +EOF + return 0 ;; + --) shift ;; + -*) echo "cdsb: unknown option $1" ; return 1 ;; + esac + + # temporarily do case-insensitive globbing + oldshopt="$( shopt -p nocaseglob )" + shopt -s nocaseglob + + if [ -d $SBO_GITROOT/$1 ]; then + # category/prgnam (exact) + cd $SBO_GITROOT/$1 + elif [ -d "$( _cdsbexp $SBO_GITROOT/*/$1)" ]; then + # prgnam without category (exact) + cd "$( _cdsbexp $SBO_GITROOT/*/$1)" + else + echo "cdsb: no exact match, guessing dir" 1>&2 + dir="$( _cdsbexp $SBO_GITROOT/*/$1* )" + [ -z "$dir" ] && dir="$( _cdsbexp $SBO_GITROOT/*/*$1* )" + [ -n "$dir" ] && cd "$dir" || echo "cdsb: no match" 1>&2 + fi + + eval $oldshopt +} + @@ -93,8 +93,8 @@ getopts('c:e:C:k:', \%opts); die_usage("Unknown junk on command line: '$junk'") if $junk; die_usage("No category (missing required -c arg)") unless $opts{c}; $category = get_category($opts{c}); -chomp($submail = $opts{e} || `head -n1 ~/.sbo_email`); -die_usage("No email address (use -e or else create ~/.sbo_email)") unless $submail; +chomp($submail = $opts{e} || $ENV{SBO_EMAIL} +die_usage("No email address (use -e or else create ~/.sbostuff.cfg)") unless $submail; $comments = $opts{C} || ""; $tags = $opts{k} || ""; @@ -1,5 +1,9 @@ #!/bin/bash +# TODO: distcc masquerade dir, pump mode +# TODO: fix interactive shell option +# TODO: maybe change the cpufreq governor? + # Configurables: TMP=${TMP:-/tmp/SBo} @@ -3,6 +3,13 @@ # compare filenames in 2 tarballs, except /usr/doc/blah-<version> dirs # get treated specially. +if [ "$1" = "--help" ]; then + cat <<EOF +slackpkgdiff - compare contents of 2 Slackware packages without installing them +Usage: slackpkgdiff pkg1 pkg2 +EOF +fi + pkg_name() { echo "$1" | sed 's,.*/,,' | sed 's,\.[^.]*$,,' } @@ -13,9 +20,10 @@ list_tar() { } DIR=/tmp/pkgdiff.$RANDOM.$$ -echo $DIR mkdir -p $DIR || exit 1 list_tar "$1" list_tar "$2" diff $DIR/$( pkg_name "$1" ) $DIR/$( pkg_name "$2" ) +ret="$?" rm -rf $DIR +return "$ret" @@ -1,5 +1,24 @@ #!/bin/bash +if [ "$1" = "--help" ]; then +cat <<EOF +upkg - upgrade/install/reinstall a Slackware package. + +Usage: upkg <package> [<package> ...] + +<package> is an installable Slackware package (.tgz, etc). + +If no <package> given, the .info and SlackBuild in the current directory +are parsed to get a package filename. If this package exists, it will +be installed. + +Actual package installation is done with: + +upgradepkg --reinstall --install-new <package> +EOF +exit 0 +fi + die() { echo "$( basename $0 ): $@" 1>&2 exit 1 @@ -64,4 +83,4 @@ if [ -z "$@" ]; then set "$found" fi -sudo upgradepkg --reinstall --install-new "$@" +sudo /sbin/upgradepkg --reinstall --install-new "$@" |