[sbopkg-users] Requesting to merge a feature : HTTP Support (in addition to Rsync and Git)

אסף אוחיון asaf.tvn at gmail.com
Sat Jan 4 23:40:21 UTC 2014


Hello

I've ported my old 'curl' patch to 0.37.0, attached to this message and
available also here:

https://github.com/asafo/sbopkg

I find it useful at least at one place of work where it easier to write
such a patch then to talk with the sysadmin

If there any further work needs to be done to make it into the upstream
just let me know

Thanks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://sbopkg.org/pipermail/sbopkg-users/attachments/20140105/cea1945e/attachment.html>
-------------- next part --------------
diff --git a/src/etc/sbopkg/repos.d/80-SBo-curl.repo b/src/etc/sbopkg/repos.d/80-SBo-curl.repo
new file mode 100644
index 0000000..2f43681
--- /dev/null
+++ b/src/etc/sbopkg/repos.d/80-SBo-curl.repo
@@ -0,0 +1,4 @@
+# DO NOT EDIT THIS FILE. CHANGES WILL BE OVERWRITTEN. See the README.
+# Repo Branch Description Tag Tool Link CheckGPG
+SBo-curl 14.1 "SBo HTTP repository for Slackware 14.1" _SBo curl http://slackbuilds.org/slackbuilds/14.1 GPG
+
diff --git a/src/usr/sbin/sbopkg b/src/usr/sbin/sbopkg
index 2ce0a01..d1e7816 100755
--- a/src/usr/sbin/sbopkg
+++ b/src/usr/sbin/sbopkg
@@ -222,7 +222,7 @@ load_repositories() {
             # Sanity checks
             # these two assignments work around a bash3-4 incompatibility
             local GPG='^GPG$|^$'
-            local RSYNC='^rsync$|^git$|^$'
+            local RSYNC='^rsync$|^git$|^curl$|^$'
             [[ ! ${TMPARRAY[6]} =~ $GPG ]] && ERROR="gpg"
             [[ ! ${TMPARRAY[4]} =~ $RSYNC ]] && ERROR="tool"
             [[ ${#TMPARRAY[@]} -ne $REPOS_FIELDS ]] && ERROR="fields"
@@ -1003,6 +1003,11 @@ checkout_rsync_branch() {
     REPO_DIR=$REPO_DIR/$REPO_BRANCH
 }
 
+checkout_curl_branch() {
+    REPO_DIR=$REPO_DIR/$REPO_BRANCH
+}
+
+
 checkout_git_branch() {
     # This function makes sure that in $REPO_DIR there's the currently
     # selected branch.
@@ -1072,7 +1077,7 @@ set_repo_vars() {
             REPO_GPG=${REPOSITORIES[$((i + 6))]}
             REPO_DIR=$REPO_ROOT/$REPO_NAME
 
-            if [[ $REPO_TOOL = "rsync" || $REPO_TOOL = "git" ]]; then
+            if [[ $REPO_TOOL = "rsync" || $REPO_TOOL = "git"  || $REPO_TOOL = "curl" ]]; then
                 checkout_${REPO_TOOL}_branch
             fi
 
@@ -2434,6 +2439,132 @@ git_command() {
     echo
 }
 
+curl_changelog_txt() {
+
+    curl --fail $REPO_LINK/ChangeLog.txt >  $SBOPKGTMP/ChangeLog.new
+    if [ ! $? -eq 0 ]; then
+            echo
+	    echo "The ChangeLog.txt file was not found"
+            echo "(The repo's LINK is currently set to: $REPO_LINK)."
+            echo "Please check your settings and try again later."
+            echo
+	    return 10
+    fi
+
+    diff $REPO_DIR/ChangeLog.txt $SBOPKGTMP/ChangeLog.new > $SBOPKGTMP/ChangeLog.diff
+
+    if [ $? -eq 0 ]; then
+	echo "No Updates"
+	return 0
+    fi
+
+    echo "Downloaded ChangeLog"
+    regexp="^> ([[:alnum:]]*)/([[:alnum:]]*):(.*)"
+    packages=""
+    while read line; do
+	if [[ "$line" =~ $regexp ]]; then
+	    packages="$packages ${BASH_REMATCH[2]}"
+	fi
+    done < $SBOPKGTMP/ChangeLog.diff
+
+    /bin/mv $REPO_DIR/SLACKBUILDS.TXT $SBOPKGTMP/SLACKBUILDS.TXT
+    curl_slackbuilds_txt "$packages"
+    /bin/mv $SBOPKGTMP/ChangeLog.new $REPO_DIR/ChangeLog.txt
+
+    return 0
+}
+
+# curl_sync_package $package_name $package_version $package_location
+#	    "$package_download" "$package_files"  $package_md5sum
+# "$package_shortdesc"
+curl_sync_package() {
+    echo -n "$1-$2..."
+    mkdir -p $REPO_DIR/$3
+    
+    curl  --fail --silent "$REPO_LINK/$3.tar.gz" > "$REPO_DIR/$3.tar.gz" \
+	|| return $?
+    category=$(echo $3 | cut -d'/' -f2)
+    cd $REPO_DIR/$category
+    tar xf "$1.tar.gz"
+
+    echo "Ok"
+}
+
+# curl_slackbuilds_txt - process SLACKBUILD.TXT to synchronize some or all
+# packages
+# curl_slackbuilds_txt packages
+curl_slackbuilds_txt() {
+
+    curl --fail $REPO_LINK/SLACKBUILDS.TXT.gz > \
+	$REPO_DIR/SLACKBUILDS.TXT.gz || return $?
+    gunzip $REPO_DIR/SLACKBUILDS.TXT.gz
+
+    regexp="SLACKBUILD[ ]*([[:alnum:]]*): (.*)"
+
+    while read line; do
+	if [[ $line =~ $regexp ]]; then	
+	    name=${BASH_REMATCH[1]}
+	    case $name in
+		"NAME" )
+		    if [[ "$package_name" ]]; then
+			if [ "$1" == "all" ]; then
+			    curl_sync_package $package_name $package_version $package_location \
+				"$package_download" "$package_files"  $package_md5sum "$package_shortdesc"
+			else
+			    for pkg_name in $1; do
+				if [ $pkg_name == $package_name ]; then
+				    curl_sync_package $package_name $package_version $package_location \
+					"$package_download" "$package_files"  $package_md5sum "$package_shortdesc"
+				fi
+			    done
+			fi
+		    fi
+		    package_name=${BASH_REMATCH[2]}
+		    ;;
+		"LOCATION" ) 
+		    package_location="${BASH_REMATCH[2]}"
+		    ;;
+		"FILES" )
+		    package_files="${BASH_REMATCH[2]}"
+		    ;;
+		"DOWNLOAD" )
+		    package_download="${BASH_REMATCH[2]}"
+		    ;;
+		"VERSION" ) 
+		    package_version="${BASH_REMATCH[2]}"
+		    ;;
+		"MD5SUM" ) 
+		    package_md5sum="${BASH_REMATCH[2]}"
+ 		    ;;
+		"SHORT DESCRIPTION" ) 
+		    package_shortdesc="${BASH_REMATCH[2]}"
+		    ;;
+		* ) 
+		    echo "unknown ${BASH_REMATCH[1]} : ${BASH_REMATCH[2]}"
+		    ;;
+	    esac
+	fi
+    done < $REPO_DIR/SLACKBUILDS.TXT
+    curl --fail $REPO_LINK/ChangeLog.txt >  $REPO_DIR/ChangeLog.txt
+}
+
+curl_command() {
+    local SYNC_LOCK=$SBOPKGTMP/sbopkg_sync.lck
+    local URL BRANCH CWD
+
+    if [ -f $REPO_DIR/ChangeLog.txt ]; then
+	curl_changelog_txt
+    else
+	curl_slackbuilds_txt "all"
+    fi
+
+    # All done
+    rm -f $SBOPKGTMP/sbopkg_sync.lck
+    echo
+    echo "Repository update complete."
+    echo
+}
+
 sync_repo() {
     # This function does the sync with SBo.
 
@@ -2448,7 +2579,7 @@ sync_repo() {
         fi
         continue
     fi
-    if [[ $REPO_TOOL != "rsync" && $REPO_TOOL != "git" ]]; then
+    if [[ $REPO_TOOL != "rsync" && $REPO_TOOL != "git" && $REPO_TOOL != "curl" ]]; then
         if [[ $DIAG ]]; then
             dialog --title "ERROR" --msgbox \
                 "Unsupported fetching tool \"$REPO_TOOL\"." 8 30


More information about the sbopkg-users mailing list