aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xtrunk/src/mkbuild113
1 files changed, 94 insertions, 19 deletions
diff --git a/trunk/src/mkbuild b/trunk/src/mkbuild
index 65a54db..b784acb 100755
--- a/trunk/src/mkbuild
+++ b/trunk/src/mkbuild
@@ -767,6 +767,19 @@ function file_metainfo {
return 1
fi
+ elif [ "$file_type" == "PATCH" ]; then
+
+ # Determine file location
+ get_patch_file $file
+
+ # Update Manifest metadata
+ if [ -e "$DOWNLOADED_PATCH_LOCATION" ]; then
+ file="$DOWNLOADED_PATCH_LOCATION"
+ else
+ echo "$file_type $dist_name " >> $manifest_file # end space is important
+ return 1
+ fi
+
else
echo "$file_type $dist_name " >> $manifest_file # end space is important
return 1
@@ -779,9 +792,9 @@ function file_metainfo {
echo $file_type $dist_name `file_size $file` $sum >> $manifest_file
- if [ "$file_type" == "DIST" ]; then
+ if [ "$file_type" == "DIST" ] || [ "$file_type" == "PATCH" ]; then
echo "Please make sure that the following hashes are correct:"
- grep -e "^DIST $DIST_SRC_NAME " $manifest_file
+ grep -e "^$file_type $dist_name " $manifest_file
fi
}
@@ -824,7 +837,7 @@ function update_manifest_info {
function edit_manifest {
# Update Manifest file
- verbose "Updating Manifest..."
+ echo "Updating Manifest..."
# Update mkbuild metainformation
update_manifest_info $WORK/$MKBUILD_NAME
@@ -849,6 +862,13 @@ function edit_manifest {
fi
done
+ # Update patches from URLs
+ for i in $PATCH_URLS; do
+ if ! grep -q -e "^PATCH `basename $i` " $WORK/Manifest; then
+ update_manifest_info $i patch
+ fi
+ done
+
# Update miscelaneous information
for i in `find $WORK | grep -E -v '(SlackBuild|old|slack-required|.mkbuild$|.tmp$|Manifest$)\*{0,1}$' | grep -v "/\.svn"`; do
if [ ! -d "$WORK/$i" ] && [ "`basename $i`" != "$DIST_SRC_NAME" ]; then
@@ -858,19 +878,33 @@ function edit_manifest {
}
-function get_dist_file {
+function get_file {
- # get package source code
- # usage: get_dist_file [file]
+ # download a file
+ # usage: download_file <file_type> <url> [file] [dist_name]
+
+ local folder folders path candidate
+ local file_type="`echo $1 | tr '[:lower:]' '[:upper:]'`"
+ local url="$2" file="$3" file_name="$4"
+ local protocol="`echo $url| cut -d : -f 1 | tr '[:upper:]' '[:lower:]'`"
+
+ if [ -z "$file_name" ]; then
+ if [ "$file_type" == "DIST" ]; then
+ file_name="$DIST_SRC_NAME"
+ else
+ file_name="`basename $url`"
+ fi
+ fi
- local folders path candidate file="$1"
- local protocol="`echo $URL | cut -d : -f 1 | tr '[:upper:]' '[:lower:]'`"
+ # Clean global var
+ DOWNLOADED_FILE_LOCATION=""
# Determine file location
if [ -d "$file" ]; then
- file="$DIST_SRC_NAME"
- for candidate in $(find $SOURCE_FILE -name $(basename $file)); do
+ folder="$file"
+ file="$file_name"
+ for candidate in $(find $folder -name $(basename $file)); do
if [ ! -z "$candidate" ]; then
break 2
fi
@@ -880,13 +914,13 @@ function get_dist_file {
echo "Using $(basename $candidate) found at $(dirname $candidate) to hash at the Manifest."
file="$candidate"
else
- echo "Can't find $file at $DIST_SRC_NAME."
+ echo "Can't find $file at $folder."
return 1
fi
elif [ -z "$file" ]; then
- file="$DIST_SRC_NAME"
+ file="$file_name"
folders="$WORK $TMP $SOURCE_DIR"
if ! is_the_same /tmp $TMP; then
folders="$folders /tmp"
@@ -900,7 +934,7 @@ function get_dist_file {
break 2
fi
done
- done
+ done
if [ ! -z "$candidate" ]; then
@@ -912,16 +946,17 @@ function get_dist_file {
[ "$protocol" == "ftp" ]; then
# Try to donwload the file
+ echo "File $file not found, trying to download it..."
if [ ! -e "$file" ]; then
if is_writable_folder $SOURCE_DIR/$PKG_NAME; then
- file="$SOURCE_DIR/$PKG_NAME/`basename $DIST_SRC_NAME`"
- wget "$URL" -O "$file"
+ file="$SOURCE_DIR/$PKG_NAME/`basename $file_name`"
+ wget "$url" -O "$file"
if [ "$?" != "0" ]; then
echo "Could not download $file"
return 1
fi
elif is_writable_folder $TMP; then
- file="$TMP/`basename $DIST_SRC_NAME`"
+ file="$TMP/`basename $file_name`"
if [ ! -e "$file" ]; then
wget "$URL" -O "$file"
if [ "$?" != "0" ]; then
@@ -930,7 +965,7 @@ function get_dist_file {
fi
fi
elif ! is_the_same /tmp $TMP; then
- file="/tmp/`basename $DIST_SRC_NAME`"
+ file="/tmp/`basename $file_name`"
if [ ! -e "$file" ]; then
wget "$URL" -O "$file"
if [ "$?" != "0" ]; then
@@ -946,7 +981,43 @@ function get_dist_file {
fi
fi
- DIST_SRC_LOCATION="$file"
+ if [ -e "$file" ]; then
+ DOWNLOADED_FILE_LOCATION="$file"
+ fi
+
+}
+
+function get_dist_file {
+
+ # get package source code
+ # usage: get_dist_file <url> [file_name]
+
+ DIST_SRC_LOCATION=""
+ get_file dist $URL
+ DIST_SRC_LOCATION="$DOWNLOADED_FILE_LOCATION"
+
+}
+
+function get_patch_file {
+
+ # get a patch
+ # usage: get_patch <file_name>
+
+ local patch_url file_name="$1"
+
+ if [ -z "$file_name" ]; then
+ return 1
+ fi
+
+ DOWNLOADED_PATCH_LOCATION=""
+
+ for patch_url in $PATCH_URLS; do
+ if [ "`basename $file_name`" == "`basename $patch_url`" ]; then
+ get_file patch $patch_url
+ DOWNLOADED_PATCH_LOCATION="$DOWNLOADED_FILE_LOCATION"
+ break
+ fi
+ done
}
@@ -964,7 +1035,7 @@ function update_manifest {
echo "Updating DIST information at $MKBUILD_NAME Manifest..."
# Determine file location
- get_dist_file
+ get_dist_file $SOURCE_FILE
# Update Manifest metadata
if [ -e "$DIST_SRC_LOCATION" ]; then
@@ -1132,6 +1203,10 @@ function get_mkbuild_values {
PATCH_FILES=`validate_parameter "$PATCH_FILES" "PATCH FILES" ""`
verbose "[[PATCH_FILES]]=\"$PATCH_FILES\""
+ # PATCH URLs
+ PATCH_URLS=`validate_parameter "$PATCH_URLS" "PATCH URLS" ""`
+ verbose "[[PATCH_URLS]]=\"$PATCH_URLS\""
+
# Strip the smallest prefix containing num leading slashes from each file name found in the patch file.
NPS_STRIP=`validate_parameter "$NPS_STRIP" "NUMBER OF PREFIX SLASHES TO STRIP" "1"`
verbose "[[NUMBER OF PREFIX SLASHES TO STRIP]]=\"$NPS_STRIP\""