Overhaul handling of source and patch entries during setup
* buildpkg.functions(get_source_filename, get_source_path, get_source_absfilename, fetch_source): Take a filename as input instead of an array index so they can be used for both source and patch entries * buildpkg.functions(unpack, patch): Updated to use new interface to above functions * buildpkg.packaging.irix(auto_rel, auto_src): Ditto. Also make sure to maintain timestamps when copying patches into the package * buildpkg.functions(get_files): New function to handle all downloading of sources and patches before unpacking
This commit is contained in:
parent
20a817e189
commit
f84b1dd660
@ -249,7 +249,7 @@ patch()
|
|||||||
if [ ! -z ${patch[$pnum]} ]; then # They didn't give us an empty string
|
if [ ! -z ${patch[$pnum]} ]; then # They didn't give us an empty string
|
||||||
if [ "${patch[$pnum]:0:1}" != "/" ]; then # We have a relative pathname
|
if [ "${patch[$pnum]:0:1}" != "/" ]; then # We have a relative pathname
|
||||||
# expand to absolute
|
# expand to absolute
|
||||||
patch[$pnum]=$patchdir/${patch[$pnum]}
|
patch[$pnum]=$(get_source_absfilename ${patch[$pnum]})
|
||||||
fi # We are now sure that $patch[$pnum] contains file with absolute path
|
fi # We are now sure that $patch[$pnum] contains file with absolute path
|
||||||
echo "Processing patch[$pnum] - ${patch[$pnum]}"
|
echo "Processing patch[$pnum] - ${patch[$pnum]}"
|
||||||
if [ -r ${patch[$pnum]} ]; then # file is readable
|
if [ -r ${patch[$pnum]} ]; then # file is readable
|
||||||
@ -266,11 +266,11 @@ patch()
|
|||||||
}
|
}
|
||||||
|
|
||||||
# get_source_filename(): Find filename for given sourceid
|
# get_source_filename(): Find filename for given sourceid
|
||||||
# params: $1 = source number (arrayindex)
|
# params: $1 = file to resolve (ie. source[x] or patch[x])
|
||||||
get_source_filename()
|
get_source_filename()
|
||||||
{
|
{
|
||||||
local snum=$1
|
local source=$1
|
||||||
local file="${source[$snum]##*/}" # Extract filename part
|
local file="${source##*/}" # Extract filename part
|
||||||
|
|
||||||
if [ -z "$file" ]; then
|
if [ -z "$file" ]; then
|
||||||
error $E_BAD_FILE get_source_filename
|
error $E_BAD_FILE get_source_filename
|
||||||
@ -280,13 +280,13 @@ get_source_filename()
|
|||||||
}
|
}
|
||||||
|
|
||||||
# get_source_path(): Find local path for given sourceid
|
# get_source_path(): Find local path for given sourceid
|
||||||
# params: $1 = source number (arrayindex)
|
# params: $1 = file to resolve (ie. source[x] or patch[x])
|
||||||
get_source_path()
|
get_source_path()
|
||||||
{
|
{
|
||||||
local snum=$1
|
local source=$1
|
||||||
local path_return=""
|
local path_return=""
|
||||||
local path="${source[$snum]%/*}" # Extract path part
|
local path="${source%/*}" # Extract path part
|
||||||
local file=$(get_source_filename $snum) # Extract filename part
|
local file=$(get_source_filename "$source") # Extract filename part
|
||||||
|
|
||||||
if [ -n "$path" ]; then
|
if [ -n "$path" ]; then
|
||||||
# We have a path component, could be relative, url or abs path
|
# We have a path component, could be relative, url or abs path
|
||||||
@ -317,13 +317,13 @@ get_source_path()
|
|||||||
}
|
}
|
||||||
|
|
||||||
# get_source_absfilename(): Wrapper for get_source_filename and get_source_path
|
# get_source_absfilename(): Wrapper for get_source_filename and get_source_path
|
||||||
# params: $1 = source number (arrayindex)
|
# params: $1 = file to resolve (ie. source[x] or patch[x])
|
||||||
# Note this wrapper will exit with $E_BAD_FILE if the absolute filename is not
|
# Note this wrapper will exit with $E_BAD_FILE if the absolute filename is not
|
||||||
# readable
|
# readable
|
||||||
get_source_absfilename()
|
get_source_absfilename()
|
||||||
{
|
{
|
||||||
local snum=$1
|
local source=$1
|
||||||
local absfilename="$(get_source_path $snum)/$(get_source_filename $1)"
|
local absfilename="$(get_source_path "$source")/$(get_source_filename $1)"
|
||||||
if [ -r "$absfilename" ]; then
|
if [ -r "$absfilename" ]; then
|
||||||
echo "$absfilename"
|
echo "$absfilename"
|
||||||
else
|
else
|
||||||
@ -333,30 +333,53 @@ get_source_absfilename()
|
|||||||
}
|
}
|
||||||
|
|
||||||
# fetch_source(): Fetch a sourcefile from an url
|
# fetch_source(): Fetch a sourcefile from an url
|
||||||
# params: $1 = source number (arrayindex)
|
# params: $1 = URL to fetch
|
||||||
fetch_source()
|
fetch_source()
|
||||||
{
|
{
|
||||||
local snum=$1
|
local url=$1
|
||||||
local file=$(get_source_filename $snum)
|
local file=$(get_source_filename "$url")
|
||||||
local path=$(get_source_path $snum)
|
local path=$(get_source_path "$url")
|
||||||
|
|
||||||
if [ ! -r "$path/$file" ]; then
|
if [ ! -r "$path/$file" ]; then
|
||||||
echo "fetch_source: Downloading ${source[$snum]}"
|
echo "fetch_source: Downloading $url"
|
||||||
if [ -x ${__curl} ]; then
|
if [ -x ${__curl} ]; then
|
||||||
${__curl} -# -L --retry 2 -C - -o $srcfiles/$file "${source[$snum]}"
|
${__curl} -# -L --retry 2 -C - -o $srcfiles/$file "$url"
|
||||||
else
|
else
|
||||||
error $E_MISSING_EXE fetch_source
|
error $E_MISSING_EXE fetch_source
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# get_files(): Fetch source files and patches from URLs
|
||||||
|
# params: none
|
||||||
|
# Any source or patch entries with URL's will be processed and downloaded
|
||||||
|
# as necessary.
|
||||||
|
get_files()
|
||||||
|
{
|
||||||
|
local numsource=${#source[@]}
|
||||||
|
local numpatch=${#patch[@]}
|
||||||
|
local source
|
||||||
|
local array
|
||||||
|
local counter
|
||||||
|
|
||||||
|
local idx=0
|
||||||
|
let counter=$numsource+$numpatch
|
||||||
|
array=( ${source[@]} ${patch[@]} )
|
||||||
|
while [ $idx -lt ${counter} ]
|
||||||
|
do
|
||||||
|
source=${array[$idx]}
|
||||||
|
[ -n "$(echo $source | grep '://')" ] && fetch_source $source
|
||||||
|
let idx=idx+1
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
# unpack(): Unpack source
|
# unpack(): Unpack source
|
||||||
# params: $1 = source number (arrayindex)
|
# params: $1 = source number (arrayindex)
|
||||||
# It will detect filetype and unpack
|
# It will detect filetype and unpack
|
||||||
# .tar, .tgz, .gz, .bz2, zip and .Z supported
|
# .tar, .tgz, .gz, .bz2, zip and .Z supported
|
||||||
unpack()
|
unpack()
|
||||||
{
|
{
|
||||||
local snum=$1
|
local source=${source[$1]}
|
||||||
local filename
|
local filename
|
||||||
local suffix
|
local suffix
|
||||||
local absfile
|
local absfile
|
||||||
@ -365,17 +388,17 @@ unpack()
|
|||||||
|
|
||||||
# If source contains an URL then first
|
# If source contains an URL then first
|
||||||
# download the file to $srcfiles
|
# download the file to $srcfiles
|
||||||
if [ -n "$(echo ${source[$snum]} | grep '://')" ]; then
|
if [ -n "$(echo $source | grep '://')" ]; then
|
||||||
# Yep it's an url
|
# Yep it's an url
|
||||||
fetch_source $snum
|
fetch_source "$source"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
filename="$(get_source_filename $snum)"
|
filename="$(get_source_filename "$source")"
|
||||||
suffix=${filename##*.} # Strip down to filename suffix (strip down to the last .)
|
suffix=${filename##*.} # Strip down to filename suffix (strip down to the last .)
|
||||||
echo "Unpacking $filename"
|
echo "Unpacking $filename"
|
||||||
# Note observe order here, since get_source_absfilename can exit with $E_BAD_FILE this
|
# Note observe order here, since get_source_absfilename can exit with $E_BAD_FILE this
|
||||||
# provides context for resolving!
|
# provides context for resolving!
|
||||||
absfile="$(get_source_absfilename $snum)"
|
absfile="$(get_source_absfilename "$source")"
|
||||||
# Catch any badness from the get_source function stack
|
# Catch any badness from the get_source function stack
|
||||||
[ "$?" != "0" ] && error $E_BAD_FILE unpack
|
[ "$?" != "0" ] && error $E_BAD_FILE unpack
|
||||||
# Determine filetype and unpack
|
# Determine filetype and unpack
|
||||||
@ -707,6 +730,11 @@ compute_octal()
|
|||||||
generic_prep()
|
generic_prep()
|
||||||
{
|
{
|
||||||
clean source
|
clean source
|
||||||
|
|
||||||
|
# Sweep ${#source[@]} and ${#patch[@]} for URL's and download any files
|
||||||
|
# needed
|
||||||
|
get_files
|
||||||
|
|
||||||
unpack 0
|
unpack 0
|
||||||
|
|
||||||
# Verify that ${patch[$pnum]} is defined
|
# Verify that ${patch[$pnum]} is defined
|
||||||
|
@ -967,11 +967,11 @@ auto_src()
|
|||||||
if [ ! -z ${patch[$pnum]} ]; then # They didn't give us an empty string
|
if [ ! -z ${patch[$pnum]} ]; then # They didn't give us an empty string
|
||||||
if [ "${patch[$pnum]:0:1}" != "/" ]; then # We have a relative pathname
|
if [ "${patch[$pnum]:0:1}" != "/" ]; then # We have a relative pathname
|
||||||
# expand to absolute
|
# expand to absolute
|
||||||
patch[$pnum]=$patchdir/${patch[$pnum]}
|
patch[$pnum]=$(get_source_absfilename ${patch[$pnum]})
|
||||||
fi # We are now sure that $patch[$pnum] contains file with absolute path
|
fi # We are now sure that $patch[$pnum] contains file with absolute path
|
||||||
if [ -r ${patch[$pnum]} ]; then # file is readable
|
if [ -r ${patch[$pnum]} ]; then # file is readable
|
||||||
echo "Copying patch[$pnum] - ${patch[$pnum]}"
|
echo "Copying patch[$pnum] - ${patch[$pnum]}"
|
||||||
${__cp} ${patch[$pnum]} $distsrcdir
|
${__cp} -p ${patch[$pnum]} $distsrcdir
|
||||||
else
|
else
|
||||||
error $E_BAD_FILE patch
|
error $E_BAD_FILE patch
|
||||||
fi
|
fi
|
||||||
@ -987,8 +987,8 @@ auto_src()
|
|||||||
local snum=0
|
local snum=0
|
||||||
for ((snum=0; $snum < $numsource; snum++))
|
for ((snum=0; $snum < $numsource; snum++))
|
||||||
do
|
do
|
||||||
local absfile=$(get_source_absfilename $snum)
|
local absfile=$(get_source_absfilename ${source[$snum]})
|
||||||
${__cp} $absfilename $distsrcdir
|
${__cp} -p $absfilename $distsrcdir
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@ -1088,8 +1088,8 @@ auto_rel()
|
|||||||
local temp_source_sha1sum=""
|
local temp_source_sha1sum=""
|
||||||
for ((snum=0; $snum < ${#source[@]}; snum++))
|
for ((snum=0; $snum < ${#source[@]}; snum++))
|
||||||
do
|
do
|
||||||
path="$(get_source_path $snum)"
|
path="$(get_source_path ${source[$snum]})"
|
||||||
file="$(get_source_filename $snum)"
|
file="$(get_source_filename ${source[$snum]})"
|
||||||
(cd "$path"; ${__sha1sum} "$file") >> $metadir/sums
|
(cd "$path"; ${__sha1sum} "$file") >> $metadir/sums
|
||||||
done
|
done
|
||||||
[ -r "$metadir/sums" ] && temp_source_sha1sum="$(cat $metadir/sums | ${__awk} '{ printf "%s\\n",$0 }')"
|
[ -r "$metadir/sums" ] && temp_source_sha1sum="$(cat $metadir/sums | ${__awk} '{ printf "%s\\n",$0 }')"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user