]> gitweb.fluxo.info Git - simplepkg.git/commitdiff
adding initial support for Manifest files
authorrhatto <rhatto@04377dda-e619-0410-9926-eae83683ac58>
Sat, 20 Dec 2008 17:47:07 +0000 (17:47 +0000)
committerrhatto <rhatto@04377dda-e619-0410-9926-eae83683ac58>
Sat, 20 Dec 2008 17:47:07 +0000 (17:47 +0000)
git-svn-id: svn+slack://slack.fluxo.info/var/svn/simplepkg@691 04377dda-e619-0410-9926-eae83683ac58

trunk/conf/simplepkg.conf
trunk/lib/common.sh
trunk/mkbuild/generic.mkSlackBuild
trunk/mkbuild/model.mkbuild
trunk/src/createpkg
trunk/src/mkbuild

index 746070768c3b3a6c27d31cf6ce2a5489ce6e2a74..8554f521b7b91d9933aa33cc94ab4c9695e471bb 100644 (file)
@@ -19,7 +19,7 @@
 # DEFAULT_VERSION="12.2"
 
 # Temporary folder
-TMP="/tmp"
+TMP="/tmp/simplepkg"
 
 #---------------------------------------------------------------------
 #                   MKBUILD AND CREATEPKG SECTION
index a6f82bc162cebcf9ed109ef8561050444b346ea9..58cffb26d1db592fddd632c0e7b1ea8c96464920 100644 (file)
@@ -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 
index 8cccbb285b1b866642a6fe6b82f17df6ea7dcf93..a9173e83653e02a2b20747026609fc49b11e22ba 100644 (file)
@@ -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 .
index 84dc256e915e1015cf3d0c5633fee39ac18d72bc..1ca855cc1e0bb9dd8fb0289c11e24b3465b86b45 100644 (file)
@@ -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
index 2344a1bd957880f494fdc0a05d43094f2e568cd4..325d120ed374b5699732cacb7b0c752504731108 100644 (file)
@@ -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 {
index 551c5ada975f108603c0a62755e81d7b63a9a065..72c970f22b256af0179c46e14231689a7fb54545 100755 (executable)
@@ -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