aboutsummaryrefslogtreecommitdiff
path: root/trunk/src
diff options
context:
space:
mode:
authorrhatto <rhatto@04377dda-e619-0410-9926-eae83683ac58>2008-12-23 21:24:11 +0000
committerrhatto <rhatto@04377dda-e619-0410-9926-eae83683ac58>2008-12-23 21:24:11 +0000
commit5c7d3944cda03a29ae6349ec4bd058e405c3b8f4 (patch)
tree37edd861a5388d07f9e6b06b64c5e1d8c70412b4 /trunk/src
parent9a8f7b53cefff0a1282d32112fcf353d06cb6d5c (diff)
downloadsimplepkg-5c7d3944cda03a29ae6349ec4bd058e405c3b8f4.tar.gz
simplepkg-5c7d3944cda03a29ae6349ec4bd058e405c3b8f4.tar.bz2
mkbuild: adding --update-manifest and other changes (see CHANGELOG)
git-svn-id: svn+slack://slack.fluxo.info/var/svn/simplepkg@707 04377dda-e619-0410-9926-eae83683ac58
Diffstat (limited to 'trunk/src')
-rw-r--r--trunk/src/createpkg23
-rwxr-xr-xtrunk/src/mkbuild187
-rwxr-xr-xtrunk/src/simplaret4
3 files changed, 185 insertions, 29 deletions
diff --git a/trunk/src/createpkg b/trunk/src/createpkg
index 325d120..09e38c1 100644
--- a/trunk/src/createpkg
+++ b/trunk/src/createpkg
@@ -257,6 +257,8 @@ function load_parameters {
SLACKBUILDS_SVN="`eval_parameter SLACKBUILDS_SVN http://slack.sarava.org/slackbuilds`"
SVN_USER="`eval_parameter PACKAGES_SVN_USER`"
SVN_GROUP="`eval_parameter PACKAGES_SVN_GROUP`"
+ SOURCE_DIR_USER="`eval_parameter SOURCE_DIR_USER`"
+ SOURCE_DIR_GROUP="`eval_parameter SOURCE_DIR_GROUP`"
COLOR_MODE="`eval_parameter COLOR_MODE none`"
CREATEPKG_ARCH="`eval_parameter CREATEPKG_ARCH $(default_arch)`"
@@ -267,11 +269,18 @@ function load_parameters {
SIGN_PACKAGES="`eval_boolean_parameter SIGN_PACKAGES $off`"
SIGN_PACKAGES_USER="`eval_parameter SIGN_PACKAGES_USER`"
SIGN_PACKAGES_KEYID="`eval_parameter SIGN_PACKAGES_KEYID`"
+ SIGN_PACKAGES_WITH_GPG_AGENT="`eval_boolean_parameter SIGN_PACKAGES_WITH_GPG_AGENT $off`"
if [ ! -z "$SIGN_PACKAGES_KEYID" ]; then
SIGN_PACKAGES_KEYID="`echo $SIGN_PACKAGES_KEYID | tr '[:lower:]' '[:upper:]'`"
fi
+ if [ "$SIGN_PACKAGES_WITH_GPG_AGENT" -eq $on ]; then
+ GPG_AGENT_OPTION="--use-agent"
+ else
+ GPG_AGENT_OPTION=""
+ fi
+
REMOVE_OLD_PACKAGE="`eval_boolean_parameter REMOVE_OLD_PACKAGE $off`"
MOVE_BIN_PACKAGE="`eval_boolean_parameter MOVE_BIN_PACKAGE $off`"
MOVE_SLACK_REQUIRED="`eval_boolean_parameter MOVE_SLACK_REQUIRED $off`"
@@ -676,6 +685,16 @@ cd $SCRIPT_BASE
# Check if package was built
handle_error $? $PACKAGE
+# Fix source folder user
+if [ ! -z "$SOURCE_DIR_USER" ]; then
+ chown -R $SOURCE_DIR_USER $SOURCE_DIR
+fi
+
+# Fix source folder group
+if [ ! -z "$SOURCE_DIR_GROUP" ]; then
+ chgrp -R $SOURCE_DIR_USER $SOURCE_DIR
+fi
+
# Get package name, arch, version and build number
PKG_NAME="`ls -1 -c $PACKAGES_DIR/$PACKAGE-*-*-*.tgz | head -n 1 | xargs basename`"
PACKAGE_NAME="`package_name $PKG_NAME`"
@@ -719,11 +738,11 @@ if [ $SIGN_PACKAGES -eq $on ]; then
if [ ! -z "$SIGN_PACKAGES_USER" ]; then
tmp_sign_folder="`mktemp -d $TMP/createpkg_sign.XXXXXX`"
chown $SIGN_PACKAGES_USER $tmp_sign_folder
- su $SIGN_PACKAGES_USER -c "gpg --use-agent --armor -sb -u $SIGN_KEYID -o $tmp_sign_folder/$PKG_NAME.asc $PACKAGES_DIR/$PKG_NAME"
+ su $SIGN_PACKAGES_USER -c "gpg $GPG_AGENT_OPTION --armor -sb -u $SIGN_KEYID -o $tmp_sign_folder/$PKG_NAME.asc $PACKAGES_DIR/$PKG_NAME"
cp $tmp_sign_folder/$PKG_NAME.asc $PACKAGES_DIR/$PKG_NAME.asc
rm -rf $tmp_sign_folder
else
- gpg --use-agent --armor -sb -u $SIGN_KEYID $PACKAGES_DIR/$PKG_NAME
+ gpg $GPG_AGENT_OPTION --armor -sb -u $SIGN_KEYID $PACKAGES_DIR/$PKG_NAME
fi
fi
diff --git a/trunk/src/mkbuild b/trunk/src/mkbuild
index 84120ff..f7566f5 100755
--- a/trunk/src/mkbuild
+++ b/trunk/src/mkbuild
@@ -164,6 +164,12 @@ function set_parameters {
ACTION="commit_all"
shift
;;
+ '-um'|'--update-manifest')
+ ACTION="update_manifest"
+ MKBUILD_NAME="${2//.mkbuild}.mkbuild"
+ SOURCE_FILE="$3"
+ shift 2
+ ;;
'-n'|'--new')
# New mkbuild configure file
MKBUILD_NAME="${2//.mkbuild}.mkbuild"
@@ -729,6 +735,7 @@ function file_metainfo {
local sum="" file="$1" file_type="`echo $2 | tr '[:lower:]' '[:upper:]'`"
local size algo candidate folders path manifest_file="$3"
+ local dist_name="`basename $file`"
if [ -d "$file" ]; then
return
@@ -741,30 +748,28 @@ function file_metainfo {
if [ ! -e "$file" ]; then
if [ "$file_type" == "DIST" ]; then
- folders="$WORK $TMP $SOURCE_DIR"
- if ! is_the_same /tmp $TMP; then
- folders="$folders /tmp"
+ # Add DIST information only if source is not under revision control
+ if [ $SVN_MOD -eq $on -o $GIT_MOD -eq $on ]; then
+ return
fi
- echo "Trying to find $(basename $file)) at $folders..."
+ # Force DIST file name at Manifest
+ dist_name="$DIST_SRC_NAME"
- for path in $folders; do
- candidate="$(find $path -name $(basename $file))"
- if [ ! -z "$candidate" ]; then
- break
- fi
- done
+ # Determine file location
+ get_dist_file
- if [ ! -z "$candidate" ]; then
- echo "Using $(basename $file) found at $(dirname $candidate) to hash at the Manifest."
- file="$candidate"
+ # Update Manifest metadata
+ if [ -e "$DIST_SRC_LOCATION" ]; then
+ file="$DIST_SRC_LOCATION"
+ echo "Using $(basename $file) found at $(dirname $file) to hash at the Manifest."
else
- echo "$file_type `basename $file` " >> $manifest_file # end space is important
+ echo "$file_type $dist_name " >> $manifest_file # end space is important
return 1
fi
else
- echo "$file_type `basename $file` " >> $manifest_file # end space is important
+ echo "$file_type $dist_name " >> $manifest_file # end space is important
return 1
fi
fi
@@ -773,7 +778,7 @@ function file_metainfo {
sum="$sum `echo $algo | tr '[:lower:]' '[:upper:]'` `gethash $algo $file`"
done
- echo $file_type `basename $file` `file_size $file` $sum >> $manifest_file
+ echo $file_type $dist_name `file_size $file` $sum >> $manifest_file
}
@@ -789,7 +794,7 @@ function update_manifest_info {
fi
# Update Manifest file
- if [ ! -e "`dirname $file`/Manifest" ]; then
+ if [ ! -e "$WORK/Manifest" ]; then
touch $WORK/Manifest
fi
@@ -797,7 +802,7 @@ function update_manifest_info {
tmpfile="`mktemp $TMP/mkbuild_manifest.XXXXXX`"
# Update metadata
- sed -e "/^$file_type `basename $file` /d" `dirname $file`/Manifest > $tmpfile
+ sed -e "/^$file_type `basename $file` /d" $WORK/Manifest > $tmpfile
file_metainfo $file $file_type $tmpfile
if [ "$?" != "0" ]; then
@@ -806,13 +811,13 @@ function update_manifest_info {
fi
# Save Manifest changes
- sort $tmpfile > `dirname $file`/Manifest
+ sort $tmpfile > $WORK/Manifest
rm -f $tmpfile
}
-function update_manifest {
+function edit_manifest {
# Update Manifest file
verbose "Updating Manifest..."
@@ -849,6 +854,127 @@ function update_manifest {
}
+function get_dist_file {
+
+ # get package source code
+ # usage: get_dist_file [file]
+
+ local folders path candidate file="$1"
+ local protocol="`echo $URL | cut -d : -f 1 | tr '[:upper:]' '[:lower:]'`"
+
+ # Determine file location
+ if [ -d "$file" ]; then
+
+ file="$DIST_SRC_NAME"
+ for candidate in $(find $SOURCE_FILE -name $(basename $file)); do
+ if [ ! -z "$candidate" ]; then
+ break 2
+ fi
+ done
+
+ if [ ! -z "$candidate" ]; then
+ 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."
+ return 1
+ fi
+
+ elif [ -z "$file" ]; then
+
+ file="$DIST_SRC_NAME"
+ folders="$WORK $TMP $SOURCE_DIR"
+ if ! is_the_same /tmp $TMP; then
+ folders="$folders /tmp"
+ fi
+
+ echo "Trying to find $(basename $file) at $folders..."
+
+ for path in $folders; do
+ for candidate in $(find $path -name $(basename $file)); do
+ if [ ! -z "$candidate" ]; then
+ break 2
+ fi
+ done
+ done
+
+ if [ ! -z "$candidate" ]; then
+
+ echo "Using $(basename $candidate) found at $(dirname $candidate) to hash at the Manifest."
+ file="$candidate"
+
+ elif [ "$protocol" == "https" ] || \
+ [ "$protocol" == "http" ] || \
+ [ "$protocol" == "ftp" ]; then
+
+ # TODO: config file parameter should control whether to donwload
+ # Try to donwload the file
+ 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"
+ if [ "$?" != "0" ]; then
+ echo "Could not download $file"
+ return 1
+ fi
+ elif is_writable_folder $TMP; then
+ file="$TMP/`basename $DIST_SRC_NAME`"
+ if [ ! -e "$file" ]; then
+ wget "$URL" -O "$file"
+ if [ "$?" != "0" ]; then
+ echo "Could not download $file"
+ return 1
+ fi
+ fi
+ elif ! is_the_same /tmp $TMP; then
+ file="/tmp/`basename $DIST_SRC_NAME`"
+ if [ ! -e "$file" ]; then
+ wget "$URL" -O "$file"
+ if [ "$?" != "0" ]; then
+ echo "Could not download $file"
+ return 1
+ fi
+ fi
+ else
+ echo "Could not download $file"
+ return 1
+ fi
+ fi
+ fi
+ fi
+
+ DIST_SRC_LOCATION="$file"
+
+}
+
+function update_manifest {
+
+ # Get mkbuild values
+ get_mkbuild_values
+
+ # Add DIST information only if source is not under revision control
+ if [ $SVN_MOD -eq $on -o $GIT_MOD -eq $on ]; then
+ echo "Source is under version control system, can't add hashes to Manifest."
+ return
+ fi
+
+ echo "Updating DIST information at $MKBUILD_NAME Manifest..."
+
+ # Determine file location
+ get_dist_file
+
+ # Update Manifest metadata
+ if [ -e "$DIST_SRC_LOCATION" ]; then
+ update_manifest_info $DIST_SRC_LOCATION dist
+ # TODO: that should appear also when adding DIST information at edit_manifest
+ echo "Please make sure that the following hashes are correct:"
+ grep -e "^DIST $DIST_SRC_NAME " $WORK/Manifest
+ else
+ echo "Can't get $DIST_SRC_NAME."
+ fi
+
+}
+
function if_previous_error {
if [ "$?" != "0" ]; then
@@ -859,13 +985,13 @@ function if_previous_error {
function verbose {
- if [ $VERBOSE -eq $on ]; then
- echo $*
- fi
+ if [ $VERBOSE -eq $on ]; then
+ echo $*
+ fi
}
-function make_slackbuild {
+function get_mkbuild_values {
# Get values
# Author name
@@ -1016,9 +1142,17 @@ function make_slackbuild {
SLACKBUILD_PATH=`get_slackbuild_path`
verbose "[[SLACKBUILD PATH]]=\"$SLACKBUILD_PATH\""
+}
+
+function make_slackbuild {
+
#--------------------------------------------------------------
#- Start build SlackBuild -
#--------------------------------------------------------------
+
+ # Get mkbuild values
+ get_mkbuild_values
+
verbose -e "\nStart SlackBuild make"
SLACKBUILD_TEMP=$SLACKBUILD.tmp
cp $MODEL_DIR/$MODEL $SLACKBUILD_TEMP
@@ -1059,7 +1193,7 @@ function make_slackbuild {
change_other_parameters
# Update Manifest file
- update_manifest
+ edit_manifest
# Commit SlackBuild
[ $SUBMIT_SLACKBUILD -eq $on ] && submit_slackbuild
@@ -1151,6 +1285,9 @@ set_parameters "$@"
verbose -e "$BASENAME version $PROG_VERSION\n"
if [ ! -z $MKBUILD_NAME ]; then
case $ACTION in
+ 'update_manifest')
+ update_manifest $*
+ ;;
'commit_slackbuild')
commit_changes $SLACKBUILDS_DIR $*
;;
diff --git a/trunk/src/simplaret b/trunk/src/simplaret
index 7edd92a..a1ffe2d 100755
--- a/trunk/src/simplaret
+++ b/trunk/src/simplaret
@@ -98,7 +98,7 @@ function simplaret_download {
local curl_timeout curl_passive_ftp curl_verbose
local ncftpget_timeout ncftpget_passive_ftp
- protocol="`echo $1 | cut -d : -f 1`"
+ protocol="`echo $1 | cut -d : -f 1 | tr '[:upper:]' '[:lower:]'`"
file="`basename $2`"
if [ ! -d "$3" ]; then
@@ -117,7 +117,7 @@ function simplaret_download {
echo ""
fi
- if [ "$protocol" == "http" ]; then
+ if [ "$protocol" == "http" ] || [ "$protocol" == "https" ]; then
echo Getting $1/$2:
if [ "$HTTP_TOOL" == "wget" ]; then