mirror of
https://github.com/sbopkg/sbopkg
synced 2025-01-19 10:26:56 +01:00
Add support for multiple source files and to x86_64.
This patch adds support for the new SBo 13.0 features, namely x86_64 support and the ability to specify more than one source tarball in the .info file. Signed-off-by: Mauro Giachero <mauro.giachero@gmail.com>
This commit is contained in:
parent
08e6246bf1
commit
1c3910e57e
2 changed files with 167 additions and 98 deletions
|
@ -113,4 +113,7 @@ enhancements:
|
||||||
* Add in 'uname -m' test for x86_64 and if so, set ARCH to x86_64.
|
* Add in 'uname -m' test for x86_64 and if so, set ARCH to x86_64.
|
||||||
* Set default SBo repo to 13.0; add 13.0 repo to
|
* Set default SBo repo to 13.0; add 13.0 repo to
|
||||||
/etc/sbopkg/repos.d/40-sbo.repo
|
/etc/sbopkg/repos.d/40-sbo.repo
|
||||||
|
* Add support for multiple architectures and multiple source files. This
|
||||||
|
makes sbopkg able to handle the new features that SlackBuilds.org admins
|
||||||
|
are preparing for the Slackware 13.0 release.
|
||||||
+--------------------------+
|
+--------------------------+
|
||||||
|
|
|
@ -2363,12 +2363,49 @@ show_readme() {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
read_info() {
|
||||||
|
# Read the info file specified in $1.
|
||||||
|
# This used to be a plain ". $INFO", but due to the changes required to
|
||||||
|
# support multiple arches and source files (both features are planned
|
||||||
|
# for the Slackware 13.0 release) it needs some more work.
|
||||||
|
# The DOWNLOAD and MD5SUM arrays will always contain the "right"
|
||||||
|
# (possibly ARCH-dependent) values.
|
||||||
|
|
||||||
|
local INFO=$1
|
||||||
|
local i DOWNLOAD_ARCH
|
||||||
|
local {DOWNLOAD,MD5SUM}_$ARCH
|
||||||
|
|
||||||
|
unset DOWNLOAD MD5SUM
|
||||||
|
|
||||||
|
# Parse the .info file
|
||||||
|
. $INFO
|
||||||
|
# Assign the proper entries to DOWNLOAD and MD5SUM.
|
||||||
|
DOWNLOAD_ARCH=$(eval echo \$DOWNLOAD_$ARCH)
|
||||||
|
if [[ -n $DOWNLOAD_ARCH ]]; then
|
||||||
|
DOWNLOAD=$DOWNLOAD_ARCH
|
||||||
|
MD5SUM=$(eval echo \$MD5SUM_$ARCH)
|
||||||
|
fi
|
||||||
|
# Note: on SBo pre-13.0 repositories, as well as on current non-SBo
|
||||||
|
# repositories, none of the above triggers. In that case, we use the
|
||||||
|
# provided DOWNLOAD and MD5SUM variables, which is exactly the old-style
|
||||||
|
# behavior.
|
||||||
|
|
||||||
|
# Convert the space-separated strings to arrays
|
||||||
|
DOWNLOAD=($DOWNLOAD)
|
||||||
|
MD5SUM=($MD5SUM)
|
||||||
|
}
|
||||||
|
|
||||||
get_source_names() {
|
get_source_names() {
|
||||||
# Echo the source names for an app, given the info file.
|
# Echo the source names for an app, given the info file.
|
||||||
# Usage: get_source_names [--all] info_file
|
# Usage: get_source_names [--all] [--placeholder] info_file
|
||||||
# --all try to find all source files (i.e. also the obsolete ones)
|
# --all try to find all source files (i.e. also the obsolete
|
||||||
|
# ones)
|
||||||
|
# --placeholder if no source file is found for a DOWNLOAD entry, a
|
||||||
|
# line containing "." is generated
|
||||||
|
# Note that even without --all this function can return multiple files,
|
||||||
|
# if the application specifies more than one in its .info file.
|
||||||
|
|
||||||
local SRCNAME INFO ALL CWD
|
local SRCNAME INFO ALL CWD DL PLACEHOLDER
|
||||||
# Don't pollute the environment with the .info content...
|
# Don't pollute the environment with the .info content...
|
||||||
local PRGNAM VERSION HOMEPAGE DOWNLOAD MD5SUM MAINTAINER EMAIL APPROVED
|
local PRGNAM VERSION HOMEPAGE DOWNLOAD MD5SUM MAINTAINER EMAIL APPROVED
|
||||||
|
|
||||||
|
@ -2376,21 +2413,28 @@ get_source_names() {
|
||||||
ALL=yes
|
ALL=yes
|
||||||
shift
|
shift
|
||||||
fi
|
fi
|
||||||
INFO="$1"
|
if [[ $1 == "--placeholder" ]]; then
|
||||||
|
PLACEHOLDER="."
|
||||||
|
shift
|
||||||
|
fi
|
||||||
|
INFO=$1
|
||||||
|
|
||||||
. $INFO
|
read_info $INFO
|
||||||
SRCNAME=${DOWNLOAD##*/}
|
for DL in "${DOWNLOAD[@]}"; do
|
||||||
# Replace URI hex sequences (like %20 for ' ' and %2B for '+') with their
|
SRCNAME=${DL##*/}
|
||||||
# corresponding characters.
|
# Replace URI hex sequences (like %20 for ' ' and %2B for '+') with
|
||||||
# This is done replacing '%' with '\x' and passing the string to printf.
|
# their corresponding characters.
|
||||||
|
# This is done replacing '%' with '\x' and passing the string to
|
||||||
|
# printf.
|
||||||
if [[ $SRCNAME =~ % ]]; then
|
if [[ $SRCNAME =~ % ]]; then
|
||||||
SRCNAME=$(printf ${SRCNAME//\%/\\x})
|
SRCNAME=$(printf ${SRCNAME//\%/\\x})
|
||||||
fi
|
fi
|
||||||
# The above doesn't work when the download link doesn't reference the file
|
# The above doesn't work when the download link doesn't reference the
|
||||||
# name explicitly. If this is the case, all we can do is guessing...
|
# file name explicitly. If this is the case, all we can do is
|
||||||
|
# guessing...
|
||||||
if [[ ! $SRCNAME ]]; then
|
if [[ ! $SRCNAME ]]; then
|
||||||
# If the source has a name resembling $PRGNAM-$VERSION.tar.gz, catch
|
# If the source has a name resembling $PRGNAM-$VERSION.tar.gz,
|
||||||
# it.
|
# catch it.
|
||||||
CWD=$(pwd)
|
CWD=$(pwd)
|
||||||
cd $SRCDIR
|
cd $SRCDIR
|
||||||
SRCNAME=$(find . -iname $PRGNAM\*$VERSION.\* | head -n 1)
|
SRCNAME=$(find . -iname $PRGNAM\*$VERSION.\* | head -n 1)
|
||||||
|
@ -2403,18 +2447,19 @@ get_source_names() {
|
||||||
|
|
||||||
# If the user asked for "all" sources, let's try to find similar names
|
# If the user asked for "all" sources, let's try to find similar names
|
||||||
if [[ $ALL ]]; then
|
if [[ $ALL ]]; then
|
||||||
# The following is based on the idea that the source name contains the
|
# The following is based on the idea that the source name contains
|
||||||
# version number. The expression below takes the parts before and
|
# the version number. The expression below takes the parts before
|
||||||
# after the version number, and replaces the version number with a
|
# and after the version number, and replaces the version number
|
||||||
# regular expression matching and digit and any character present in
|
# with a regular expression matching and digit and any character
|
||||||
# the known version number (this is to match odd version numbers
|
# present in the known version number (this is to match odd
|
||||||
# containing letters, like "svn1234", but makes it less likely to
|
# version numbers containing letters, like "svn1234", but makes it
|
||||||
# match different packages with similar names, like virtualbox-kernel
|
# less likely to match different packages with similar names, like
|
||||||
# and virtualbox-kernel-addons)
|
# virtualbox-kernel and virtualbox-kernel-addons)
|
||||||
SRCNAME=${SRCNAME%%$VERSION*}[0-9$VERSION]\*${SRCNAME##*$VERSION}
|
SRCNAME=${SRCNAME%%$VERSION*}[0-9$VERSION]\*${SRCNAME##*$VERSION}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ls -A $SRCDIR | grep "^${SRCNAME##*/}"
|
ls -A $SRCDIR | grep "^${SRCNAME##*/}" || echo $PLACEHOLDER
|
||||||
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
check_source() {
|
check_source() {
|
||||||
|
@ -2437,16 +2482,14 @@ check_source() {
|
||||||
[[ -z $SRCNAME || ! -f $SRCDIR/$SRCNAME ]] && return 1
|
[[ -z $SRCNAME || ! -f $SRCDIR/$SRCNAME ]] && return 1
|
||||||
|
|
||||||
# Check MD5
|
# Check MD5
|
||||||
echo "Checking MD5SUM for \"$SRCNAME\"..."
|
echo -n " Checking MD5SUM for \"$SRCNAME\"... " | tee -a $TMPSUMMARYLOG
|
||||||
MD5CHK=$(md5sum "$SRCDIR/$SRCNAME" | cut -d' ' -f1)
|
MD5CHK=$(md5sum "$SRCDIR/$SRCNAME" | cut -d' ' -f1)
|
||||||
echo | tee -a $TMPSUMMARYLOG
|
|
||||||
echo "$PKG:" | tee -a $TMPSUMMARYLOG
|
|
||||||
if [[ $MD5CHK == $MD5SUM ]]; then
|
if [[ $MD5CHK == $MD5SUM ]]; then
|
||||||
echo "MD5SUM check passed." | tee -a $TMPSUMMARYLOG
|
echo "passed." | tee -a $TMPSUMMARYLOG
|
||||||
else
|
else
|
||||||
echo "MD5SUM check failed!" | tee -a $TMPSUMMARYLOG
|
echo "failed!" | tee -a $TMPSUMMARYLOG
|
||||||
echo "Expected: $MD5SUM" | tee -a $TMPSUMMARYLOG
|
echo " Expected: $MD5SUM" | tee -a $TMPSUMMARYLOG
|
||||||
echo "Found: $MD5CHK" | tee -a $TMPSUMMARYLOG
|
echo " Found: $MD5CHK" | tee -a $TMPSUMMARYLOG
|
||||||
# Ask the user what to do with the bad source
|
# Ask the user what to do with the bad source
|
||||||
while :; do
|
while :; do
|
||||||
cat << EOF
|
cat << EOF
|
||||||
|
@ -2464,21 +2507,21 @@ EOF
|
||||||
case $ANS in
|
case $ANS in
|
||||||
y* | Y* )
|
y* | Y* )
|
||||||
MD5SUM=$(tr / _ <<< "$MD5CHK")
|
MD5SUM=$(tr / _ <<< "$MD5CHK")
|
||||||
echo "Keeping the source and continuing." |
|
echo " Keeping the source and continuing." |
|
||||||
tee -a $TMPSUMMARYLOG
|
tee -a $TMPSUMMARYLOG
|
||||||
return 0
|
return 0
|
||||||
;;
|
;;
|
||||||
n* | N* )
|
n* | N* )
|
||||||
rm -f "$SRCDIR/$SRCNAME"
|
rm -f "$SRCDIR/$SRCNAME"
|
||||||
echo "Source deleted." | tee -a $TMPSUMMARYLOG
|
echo " Source deleted." | tee -a $TMPSUMMARYLOG
|
||||||
return 2
|
return 2
|
||||||
;;
|
;;
|
||||||
r* | R* )
|
r* | R* )
|
||||||
echo "Downloading again." | tee -a $TMPSUMMARYLOG
|
echo " Downloading again." | tee -a $TMPSUMMARYLOG
|
||||||
return 1
|
return 1
|
||||||
;;
|
;;
|
||||||
* )
|
* )
|
||||||
echo "Unknown response."
|
echo " Unknown response."
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
@ -2498,57 +2541,77 @@ get_source() {
|
||||||
# 1 = failed, continue queue processing
|
# 1 = failed, continue queue processing
|
||||||
# 2 = failed, stop queue processing
|
# 2 = failed, stop queue processing
|
||||||
|
|
||||||
local INFO="$1"
|
local INFO=$1
|
||||||
local PKG=$(sed 's:\.info.*$::g' <<< $INFO)
|
local PKG=$(sed 's:\.info.*$::g' <<< $INFO)
|
||||||
local BUILD_LOCK=$SBOPKGTMP/sbopkg_build.lck
|
local BUILD_LOCK=$SBOPKGTMP/sbopkg_build.lck
|
||||||
local DLDIR=$SBOPKGTMP/sbopkg-download
|
local DLDIR=$SBOPKGTMP/sbopkg-download
|
||||||
local PIDLIST=$SBOPKGTMP/sbopkgpidlist
|
local PIDLIST=$SBOPKGTMP/sbopkgpidlist
|
||||||
local TMPSUMMARYLOG=$SBOPKGTMP/sbopkg-tmp-summarylog
|
local TMPSUMMARYLOG=$SBOPKGTMP/sbopkg-tmp-summarylog
|
||||||
local SRCNAME DL FAILURE ANS MD5CHK
|
local SRCNAME DL_SRCNAME DL FAILURE ANS MD5CHK i CWD
|
||||||
# Don't pollute the environment with the .info content...
|
# Don't pollute the environment with the .info content...
|
||||||
local PRGNAM VERSION HOMEPAGE DOWNLOAD MD5SUM MAINTAINER EMAIL APPROVED
|
local PRGNAM VERSION HOMEPAGE DOWNLOAD MD5SUM MAINTAINER EMAIL APPROVED
|
||||||
|
|
||||||
. "$INFO"
|
CWD=$(pwd)
|
||||||
SRCNAME=$(get_source_names "$INFO")
|
read_info $INFO
|
||||||
|
|
||||||
|
echo | tee -a $TMPSUMMARYLOG
|
||||||
|
echo "$PKG:" | tee -a $TMPSUMMARYLOG
|
||||||
|
for i in ${!MD5SUM[@]}; do
|
||||||
while :; do
|
while :; do
|
||||||
check_source $PKG $MD5SUM $SRCNAME
|
cd "$CWD"
|
||||||
|
SRCNAME=$(get_source_names --placeholder $INFO)
|
||||||
|
|
||||||
|
# Put SRCNAME lines into array elements.
|
||||||
|
# This is a little bit involved since it has to deal with spaces
|
||||||
|
# inside file names.
|
||||||
|
# We know that we could obtain the same result faster by mangling
|
||||||
|
# with IFS, but the resulting code was a bit too hacky.
|
||||||
|
eval SRCNAME=( $(
|
||||||
|
while read LINE; do
|
||||||
|
printf '%q ' "$LINE"
|
||||||
|
done <<< "$SRCNAME"
|
||||||
|
) )
|
||||||
|
|
||||||
|
check_source $PKG ${MD5SUM[$i]} "${SRCNAME[$i]}"
|
||||||
case $? in
|
case $? in
|
||||||
0 ) # Source OK
|
0 ) # Source OK
|
||||||
break
|
rm -f "$REPO_DIR/$PKGPATH/${SRCNAME[$i]}"
|
||||||
|
ln -s "$SRCDIR/${SRCNAME[$i]}" \
|
||||||
|
"$REPO_DIR/$PKGPATH/${SRCNAME[$i]}"
|
||||||
|
continue 2
|
||||||
;;
|
;;
|
||||||
2 ) # Abort
|
2 ) # Abort
|
||||||
FAILURE=download
|
FAILURE=download
|
||||||
break
|
break 2
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
mkdir -p $DLDIR
|
mkdir -p $DLDIR
|
||||||
cd $DLDIR
|
cd $DLDIR
|
||||||
wget $WGETFLAGS $DOWNLOAD >> $SBOPKGOUTPUT & echo "$!" >> \
|
wget $WGETFLAGS ${DOWNLOAD[$i]} >> $SBOPKGOUTPUT & echo "$!" >> \
|
||||||
$PIDLIST 2>> $SBOPKGOUTPUT
|
$PIDLIST 2>> $SBOPKGOUTPUT
|
||||||
wait
|
wait
|
||||||
# Source filename corrections for Virtualbox, where '?e=foo' gets
|
# Source filename corrections for Virtualbox, where '?e=foo' gets
|
||||||
# appended to the filename and for calcurse, where a 'foo?' gets
|
# appended to the filename and for calcurse, where a 'foo?' gets
|
||||||
# prepended to the filename
|
# prepended to the filename
|
||||||
DL=$(ls -A . 2> /dev/null)
|
DL=$(ls -A . 2> /dev/null)
|
||||||
SRCNAME=$(sed 's/?e=.*$//;s/^.*?//' <<< "$DL")
|
DL_SRCNAME=$(sed 's/?e=.*$//;s/^.*?//' <<< "$DL")
|
||||||
if [[ $SRCNAME ]]; then
|
if [[ $DL_SRCNAME ]]; then
|
||||||
mv "$DL" "$SRCDIR/$SRCNAME"
|
mv "$DL" "$SRCDIR/$DL_SRCNAME"
|
||||||
else
|
else
|
||||||
FAILURE=download
|
FAILURE=download
|
||||||
echo >> $TMPSUMMARYLOG
|
echo " Download failed." >> $TMPSUMMARYLOG
|
||||||
echo "$PKG:" >> $TMPSUMMARYLOG
|
|
||||||
echo "Download failed." >> $TMPSUMMARYLOG
|
|
||||||
echo >> $TMPSUMMARYLOG
|
echo >> $TMPSUMMARYLOG
|
||||||
fi
|
fi
|
||||||
|
rm -f $REPO_DIR/$PKGPATH/"$DL_SRCNAME"
|
||||||
cd $SRCDIR
|
cd $SRCDIR
|
||||||
rm -rf $DLDIR
|
rm -rf $DLDIR
|
||||||
[[ $FAILURE ]] && break
|
[[ $FAILURE ]] && break 2
|
||||||
|
ln -s "$SRCDIR/$DL_SRCNAME" "$REPO_DIR/$PKGPATH/$DL_SRCNAME"
|
||||||
|
done
|
||||||
done
|
done
|
||||||
|
|
||||||
cd $REPO_DIR/$PKGPATH
|
cd $REPO_DIR/$PKGPATH
|
||||||
rm -f "$SRCNAME"
|
|
||||||
|
|
||||||
if [[ $FAILURE ]]; then
|
if [[ $FAILURE ]]; then
|
||||||
rm -f $PKG.{info,SlackBuild}.build
|
rm -f $PKG.{info,SlackBuild}.build
|
||||||
|
@ -2569,8 +2632,6 @@ get_source() {
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
return 2
|
return 2
|
||||||
else
|
|
||||||
ln -s "$SRCDIR/$SRCNAME" "$SRCNAME"
|
|
||||||
fi
|
fi
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
@ -2612,10 +2673,12 @@ remove_obsoleted_sources() {
|
||||||
# Bail out if the user pressed ESC
|
# Bail out if the user pressed ESC
|
||||||
progressbar_interrupted && touch $PROGRESSBAR_INTERRUPTED && break
|
progressbar_interrupted && touch $PROGRESSBAR_INTERRUPTED && break
|
||||||
|
|
||||||
APP_CURRSRC=$(get_source_names "$INFO")
|
# Reading get_source_names output...
|
||||||
|
while read APP_CURRSRC; do
|
||||||
if [[ $APP_CURRSRC ]]; then
|
if [[ $APP_CURRSRC ]]; then
|
||||||
REGEX="/^$APP_CURRSRC$/d;$REGEX"
|
REGEX="/^$APP_CURRSRC$/d;$REGEX"
|
||||||
fi
|
fi
|
||||||
|
done < <(get_source_names "$INFO")
|
||||||
|
|
||||||
# Progress indicator, for the progressbar
|
# Progress indicator, for the progressbar
|
||||||
(( PROGRESS += 1 ))
|
(( PROGRESS += 1 ))
|
||||||
|
@ -2845,7 +2908,6 @@ build_package() {
|
||||||
BUILDOPTIONS=$(< options.build)
|
BUILDOPTIONS=$(< options.build)
|
||||||
[[ $BUILDOPTIONS ]] && eval "export $BUILDOPTIONS"
|
[[ $BUILDOPTIONS ]] && eval "export $BUILDOPTIONS"
|
||||||
fi
|
fi
|
||||||
[[ $(uname -m) == "x86_64" ]] && export ARCH=${ARCH:-x86_64}
|
|
||||||
export OUTPUT=$SB_OUTPUT
|
export OUTPUT=$SB_OUTPUT
|
||||||
nice sh $PKGNAME.SlackBuild.build
|
nice sh $PKGNAME.SlackBuild.build
|
||||||
)
|
)
|
||||||
|
@ -2858,8 +2920,7 @@ build_package() {
|
||||||
# Let's see the result
|
# Let's see the result
|
||||||
cd $SB_OUTPUT
|
cd $SB_OUTPUT
|
||||||
if [ ! -f *.t?z ]; then
|
if [ ! -f *.t?z ]; then
|
||||||
echo "$PKGNAME:" >> $TMPSUMMARYLOG
|
echo " Error occurred with build. Please check the log." \
|
||||||
echo "Error occurred with build. Please check the log." \
|
|
||||||
>> $TMPSUMMARYLOG
|
>> $TMPSUMMARYLOG
|
||||||
echo
|
echo
|
||||||
echo "Would you like to continue processing the rest of the"
|
echo "Would you like to continue processing the rest of the"
|
||||||
|
@ -3101,7 +3162,7 @@ use_options() {
|
||||||
dialog --title "Build options" --menu "$(crunch "One or \
|
dialog --title "Build options" --menu "$(crunch "One or \
|
||||||
more build option files for the $OPTAPP \
|
more build option files for the $OPTAPP \
|
||||||
SlackBuild were found. Please choose which you \
|
SlackBuild were found. Please choose which you \
|
||||||
would like to use.")" 12 50 7 \
|
would like to use.")" 12 50 3 \
|
||||||
--file $OPTLIST 2> $OPTCHOICE
|
--file $OPTLIST 2> $OPTCHOICE
|
||||||
CHOICE=$?
|
CHOICE=$?
|
||||||
if [[ $CHOICE != 0 ]]; then
|
if [[ $CHOICE != 0 ]]; then
|
||||||
|
@ -3280,7 +3341,7 @@ process_queue() {
|
||||||
rm -f $PKGPATH/$CHKBUILD*.build
|
rm -f $PKGPATH/$CHKBUILD*.build
|
||||||
return 0
|
return 0
|
||||||
else
|
else
|
||||||
. $PKGPATH/$CHKBUILD.info.build
|
read_info $PKGPATH/$CHKBUILD.info.build
|
||||||
echo "Using $PICKFILE .info file" >> $TMPLOG-files
|
echo "Using $PICKFILE .info file" >> $TMPLOG-files
|
||||||
fi
|
fi
|
||||||
if ! pick_file SlackBuild $PKGPATH $CHKBUILD; then
|
if ! pick_file SlackBuild $PKGPATH $CHKBUILD; then
|
||||||
|
@ -3890,6 +3951,11 @@ if [[ $(id -u) != 0 ]]; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Set up ARCH
|
||||||
|
if [[ ! $(uname -m) =~ 'i.86' ]]; then
|
||||||
|
export ARCH=${ARCH:-$(uname -m)}
|
||||||
|
fi
|
||||||
|
|
||||||
# This is the command line options and help.
|
# This is the command line options and help.
|
||||||
while getopts ":b:cd:e:f:g:hi:lopqrs:uv:" OPT; do
|
while getopts ":b:cd:e:f:g:hi:lopqrs:uv:" OPT; do
|
||||||
case $OPT in
|
case $OPT in
|
||||||
|
|
Loading…
Reference in a new issue