From f8fd450c9b9561c29bfdba24bb87a9cc55fc889e Mon Sep 17 00:00:00 2001 From: rhatto Date: Fri, 28 Nov 2008 17:22:06 +0000 Subject: cleanup git-svn-id: svn+slack://slack.fluxo.info/var/svn/simplepkg@601 04377dda-e619-0410-9926-eae83683ac58 --- trunk/src/createpkg | 242 ++++++++++++++++++++++++++++++++-------------------- 1 file changed, 149 insertions(+), 93 deletions(-) (limited to 'trunk/src') 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 + + 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 + + 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 + + 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 -- cgit v1.2.3