aboutsummaryrefslogtreecommitdiff
path: root/trunk/src
diff options
context:
space:
mode:
authorrhatto <rhatto@04377dda-e619-0410-9926-eae83683ac58>2008-11-28 17:22:06 +0000
committerrhatto <rhatto@04377dda-e619-0410-9926-eae83683ac58>2008-11-28 17:22:06 +0000
commitf8fd450c9b9561c29bfdba24bb87a9cc55fc889e (patch)
treefeea5ca231dc9f2a571a67591b893bb5388378f7 /trunk/src
parent990e65cdfd4539143968b4e85d7badd2ef42c2ec (diff)
downloadsimplepkg-f8fd450c9b9561c29bfdba24bb87a9cc55fc889e.tar.gz
simplepkg-f8fd450c9b9561c29bfdba24bb87a9cc55fc889e.tar.bz2
cleanup
git-svn-id: svn+slack://slack.fluxo.info/var/svn/simplepkg@601 04377dda-e619-0410-9926-eae83683ac58
Diffstat (limited to 'trunk/src')
-rw-r--r--trunk/src/createpkg242
1 files changed, 149 insertions, 93 deletions
diff --git a/trunk/src/createpkg b/trunk/src/createpkg
index a11a101..9ce645a 100644
--- a/trunk/src/createpkg
+++ b/trunk/src/createpkg
@@ -254,6 +254,8 @@ function load_parameters {
# Load Createpkg parameters
MAKEPKG_REPOS="`eval_parameter MAKEPKG_REPOS /var/simplepkg/repos`"
MAKEPKG_REPOS_STYLE="`eval_parameter MAKEPKG_REPOS_STYLE none`"
+ MAKEPKG_REPOS_NOARCH="`eval_parameter MAKEPKG_REPOS_NOARCH $off`"
+ NOARCH_REPOS="`eval_parameter MAKEPKG_REPOS /var/simplepkg/repos`/noarch"
SOURCE_DIR="`eval_parameter SOURCE_DIR /var/simplepkg/sources`"
SLACKBUILDS_DIR="`eval_parameter SLACKBUILDS_DIR /var/simplepkg/slackbuilds`"
SLACKBUILDS_SVN="`eval_parameter SLACKBUILDS_SVN http://slack.sarava.org/slackbuilds`"
@@ -313,6 +315,131 @@ function commit_changes {
}
+function create_repo_folder {
+
+ # Create repository directory
+ # usage: create_repo_folder <repository_folder>
+
+ folder="$1"
+
+ if [ ! -e $new_repos ]; then
+ if [ -d "$folder/.svn" ] && ! svn_check $folder/$SUBFOLDER; then
+ (
+ cd $folder
+ chown_svn $folder && chgrp_svn $folder
+ svn_mkdir $SUBFOLDER
+ )
+ else
+ mkdir -p $folder/$SUBFOLDER
+ fi
+ fi
+
+}
+
+function remove_old_package_data {
+
+ # Remove old packages from repository tree
+ # usage: remove_old_package_data <repository_folder>
+
+ if [ -z "$2" ]; then
+ return 1
+ fi
+
+ makepkg_repos="$1"
+
+ # Remove old PACKAGEs from repository tree
+ if [ $REMOVE_OLD_PACKAGE -eq $on ]; then
+
+ # first remove entries from CHECKSUMS.md5
+ if [ -f "$makepkg_repos/CHECKSUMS.md5" ]; then
+ sed -i "/$PACKAGE-.*-.*-.*.*$/d" $makepkg_repos/CHECKSUMS.md5
+ fi
+
+ # then remove entries from patches/CHECKSUMS.md5
+ if [ -f "$makepkg_repos/patches/CHECKSUMS.md5" ]; then
+ sed -i "/$PACKAGE-.*-.*-.*.*$/d" $makepkg_repos/patches/CHECKSUMS.md5
+ fi
+
+ # Using subversion
+ if [ -d "$makepkg_repos/.svn" ]; then
+
+ (
+
+ cd $makepkg_repos
+
+ PACKAGE_VERSION="`package_version $PKG_NAME`"
+ PACKAGE_ARCH="`package_arch $PKG_NAME`"
+ PACKAGE_BUILD="`package_build $PKG_NAME`"
+
+ # Using -mindepth 2 so it doesn't delete the new PACKAGE
+ for file in `find . -mindepth 2 -name "$PACKAGE-*-*-*.tgz" -o -name "$PACKAGE-*-*-*.meta"`; do
+ candidate="`echo $file | sed -e 's/\.meta/\.tgz/'`" # otherwise PACKAGE info functions can fail
+ # Just delete PACKAGEs with different arch, version or build number
+ if [ "`package_version $candidate`" != "$PACKAGE_VERSION" ] || \
+ [ "`package_arch $candidate`" != "$PACKAGE_ARCH" ] || \
+ [ "`package_build $candidate`" != "$PACKAGE_BUILD" ]; then
+ svn_del $file
+ fi
+ done
+
+ for file in `find $makepkg_repos -name "$PACKAGE.slack-required"`; do
+ if [ $MOVE_SLACK_REQUIRED -eq $off ]; then
+ svn_del $file
+ elif [ ! -z "$SLACK_REQUIRED" ] && [ "$repository_folder/$SUBFOLDER/$PACKAGE.slack-required" != "$file" ]; then
+ svn_del $file
+ fi
+ done
+
+ )
+
+ else
+ # Using -mindepth 2 so it doesn't delete the new PACKAGE
+ find $makepkg_repos -mindepth 2 -name "$PACKAGE-*-*-*.tgz" -o -name "$PACKAGE-*-*-*.meta" -exec rm {} 2>/dev/null \;
+ find $makepkg_repos -name "$PACKAGE.slack-required" -exec rm {} 2>/dev/null \;
+ fi
+ fi
+
+}
+
+function update_metadata {
+
+ # Update repository metadata
+ # usage: update_metadata <repository_folder>
+
+ if [ ! -d "$1" ]; then
+ return 1
+ fi
+
+ makepkg_repos="$1"
+
+ (
+
+ cd $makepkg_repos
+
+ gen_meta $SUBFOLDER/$PKG_NAME
+ gen_filelist
+ gen_patches_filelist patches
+ update_md5_checksum $makepkg_repos $SUBFOLDER/$PKG_NAME
+
+ # update md5 file from patches/ folder if needed
+ if [ -d "patches/" ]; then
+
+ found_patch="no"
+
+ for file in `find patches/ -name "$PACKAGE-*-*-*.tgz"`; do
+ found_patch="yes"
+ update_md5_checksum $makepkg_repos/patches patches/$SUBFOLDER/$PKG_NAME
+ done
+
+ if [ "$found_patch" == "yes" ]; then
+ gen_patches_filelist patches/
+ fi
+ fi
+
+ )
+
+}
+
#---------------------------------------------------
# Starting createpkg
#---------------------------------------------------
@@ -522,73 +649,19 @@ handle_error $? $PACKAGE
PKG_NAME="`ls -1 -c $MAKEPKG_REPOS/$PACKAGE-*-*-*.tgz | head -n 1 | xargs basename`"
# Select repository directory
-[ $MOVE_BIN_PACKAGE -eq $on ] && NEW_REPOS=$MAKEPKG_REPOS/$( echo ${SCRIPT_BASE#$SLACKBUILDS_DIR/} ) || NEW_REPOS=$MAKEPKG_REPOS
-
-# Create repository directory
-if [ ! -e $NEW_REPOS ]; then
- if [ -d "$MAKEPKG_REPOS/.svn" ] && ! svn_check $NEW_REPOS; then
- (
- cd $MAKEPKG_REPOS
- chown_svn $MAKEPKG_REPOS && chgrp_svn $MAKEPKG_REPOS
- svn_mkdir $( echo ${SCRIPT_BASE#$SLACKBUILDS_DIR/} )
- )
- else
- mkdir -p $NEW_REPOS
- fi
+if [ $MOVE_BIN_PACKAGE -eq $on ]; then
+ SUBFOLDER="$( echo ${SCRIPT_BASE#$SLACKBUILDS_DIR/} )"
+ NEW_REPOS=$MAKEPKG_REPOS/$SUBFOLDER
+else
+ SUBFOLDER="."
+ NEW_REPOS=$MAKEPKG_REPOS
fi
-# Remove old packages from repository tree
-if [ $REMOVE_OLD_PACKAGE -eq $on ]; then
-
- # first remove entries from CHECKSUMS.md5
- if [ -f "$MAKEPKG_REPOS/CHECKSUMS.md5" ]; then
- sed -i "/$PACKAGE-.*-.*-.*.*$/d" $MAKEPKG_REPOS/CHECKSUMS.md5
- fi
-
- # then remove entries from patches/CHECKSUMS.md5
- if [ -f "$MAKEPKG_REPOS/patches/CHECKSUMS.md5" ]; then
- sed -i "/$PACKAGE-.*-.*-.*.*$/d" $MAKEPKG_REPOS/patches/CHECKSUMS.md5
- fi
-
- # Using subversion
- if [ -d "$MAKEPKG_REPOS/.svn" ]; then
-
- (
-
- cd $MAKEPKG_REPOS
-
- PACKAGE_VERSION="`package_version $PKG_NAME`"
- PACKAGE_ARCH="`package_arch $PKG_NAME`"
- PACKAGE_BUILD="`package_build $PKG_NAME`"
-
- # Using -mindepth 2 so it doesn't delete the new package
- for file in `find . -mindepth 2 -name "$PACKAGE-*-*-*.tgz" -o -name "$PACKAGE-*-*-*.meta"`; do
- candidate="`echo $file | sed -e 's/\.meta/\.tgz/'`" # otherwise package info functions can fail
- # Just delete packages with different arch, version or build number
- if [ "`package_version $candidate`" != "$PACKAGE_VERSION" ] || \
- [ "`package_arch $candidate`" != "$PACKAGE_ARCH" ] || \
- [ "`package_build $candidate`" != "$PACKAGE_BUILD" ]; then
- svn_del $file
- fi
- done
-
- for file in `find $MAKEPKG_REPOS -name "$PACKAGE.slack-required"`; do
- if [ $MOVE_SLACK_REQUIRED -eq $off ]; then
- svn_del $file
- elif [ ! -z "$SLACK_REQUIRED" ] && [ "$NEW_REPOS/$PACKAGE.slack-required" != "$file" ]; then
- svn_del $file
- fi
- done
-
- )
-
- else
- # Using -mindepth 2 so it doesn't delete the new package
- find $MAKEPKG_REPOS -mindepth 2 -name "$PACKAGE-*-*-*.tgz" -o -name "$PACKAGE-*-*-*.meta" -exec rm {} 2>/dev/null \;
- find $MAKEPKG_REPOS -name "$PACKAGE.slack-required" -exec rm {} 2>/dev/null \;
- fi
-fi
+# Create the repository folders
+create_repo_folder $MAKEPKG_REPOS
+# Remove old packages from repository tree
+remove_old_package_data $MAKEPKG_REPOS
# Move package to SlackBuilds-like tree
if [ $MOVE_BIN_PACKAGE -eq $on ]; then
@@ -611,40 +684,23 @@ if [ $MOVE_BIN_PACKAGE -eq $on ]; then
fi
-# Update repository FILELIST.TXT, ...
-(
-
- cd $MAKEPKG_REPOS
-
- SUBFOLDER="`echo $NEW_REPOS | sed -e "s/^$(regexp_slash $MAKEPKG_REPOS/)//"`"
- gen_meta $SUBFOLDER/$PKG_NAME
-
- gen_filelist
- gen_patches_filelist patches
- update_md5_checksum $MAKEPKG_REPOS $SUBFOLDER/$PKG_NAME
-
- # update md5 file from patches/ folder if needed
- if [ -d "patches/" ]; then
-
- found_patch="no"
-
- for file in `find patches/ -name "$PACKAGE-*-*-*.tgz"`; do
- found_patch="yes"
- SUBFOLDER="`echo $NEW_REPOS | sed -e "s/^$(regexp_slash $MAKEPKG_REPOS/patches/)//"`"
- update_md5_checksum $MAKEPKG_REPOS/patches $SUBFOLDER/$PKG_NAME
- done
-
- if [ "$found_patch" == "yes" ]; then
- gen_patches_filelist patches/
- fi
- fi
-
-)
+# Update repository metadata
+update_metadata $MAKEPKG_REPOS
# General cleanup
echo Cleaning up the repository...
svn_remove_empty_folders $MAKEPKG_REPOS
+# Update noarch repository
+if [ "$MAKEPKG_REPOS_NOARCH" -eq $on ] && [ "`package_arch $PKG_NAME`" == "noarch" ]; then
+ echo Copying package to noarch repository...
+ create_repo_folder $NOARCH_REPOS
+ remove_old_package_data $NOARCH_REPOS
+ svn_copy $NEW_REPOS/$PACKAGE* $NOARCH_REPOS/$SUBFOLDER/
+ update_metadata $NOARCH_REPOS
+ svn_remove_empty_folders $NOARCH_REPOS
+fi
+
# Install package
if [ "$INSTALL" -eq $on ]; then
upgradepkg --install-new $NEW_REPOS/$PKG_NAME