From ef0238efafe8d6e76181c0a52d9becc9b993842a Mon Sep 17 00:00:00 2001 From: Willy Sudiarto Raharjo Date: Tue, 21 May 2024 07:33:00 +0700 Subject: [PATCH] Added support to sbosrcarch. Signed-off-by: Willy Sudiarto Raharjo --- README.md | 1 + src/usr/doc/THANKS | 1 + src/usr/sbin/sbopkg | 66 ++++++++++++++++++++++++++++++++++---- tools/ChangeLog-latest.txt | 4 ++- 4 files changed, 65 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index e2be91d..b5a972f 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,7 @@ Sbopkg will allow the user to: * View the README, SlackBuild, .info, and slack-desc files for each individual piece of software in the repository. * Copy the original .info file or SlackBuild for editing. * Automatically download the source code, check the md5sum, and build or build and install a Slackware package from either the original .info file and SlackBuild or the locally-edited copies. +* Download source code from the [SBo Source Archive](https://slackware.uk/sbosrcarch/) if the original URL no longer works. * Batch queue packages for building or building and installing. * Load, save, and use sbopkg [queuefiles](https://github.com/sbopkg/sbopkg/wiki/Queuefiles) (.sqf), several of which are included with the package. * View the contents of the cache directory (where source code tarballs are stored). diff --git a/src/usr/doc/THANKS b/src/usr/doc/THANKS index cfa9c13..9754d71 100644 --- a/src/usr/doc/THANKS +++ b/src/usr/doc/THANKS @@ -103,3 +103,4 @@ We moved to github, so revision number no longer used nobodino Benjamin Trigona-Harany ArTourter + Urchlay diff --git a/src/usr/sbin/sbopkg b/src/usr/sbin/sbopkg index fd88303..3d7e7b1 100755 --- a/src/usr/sbin/sbopkg +++ b/src/usr/sbin/sbopkg @@ -3011,10 +3011,11 @@ You can choose among the following options: - (Y)es, keep the source and continue the build process; - (N)o, delete the source and abort the build process; - (R)etry download and continue the build process; or - - (A)ttempt to download from third party source repository. + - (A)ttempt to download from the SBo Source Archive [default]. EOF - printf "(Y)es, (N)o, (R)etry, (A)lternative ?: " + printf "Your choice [y/n/r/A]: " error_read + echo case $REPLY in Y|y) MD5SUM=$(tr / _ <<< "$MD5CHK") @@ -3031,7 +3032,7 @@ EOF echo " Downloading again." | tee -a $TMPSUMMARYLOG return 1 ;; - A|a) + A|a|'') echo " Searching source repository." | tee -a $TMPSUMMARYLOG return 3 ;; @@ -3070,10 +3071,52 @@ check_cert_prompt() { done } +archive_prompt() { + # 20240326 bkw: this gets called if the download of the original URL fails, + # asks whether to try sbosrcarch. + # + # Parameters: none + # + # Return value: + # true (0) = user wants to try the archive + # false (1) = user doesn't want to try the archive + + local REPLY + + echo + crunch_fmt "$SCRIPT: Download failed. Source may be available in the archive." + echo + + while :; do + printf "Download the source from the SBo Source Archive? [Y/n]: " + error_read + echo + case $REPLY in + Y|y|'') echo " Searching source repository." | tee -a $TMPSUMMARYLOG + return 0 ;; + N|n) echo " Not searching source repository." | tee -a $TMPSUMMARYLOG + return 1 ;; + *) unknown_response ;; + esac + done +} + make_archive_url() { - # Get (and echo) the sbosrcarch URL for a source + # 20240326 bkw: Get (and echo) the sbosrcarch URL for a source. + # SRC_REPO gets set in the config file, but in case someone's got an + # old config, use a reasonable default (in fact, currently, the only + # possible setting is the default, nobody else is running a sbosrcarch + # instance AFAIK). + # + # Parameters: + # $1 = md5sum + # $2 = original download URL from .info file. + # + # Return value: + # void, but prints the URL (use $() to capture). + local MD5SUM=$1 - local SRCNAME=$2 + local SRCNAME="$( echo $2 | sed 's,.*/,,' )" local ARCHIVE=${SRC_REPO:-"http://slackware.uk/sbosrcarch"} echo $ARCHIVE/by-md5/${MD5SUM:0:1}/${MD5SUM:1:1}/$MD5SUM/$SRCNAME @@ -3123,6 +3166,12 @@ get_source() { done <<< $SRCNAME ) )" + # 20240326 bkw: SRCNAME[] sometimes contains "." instead of the + # actual filename, so don't pass it to make_archive_url; instead, + # make_archive_url takes the full URL and extracts the filename. + # We always construct this URL, even if we end up not using it. + ARCHIVEURL=$( make_archive_url ${MD5SUM[$i]} ${DOWNLOAD[$i]} ) + check_source $PKG ${MD5SUM[$i]} "${SRCNAME[$i]}" case $? in 0 ) # Source OK @@ -3137,7 +3186,7 @@ get_source() { break 2 ;; 3 ) # Archive - DOWNLOAD[$i]=$( make_archive_url ${MD5SUM[$i]} ${SRCNAME[$i]} ) + DOWNLOAD[$i]=$ARCHIVEURL ;; esac @@ -3168,6 +3217,11 @@ get_source() { if [[ $WGETRC == 5 && $TWGETFLAGS != *no-check-certificate* ]]; then check_cert_prompt && continue + elif [[ $WGETRC != 0 && ${DOWNLOAD[$i]} != $ARCHIVEURL ]]; then + if archive_prompt; then + DOWNLOAD[$i]=$ARCHIVEURL + continue + fi fi FAILURE=download echo " Download failed." >> $TMPSUMMARYLOG diff --git a/tools/ChangeLog-latest.txt b/tools/ChangeLog-latest.txt index 07bdf8c..35de234 100644 --- a/tools/ChangeLog-latest.txt +++ b/tools/ChangeLog-latest.txt @@ -1,12 +1,14 @@ SBOPKG NEWS -sbopkg-devel (2022-10-15 11:59 UTC) +sbopkg-devel (2024-05-21 00:31 UTC) MODIFICATIONS * Update renames * sqg: Fix repo detection when people switch from stable to master or vice versa Patch by Jeremy Hansen (#77) * sqg: Fix duplicate lines when executing custom queue (partial fix for #83) Reported by Jeremy Hansen + * sbopkg: Support download from sbosrcarch + Patch by Urchlay sbopkg 0.38.2 (2022-03-10 16:29 UTC) FEATURES