aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrhatto <rhatto@04377dda-e619-0410-9926-eae83683ac58>2008-12-20 17:47:07 +0000
committerrhatto <rhatto@04377dda-e619-0410-9926-eae83683ac58>2008-12-20 17:47:07 +0000
commit9215fde72daf22e6f1098e914571ac79017c91e5 (patch)
tree369566c8b4cc844ffe8e249b6b89833c8be8d692
parent410130aedd6a73b9cc1f021dcd336bd5c6cb16d4 (diff)
downloadsimplepkg-9215fde72daf22e6f1098e914571ac79017c91e5.tar.gz
simplepkg-9215fde72daf22e6f1098e914571ac79017c91e5.tar.bz2
adding initial support for Manifest files
git-svn-id: svn+slack://slack.fluxo.info/var/svn/simplepkg@691 04377dda-e619-0410-9926-eae83683ac58
-rw-r--r--trunk/conf/simplepkg.conf2
-rw-r--r--trunk/lib/common.sh56
-rw-r--r--trunk/mkbuild/generic.mkSlackBuild49
-rw-r--r--trunk/mkbuild/model.mkbuild1
-rw-r--r--trunk/src/createpkg1
-rwxr-xr-xtrunk/src/mkbuild90
6 files changed, 196 insertions, 3 deletions
diff --git a/trunk/conf/simplepkg.conf b/trunk/conf/simplepkg.conf
index 7460707..8554f52 100644
--- a/trunk/conf/simplepkg.conf
+++ b/trunk/conf/simplepkg.conf
@@ -19,7 +19,7 @@
# DEFAULT_VERSION="12.2"
# Temporary folder
-TMP="/tmp"
+TMP="/tmp/simplepkg"
#---------------------------------------------------------------------
# MKBUILD AND CREATEPKG SECTION
diff --git a/trunk/lib/common.sh b/trunk/lib/common.sh
index a6f82bc..58cffb2 100644
--- a/trunk/lib/common.sh
+++ b/trunk/lib/common.sh
@@ -1186,6 +1186,7 @@ function error_codes {
ERROR_PATCH=40 # patch error
ERROR_VCS=41 # cvs error
ERROR_MKDIR=42 # make directory error
+ ERROR_MANIFEST=43 # manifest error
# Slackbuilds error codes ** not change **
# Commum error codes
@@ -1256,6 +1257,8 @@ function handle_error {
eecho $error "$BASENAME: error downloading $2 source from version control system" ;;
$ERROR_MKDIR)
eecho $error "$BASENAME: make directory $2 error, aborting" ;;
+ $ERROR_MANIFEST)
+ eecho $error "$BASENAME: problem with Manifest file, aborting" ;;
#
# General errors
@@ -1413,7 +1416,7 @@ function is_the_same {
function check_gnupg {
- # check if there's a keyring
+ # setup gnupg keyring if needed
# usage: check_gnupg [username]
local user="$1" home
@@ -1433,6 +1436,57 @@ function check_gnupg {
}
+function rmd160sum {
+
+ # computes RIPEMD-160 message digest
+ # usage: rmd160sum <file>
+
+ local sum file="$1"
+
+ if [ ! -e "$file" ]; then
+ return 1
+ fi
+
+ sum="`openssl rmd160 $file | awk '{ print $2 }'`"
+ echo "$sum $file"
+
+}
+
+function gethash {
+
+ # get a file's hash
+ # usage: gethash <algorithm> <file>
+
+ if [ ! -e "$2" ]; then
+ return 1
+ fi
+
+ $1sum $file | awk '{ print $1 }'
+
+}
+
+function file_size {
+
+ # get file size
+ # usage: filesize <file>
+
+ if [ ! -e "$1" ]; then
+ return 1
+ fi
+
+ wc -c $file | awk '{ print $1 }'
+
+}
+
+function file_extension {
+
+ # output file extension
+ # usage: filesize <filename>
+
+ echo $1 | sed -e 's/.*\.\(.*\)$/\1/'
+
+}
+
function check_installed {
# checks if a package is installed
diff --git a/trunk/mkbuild/generic.mkSlackBuild b/trunk/mkbuild/generic.mkSlackBuild
index 8cccbb2..a9173e8 100644
--- a/trunk/mkbuild/generic.mkSlackBuild
+++ b/trunk/mkbuild/generic.mkSlackBuild
@@ -81,6 +81,7 @@ ERROR_WGET=31; ERROR_MAKE=32; ERROR_INSTALL=33
ERROR_MD5=34; ERROR_CONF=35; ERROR_HELP=36
ERROR_TAR=37; ERROR_MKPKG=38; ERROR_GPG=39
ERROR_PATCH=40; ERROR_VCS=41; ERROR_MKDIR=42
+ERROR_MANIFEST=43;
</error_codes>
<start_structure> off
@@ -161,6 +162,7 @@ cd "$PKG_SRC"
</git_source>
<md5sum_check> off
+# MD5 checksum
MD5SUM_URL="[[MD5SUM CODE]]"
if [ ${#MD5SUM_URL} -eq 32 ]; then
@@ -263,6 +265,53 @@ if echo [[PATCH URLS]] | grep -q -v "PATCH URLS"; then
fi
</patch_source>
+<manifest_check> off
+# Check Manifest file
+if [ -e "$CWD/Manifest" ]; then
+
+ for MANIFEST_LINE in `grep -E -v "^(MKBUILD|SLACKBUILD)" $CWD/Manifest`; do
+
+ MANIFEST_FILE="`echo $MANIFEST_LINE | awk '{ print $2 }'`"
+ if [ -e "$SRC_DIR/$MANIFEST_FILE" ]; then
+ MANIFEST_FILE="$SRC_DIR/$MANIFEST_FILE"
+ else
+ MANIFEST_FILE="`find $CWD -name $MANIFEST_FILE`"
+ fi
+
+ if [ ! -e "$MANIFEST_FILE" ]; then
+ continue
+ fi
+
+ SIZE_SRC="`wc -c $MANIFEST_FILE`"
+ SIZE_MANIFEST="`echo $MANIFEST_LINE | awk '{ print $3 }`"
+
+ # Check source code size
+ if [ "$SIZE_SRC" != "$SIZE_MANIFEST" ]; then
+ echo "SIZE Manifest: $SIZE_MANIFEST; SIZE $SRC: $SIZE_SRC"
+ exit $ERROR_MANIFEST
+ fi
+
+ # Check source code integrity
+ for ALGO in md5 sha1 sha256 sha512 rmd160; do
+ if [ $ALGO = "rmd160" ]; then
+ ALGO_SRC="`openssl rmd160 $MANIFEST_FILE | awk '{ print $1 }'`"
+ else
+ ALGO_SRC="`"$ALGO"sum $MANIFEST_FILE | awk '{ print $1 }'`"
+ fi
+ ALGO_MANIFEST=$(echo $MANIFEST_LINE | sed 's/.* $ALGO //' | awk '{ print $1 }')
+ if [ "$ALGO_SRC" == "$ALGO_MANIFEST" ]; then
+ echo "$ALGO Manifest: $ALGO_MANIFEST; $ALGO $SRC: $ALGO_SRC"
+ exit $ERROR_MANIFEST
+ fi
+ done
+
+ done
+
+else
+ exit $ERROR_MANIFEST
+fi
+</manifest_check>
+
<files_permissions> off
# Set permissions
chown -R root:root .
diff --git a/trunk/mkbuild/model.mkbuild b/trunk/mkbuild/model.mkbuild
index 84dc256..1ca855c 100644
--- a/trunk/mkbuild/model.mkbuild
+++ b/trunk/mkbuild/model.mkbuild
@@ -147,6 +147,7 @@ off: md5sum_download_and_check_1
off: gpg_signature_check
on: untar_source
off: patch_source
+ on: manifest_check
on: configure
on: make_package
on: install_package
diff --git a/trunk/src/createpkg b/trunk/src/createpkg
index 2344a1b..325d120 100644
--- a/trunk/src/createpkg
+++ b/trunk/src/createpkg
@@ -175,6 +175,7 @@ function find_slackbuild {
OUTPUT=`find $SLACKBUILDS_DIR -iname $1.SlackBuild`
[ "$OUTPUT" != "" ] && EXIT_CODE=0 || EXIT_CODE=1
echo $OUTPUT
+
}
function info_builds {
diff --git a/trunk/src/mkbuild b/trunk/src/mkbuild
index 551c5ad..72c970f 100755
--- a/trunk/src/mkbuild
+++ b/trunk/src/mkbuild
@@ -628,7 +628,11 @@ function submit_mkbuild {
svn_copy $WORK/$MKBUILD_NAME $MKBUILD_PATH
for i in `ls $WORK | grep -E -v '(SlackBuild|old|slack-required|.mkbuild$|.tmp$)\*{0,1}$'`; do
- svn_copy $WORK/$i $MKBUILD_PATH
+ if ! is_the_same $(dirname $MKBUILD_PATH) $WORK; then
+ svn_copy $WORK/$i $MKBUILD_PATH
+ else
+ svn_add $WORK/$i
+ fi
done
# remove stuff in old places
@@ -719,6 +723,87 @@ function load_parameters {
TMP="`eval_parameter TMP /tmp`"
}
+
+function file_metainfo {
+
+ # get integrity file metainformation
+ # usage: file_metainfo <file> <file_type>
+
+ local size algo sum="" file="$1" file_type="$2"
+
+ if [ ! -e "$file" ] || [ -z "$file_type" ]; then
+ return 1
+ fi
+
+ for algo in md5 sha1 sha256 sha512 rmd160; do
+ sum="$sum `echo $algo | tr '[:lower:]' '[:upper:]'` `gethash $algo $file`"
+ done
+
+ echo $file_type `basename $file` `file_size $file` $sum
+
+}
+
+function update_manifest_info {
+
+ # update Manifest meatinfo for a given file
+ # usage: update_manifest_info <file> <file_type>
+
+ local tmpfile file="$1" file_type="`echo $2 | tr '[:lower:]' '[:upper:]'`"
+
+ if [ ! -e "$file" ]; then
+ return 1
+ fi
+
+ if [ -z "$file_type" ]; then
+ file_type="`file_extension $file | tr '[:lower:]' '[:upper:]'`"
+ fi
+
+ # Update Manifest file
+ if [ ! -e "`dirname $file`/Manifest" ]; then
+ touch $WORK/Manifest
+ fi
+
+ # Set temporary file
+ tmpfile="`mktemp $TMP/mkbuild_manifest.XXXXXX`"
+
+ # Update metainfo
+ sed -e "/^$file_type `basename $file` /d" `dirname $file`/Manifest > $tmpfile
+ file_metainfo $file $file_type >> $tmpfile
+ sort $tmpfile > `dirname $file`/Manifest
+
+ rm -f $tmpfile
+
+}
+
+function update_manifest {
+
+ # Update Manifest file
+
+ # Update mkbuild metainformation
+ uptate_manifest_info $WORK/$MKBUILD_NAME
+
+ # Update slack-required information
+ uptate_manifest_info $WORK/slack-required
+
+ # Update SlackBuild information
+ update_manifest_info $WORK/$SLACKBUILD
+
+ # Update patches
+ for i in `find $WORK | grep -E '(.diff$|.diff.gz$|.diff.bz2$|.patch$|.patch.gz$|.patch.bz2$)\*{0,1}$'`; do
+ if [ ! -d "$WORK/$i" ]; 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$)\*{0,1}$'`; do
+ if [ ! -d "$WORK/$i" ]; then
+ update_manifest_info $i misc
+ fi
+ done
+
+}
+
# ----------------------------------------------------------------
#=============================
@@ -972,6 +1057,9 @@ if [ ! -z $MKBUILD_NAME ]; then
[ $VERBOSE -eq $on ] && echo -e "\nEdit others [[]] parameters ..."
change_others_parameters
+ # Update Manifest file
+ update_manifest
+
# Commit SlackBuild
[ $SUBMIT_SLACKBUILD -eq $on ] && submit_slackbuild