diff options
author | Michele Calgaro <michele.calgaro@yahoo.it> | 2020-09-14 23:42:25 +0900 |
---|---|---|
committer | Michele Calgaro <michele.calgaro@yahoo.it> | 2020-09-14 23:42:25 +0900 |
commit | fc2fae6cf24f7cea2374dcba2e73680305c32e53 (patch) | |
tree | 298deb3179e6cf09c3e6cb12791a0d5f9e97de29 /debian/_buildscripts/local/build_module.sh | |
parent | fc4b7b4fed7e3677794695cba02725acbc50a50d (diff) | |
download | tde-packaging-fc2fae6cf24f7cea2374dcba2e73680305c32e53.tar.gz tde-packaging-fc2fae6cf24f7cea2374dcba2e73680305c32e53.zip |
DEB build scripts: updated to use extra dependency repository on TGW.
Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
Diffstat (limited to 'debian/_buildscripts/local/build_module.sh')
-rwxr-xr-x | debian/_buildscripts/local/build_module.sh | 311 |
1 files changed, 144 insertions, 167 deletions
diff --git a/debian/_buildscripts/local/build_module.sh b/debian/_buildscripts/local/build_module.sh index 3b0adef96..d34324595 100755 --- a/debian/_buildscripts/local/build_module.sh +++ b/debian/_buildscripts/local/build_module.sh @@ -17,7 +17,7 @@ exec_time_start $_BUILDMOD_TIMER_NUM # Need sudo for non-root users SUDO_CMD="" if [ "`whoami`" != "root" ]; then - SUDO_CMD="sudo -E" + SUDO_CMD="sudo -E" fi @@ -26,19 +26,19 @@ fi # $1 - error code function do_exit() { - cd "$SCRIPT_DIR" - if [ $1 -eq 0 ]; then - echo -e "${CGreen}#### Processing module ${CLightGreen}\"$MOD_GIVEN\"${CGreen} succeeded ####${CNone}" + cd "$SCRIPT_DIR" + if [ $1 -eq 0 ]; then + echo -e "${CGreen}#### Processing module ${CLightGreen}\"$MOD_GIVEN\"${CGreen} succeeded ####${CNone}" if [ "$bool_LOG_RESULT" = "y" ]; then echo "[ OK ] [$_BUILDMOD_TIME] \"$MOD_NAME\"" >>"$LOG_BUILD_RESULT_FILENAME" fi - else - echo -e "${CRed}#### Processing module ${CLightRed}\"$MOD_GIVEN\"${CRed} failed ($1) ####${CNone}" + else + echo -e "${CRed}#### Processing module ${CLightRed}\"$MOD_GIVEN\"${CRed} failed ($1) ####${CNone}" if [ "$bool_LOG_RESULT" = "y" ]; then echo "[FAILED] [$_BUILDMOD_TIME] \"$MOD_NAME\"" >>"$LOG_BUILD_RESULT_FILENAME" fi - fi - exit $1 + fi + exit $1 } @@ -48,35 +48,15 @@ function do_exit() function recreate_folder() { if [ -d "$1" ]; then - $SUDO_CMD rm -R "$1" - fi - mkdir -p "$1" -} - - -#---------------------------- -# Set module related path variables -# Parameters: -# $1 - module name -function set_module_paths() -{ - local LOC_MOD_NAME=$1 - if [ "$bool_EXTRADEP_MOD" != "y" ]; then - # Standard module - MOD_GIT_PATH="$REPO_TDE_MAIN/$LOC_MOD_NAME" - MOD_GIT_PKGING_PATH="$REPO_TDE_PACKAGING/$LOC_MOD_NAME/debian" - else - # Extra dependency module - MOD_GIT_PATH="$REPO_DIR/$LOC_MOD_NAME" - fi - export MOD_BUILD_PATH="$TDE_BUILD_DIR/$LOC_MOD_NAME" - MOD_BUILD_PKGING_PATH="$MOD_BUILD_PATH/debian" + $SUDO_CMD rm -R "$1" + fi + mkdir -p "$1" } #---------------------------- # Look for a module in the git repository or in the extra dependency folder. -# Set the new module name if found. +# Set the module name and paths if found. # Parameters: # $1 - module name function search_module() @@ -85,6 +65,7 @@ function search_module() IFS="*" local LOC_MOD_NAME=$1 local LOC_MATCH + MODULE_FOUND="n" # Search in GIT repository @@ -93,18 +74,23 @@ function search_module() # Unique module found in GIT MODULE_FOUND="y" MOD_NAME=$LOC_MATCH - set_module_paths $MOD_NAME - else + MOD_GIT_PATH="$REPO_TDE_MAIN/$MOD_NAME" + MOD_GIT_PKGING_PATH="$REPO_TDE_PACKAGING/$MOD_NAME/debian" + MOD_BUILD_PATH="$TDE_BUILD_DIR/$MOD_NAME" + else # Search in extra dependency folder - LOC_MATCH=`ls "$REPO_EXTRA_DEPENDENCIES" | grep "^$LOC_MOD_NAME$"` + LOC_BASENAME=`echo "$LOC_MOD_NAME" | sed -r "s|^${CFG_EXTRA_DEPS_DIR}/(debian/)?||"` + LOC_MATCH=`ls "$REPO_EXTRA_DEPENDENCIES/debian" | grep "^$LOC_BASENAME"` if [ "$LOC_MATCH" != "" -a "`echo $LOC_MATCH | wc -l`" = "1" ]; then # Unique module found in extra dependency folder MODULE_FOUND="y" bool_EXTRADEP_MOD="y" MOD_NAME="$CFG_EXTRA_DEPS_DIR/$LOC_MATCH" - set_module_paths $MOD_NAME + MOD_GIT_PATH="$REPO_EXTRA_DEPENDENCIES/debian/$LOC_BASENAME" + MOD_BUILD_PATH="$TDE_BUILD_DIR/$CFG_EXTRA_DEPS_DIR/$LOC_BASENAME" fi fi + MOD_BUILD_PKGING_PATH="$MOD_BUILD_PATH/debian" IFS=$OLDIFS } @@ -123,27 +109,27 @@ bool_PREPARE_ONLY="n" bool_DEBUG_MODE="n" bool_INTERNAL_PBUILDER="n" for arg in $@; do - if [ "$arg" = "-g" ]; then # select code to build from Git repo (-g) or from local build copy - bool_BUILD_FROM_GIT="y" - elif [ "$arg" = "-l" ]; then # build module Locally instead of in a clean chroot environment - bool_BUILD_LOCALLY="y" - elif [ "$arg" = "-sl" ]; then # output the building logs to terminal (ShowLog) - bool_SHOW_BUILD_LOGS="y" - elif [ "$arg" = "-lr" ]; then # Log build Result to file - bool_LOG_RESULT="y" - elif [ "$arg" = "-sh" ]; then # install Shell Hook for failing builds (only valid if NOT building locally) - bool_SHELL_HOOK="y" - elif [ "$arg" = "-po" ]; then # Prepare build folder Only but do not build - bool_PREPARE_ONLY="y" - elif [ "$arg" = "-d" ]; then # build with Debug symbols (used in hook scripts) - bool_DEBUG_MODE="y" - elif [ "$arg" = "-ip" ]; then # build using Internal Pbuilder (experimental) - bool_INTERNAL_PBUILDER="y" - elif [ "$MOD_GIVEN" = "" ]; then # module to be built - MOD_GIVEN="$arg" - fi + if [ "$arg" = "-g" ]; then # select code to build from Git repo (-g) or from local build copy + bool_BUILD_FROM_GIT="y" + elif [ "$arg" = "-l" ]; then # build module Locally instead of in a clean chroot environment + bool_BUILD_LOCALLY="y" + elif [ "$arg" = "-sl" ]; then # output the building logs to terminal (ShowLog) + bool_SHOW_BUILD_LOGS="y" + elif [ "$arg" = "-lr" ]; then # Log build Result to file + bool_LOG_RESULT="y" + elif [ "$arg" = "-sh" ]; then # install Shell Hook for failing builds (only valid if NOT building locally) + bool_SHELL_HOOK="y" + elif [ "$arg" = "-po" ]; then # Prepare build folder Only but do not build + bool_PREPARE_ONLY="y" + elif [ "$arg" = "-d" ]; then # build with Debug symbols (used in hook scripts) + bool_DEBUG_MODE="y" + elif [ "$arg" = "-ip" ]; then # build using Internal Pbuilder (experimental) + bool_INTERNAL_PBUILDER="y" + elif [ "$MOD_GIVEN" = "" ]; then # module to be built + MOD_GIVEN="$arg" + fi done -MOD_NAME=$MOD_GIVEN # the actal module to be built +MOD_NAME=$MOD_GIVEN # the actal module to be built echo -e "${CLightCyan}#### Processing module \"$MOD_GIVEN\" ####${CNone}" @@ -167,19 +153,19 @@ OPT_SIGN_PKG_LOCAL="--no-sign" # - show logs OPT_SHOW_LOGS="&>" if [ "$bool_SHOW_BUILD_LOGS" = "y" ]; then - OPT_SHOW_LOGS=" | tee " + OPT_SHOW_LOGS=" | tee " fi export OPT_SHOW_LOGS # This folders must exists BASE_DIRS=("REPO_DIR" "BUILD_DIR" "SCRIPT_DIR" "REPO_TDE_MAIN" "REPO_TDE_PACKAGING" "HOOK_DIR") if [[ "$USE_PREBUILD_EXTRA_DEPS" != "y" ]]; then - BASE_DIRS+=("REPO_EXTRA_DEPENDENCIES") + BASE_DIRS+=("REPO_EXTRA_DEPENDENCIES") fi for var_name in ${BASE_DIRS[@]}; do if [ ! -d "${!var_name}" ]; then echo -e "${CYellow}$var_name${CNone} folder missing (${CLightPurple}${!var_name}${CNone}). Check your config or create it." - do_exit 4 + do_exit 4 fi done @@ -204,24 +190,22 @@ if [[ $MOD_NAME =~ ^$CFG_EXTRA_DEPS_DIR/ ]]; then bool_EXTRADEP_MOD="y" fi -set_module_paths $MOD_NAME +# Make sure the module exists +search_module $MOD_NAME +if [ "$MODULE_FOUND" != "y" ]; then + echo "Module \"$MOD_NAME\" not found in GIT" + do_exit 5 +fi + if [ "$bool_BUILD_FROM_GIT" = "y" ]; then echo -e "${CYellow}> Building from GIT repo${CNone}" # source files - if [ ! -d "$MOD_GIT_PATH" ]; then - MODULE_FOUND="n" - search_module $MOD_NAME - if [ "$MODULE_FOUND" != "y" -o ! -d "$MOD_GIT_PATH" ]; then - echo "Module \"$MOD_NAME\" not found in GIT" - do_exit 5 - fi - fi bool_COPY_MOD_SRC="y" # packaging scripts if [ "$bool_EXTRADEP_MOD" != "y" -a ! -d "$MOD_GIT_PKGING_PATH" ]; then echo "Packaging for \"$MOD_NAME\" not found in GIT" - do_exit 6 + do_exit 6 fi bool_COPY_PKGING_FILES="y" # @@ -230,17 +214,7 @@ else # source files bool_COPY_MOD_SRC="n" if [ ! -d "$MOD_BUILD_PATH" ]; then - if [ ! -d "$MOD_GIT_PATH" ]; then - MODULE_FOUND="n" - search_module $MOD_NAME - if [ "$MODULE_FOUND" != "y" -o ! -d "$MOD_GIT_PATH" ]; then - echo "Module \"$MOD_NAME\" not found neither in BUILD nor in GIT" - do_exit 7 - fi - fi - if [ ! -d "$MOD_BUILD_PATH" ]; then - bool_COPY_MOD_SRC="y" - fi + bool_COPY_MOD_SRC="y" fi # packaging scripts @@ -266,7 +240,7 @@ fi # copy main repo source files, if needed if [ "$bool_COPY_MOD_SRC" = "y" ]; then - bool_COPY_PKGING_FILES="y" + bool_COPY_PKGING_FILES="y" recreate_folder "$MOD_BUILD_PATH" if [ "$bool_EXTRADEP_MOD" != "y" ]; then # Normal module @@ -275,27 +249,28 @@ if [ "$bool_COPY_MOD_SRC" = "y" ]; then echo "# TDE SCM module information" > "$MOD_BUILD_PATH/.tdescminfo" echo "Name: $MOD_NAME" >> "$MOD_BUILD_PATH/.tdescminfo" cd "$MOD_GIT_PATH" - MOD_BRANCH=`git symbolic-ref -q HEAD | sed "s|^refs/heads/||"` - if [[ -z "$MOD_BRANCH" ]]; then - MOD_BRANCH=`git branch --contains HEAD | egrep -v "no branch|detached" | head -n1 | cut -c 3-` - fi + MOD_BRANCH=`git symbolic-ref -q HEAD | sed "s|^refs/heads/||"` + if [[ -z "$MOD_BRANCH" ]]; then + MOD_BRANCH=`git branch --contains HEAD | egrep -v "no branch|detached" | head -n1 | cut -c 3-` + fi COMMIT_HASH=`git rev-parse HEAD` echo "Revision: $MOD_BRANCH-$COMMIT_HASH" >> "$MOD_BUILD_PATH/.tdescminfo" git log -1 --pretty=format:"DateTime: %cd%n" --date=format:"%m/%d/%Y %H:%M" >> "$MOD_BUILD_PATH/.tdescminfo" else - # Extra dependency module - if [ `find "$MOD_GIT_PATH" -name '*.dsc' | wc -l` == 1 ]; then - if [ -d "$MOD_BUILD_PATH" ]; then - $SUDO_CMD rm -R "$MOD_BUILD_PATH" - fi - eval dpkg-source --no-copy --no-check -x `find "$MOD_GIT_PATH" -name '*.dsc'` \ - \"$MOD_BUILD_PATH\" $OPT_SHOW_LOGS/dev/null + # Extra dependency module: copy and apply patches + # -- move to the correct folder + cd "$MOD_GIT_PATH" + if [ `ls -d */ | wc -l` == 1 ]; then + cd `ls -d */` + cp -R "." "$MOD_BUILD_PATH" + cd $MOD_BUILD_PATH + QUILT_PATCHES="debian/patches" quilt push -a >/dev/null # Make sure patches are not reapplied in future local builds. This could stop pdebuild from working. if [ -f "$MOD_BUILD_PATH/debian/patches/series" ]; then - cp /dev/null "$MOD_BUILD_PATH/debian/patches/series" + cp /dev/null "$MOD_BUILD_PATH/debian/patches/series" fi else - echo "There must be one and only one .dsc file in \"$MOD_GIT_PATH\"" + echo "There must be one and only one module folder in \"$MOD_GIT_PATH\"" do_exit 9 fi fi @@ -304,59 +279,59 @@ fi # copying packaging scripts, if needed if [ "$bool_EXTRADEP_MOD" != "y" -a "$bool_COPY_PKGING_FILES" = "y" ]; then if [ -d "$MOD_BUILD_PKGING_PATH" ]; then - $SUDO_CMD rm -R $MOD_BUILD_PKGING_PATH - fi - cp -R "$MOD_GIT_PKGING_PATH" "$MOD_BUILD_PKGING_PATH" - + $SUDO_CMD rm -R $MOD_BUILD_PKGING_PATH + fi + cp -R "$MOD_GIT_PKGING_PATH" "$MOD_BUILD_PKGING_PATH" + # TODO metapackage support - - # Default package name - # Calculate package version - cd $MOD_GIT_PATH - branch=`git symbolic-ref -q HEAD | sed "s|^refs/heads/||"` - if [[ -z "$branch" ]]; then - branch=`git branch --contains HEAD | egrep -v "no branch|detached" | head -n1 | cut -c 3-` - fi - target_tag=`git tag | grep -F "$TDE_RELEASE" | head -n1` - tag=`git tag | \ - sed "s|^\([^0-9]\)|\1.|" | sort -t. -k 1,1nr -k 2,2nr -k 3,3nr -k 4,4nr -k 5,5nr | sed "s|^\([^0-9]\)\.|\1|" | \ - while read t; do \ - git branch --contains $t | cut -c 3- | grep -x "$branch" >/dev/null && \ - echo "$t..HEAD" && break; done` - count=`git log $tag --pretty=oneline | wc -l` - package=$(basename $PWD)-trinity-$TDE_RELEASE - if [[ "$count" -gt 0 ]] || [[ -z "$target_tag" ]]; then - package=$package~pre$count+$(git rev-parse HEAD | cut -c 1-8) - fi - REL=4:$TDE_RELEASE${package#*$TDE_RELEASE} - REL=${REL%+*} - REL=${REL/4:14.0.0/4:14.0.0-s} - REL=${REL/4:14.0.0-s~pre/4:14.0.0-s~} - REL=${REL/.0~pre/.0~s} - # Get package name and packaging release - PKG_NAME=$(head -n1 $MOD_BUILD_PKGING_PATH/changelog) - PKG_NAME=${PKG_NAME%% *} - PKG_TAG=$(cd "$REPO_TDE_PACKAGING/$MOD_NAME" && - git tag | \ - sed "s|^\([^0-9]\)|\1.|" | sort -t. -k 1,1nr -k 2,2nr -k 3,3nr -k 4,4nr -k 5,5nr | sed "s|^\([^0-9]\)\.|\1|" | \ - while read t; do \ - git branch --contains $t | cut -c 3- | grep -x "$branch" >/dev/null && \ - echo "$t..HEAD" && break; done) - PKG_REL=$(cd "$REPO_TDE_PACKAGING/$MOD_NAME" && - git log $PKG_TAG --pretty=oneline . | wc -l) - if [ -n "$REL_SUFFIX" ]; then - PKG_REL="${PKG_REL}${REL_SUFFIX}" - fi - # TODO add relative patch count - ADD_REL=0 - - # Update changelog - REPO_DATE=`git log -1 --pretty=format:"%cd%n" --date=rfc` - GITUSER="$(git config --get user.name) <$(git config --get user.email)>" - echo "$PKG_NAME ($REL-0$DISTRO$DISTRO_VERSION.$ADD_REL+$PKG_REL) $DISTRO_NAME; urgency=low" > "$MOD_BUILD_PKGING_PATH/changelog" - echo -e "\n * Automated git build\n\n -- $GITUSER $REPO_DATE\n" >> "$MOD_BUILD_PKGING_PATH/changelog" - cat "$REPO_TDE_PACKAGING/$MOD_NAME/debian/changelog" >> "$MOD_BUILD_PKGING_PATH/changelog" - touch -d "$REPO_DATE" "$MOD_BUILD_PKGING_PATH/changelog" + + # Default package name + # Calculate package version + cd $MOD_GIT_PATH + branch=`git symbolic-ref -q HEAD | sed "s|^refs/heads/||"` + if [[ -z "$branch" ]]; then + branch=`git branch --contains HEAD | egrep -v "no branch|detached" | head -n1 | cut -c 3-` + fi + target_tag=`git tag | grep -F "$TDE_RELEASE" | head -n1` + tag=`git tag | \ + sed "s|^\([^0-9]\)|\1.|" | sort -t. -k 1,1nr -k 2,2nr -k 3,3nr -k 4,4nr -k 5,5nr | sed "s|^\([^0-9]\)\.|\1|" | \ + while read t; do \ + git branch --contains $t | cut -c 3- | grep -x "$branch" >/dev/null && \ + echo "$t..HEAD" && break; done` + count=`git log $tag --pretty=oneline | wc -l` + package=$(basename $PWD)-trinity-$TDE_RELEASE + if [[ "$count" -gt 0 ]] || [[ -z "$target_tag" ]]; then + package=$package~pre$count+$(git rev-parse HEAD | cut -c 1-8) + fi + REL=4:$TDE_RELEASE${package#*$TDE_RELEASE} + REL=${REL%+*} + REL=${REL/4:14.0.0/4:14.0.0-s} + REL=${REL/4:14.0.0-s~pre/4:14.0.0-s~} + REL=${REL/.0~pre/.0~s} + # Get package name and packaging release + PKG_NAME=$(head -n1 $MOD_BUILD_PKGING_PATH/changelog) + PKG_NAME=${PKG_NAME%% *} + PKG_TAG=$(cd "$REPO_TDE_PACKAGING/$MOD_NAME" && + git tag | \ + sed "s|^\([^0-9]\)|\1.|" | sort -t. -k 1,1nr -k 2,2nr -k 3,3nr -k 4,4nr -k 5,5nr | sed "s|^\([^0-9]\)\.|\1|" | \ + while read t; do \ + git branch --contains $t | cut -c 3- | grep -x "$branch" >/dev/null && \ + echo "$t..HEAD" && break; done) + PKG_REL=$(cd "$REPO_TDE_PACKAGING/$MOD_NAME" && + git log $PKG_TAG --pretty=oneline . | wc -l) + if [ -n "$REL_SUFFIX" ]; then + PKG_REL="${PKG_REL}${REL_SUFFIX}" + fi + # TODO add relative patch count + ADD_REL=0 + + # Update changelog + REPO_DATE=`git log -1 --pretty=format:"%cd%n" --date=rfc` + GITUSER="$(git config --get user.name) <$(git config --get user.email)>" + echo "$PKG_NAME ($REL-0$DISTRO$DISTRO_VERSION.$ADD_REL+$PKG_REL) $DISTRO_NAME; urgency=low" > "$MOD_BUILD_PKGING_PATH/changelog" + echo -e "\n * Automated git build\n\n -- $GITUSER $REPO_DATE\n" >> "$MOD_BUILD_PKGING_PATH/changelog" + cat "$REPO_TDE_PACKAGING/$MOD_NAME/debian/changelog" >> "$MOD_BUILD_PKGING_PATH/changelog" + touch -d "$REPO_DATE" "$MOD_BUILD_PKGING_PATH/changelog" fi # prepare destination directory for building @@ -372,24 +347,26 @@ recreate_folder "$MOD_DEBSRC_PATH" if [ -x "$HOOK_DIR/$MOD_NAME/pre_build.sh" ]; then echo -e "${CYellow}> Applying pre-build hook${CNone}" . "$HOOK_DIR/$MOD_NAME/pre_build.sh" - if [ $? -eq 0 ]; then - echo -e "> ${CBrown}Pre-build hook applied successfully${CNone}" - else - echo -e "> ${CLightBlue}Pre-build hook failed${CNone}" - fi + if [ $? -eq 0 ]; then + echo -e "> ${CBrown}Pre-build hook applied successfully${CNone}" + else + echo -e "> ${CLightBlue}Pre-build hook failed${CNone}" + fi fi + #---------------------------- # Switch to 3.0(quilt) format #---------------------------- # create orig tarball cd "$MOD_BUILD_PATH" + MOD_BASENAME=`head -n 1 "$MOD_BUILD_PKGING_PATH/changelog" | sed -r "s/^([^ ]+).*/\1/"` MOD_MAJOR_VER=`head -n 1 "$MOD_BUILD_PKGING_PATH/changelog" | sed -r "s/^[^ ]+ \(([^:]+:)?.*/\1/"` MOD_UP_VER=`head -n 1 "$MOD_BUILD_PKGING_PATH/changelog" | sed -r "s/^[^ ]+ \(([^:]+:)?(.*+)-.*/\2/"` MOD_DEB_VER=`head -n 1 "$MOD_BUILD_PKGING_PATH/changelog" | sed -r "s/^[^ ]+ \(.*+-([^\)]+).*/\1/"` -REPO_DATE=`dpkg-parsechangelog -l "$MOD_BUILD_PATH/debian/changelog" | sed -n -e 's|^Date: ||p'` +REPO_DATE=`dpkg-parsechangelog -l "$MOD_BUILD_PKGING_PATH/changelog" | sed -n -e 's|^Date: ||p'` tar cJf "../${MOD_BASENAME}_${MOD_UP_VER}.orig.tar.xz" --exclude="debian" --exclude=".git*" \ --mtime "$REPO_DATE" --pax-option=exthdr.name=%d/PaxHeaders/%f,delete=atime,delete=ctime . touch -d "$REPO_DATE" "../${MOD_BASENAME}_${MOD_UP_VER}.orig.tar.xz" @@ -439,19 +416,19 @@ if [ "$bool_BUILD_LOCALLY" = "y" ]; then if [ $build_retval -eq 0 ]; then eval dpkg-buildpackage -b $OPT_SIGN_PKG_LOCAL $OPT_SHOW_LOGS\"$BUILDING_LOG_FILE\" fi - build_retval=$? + build_retval=$? else ## Build module in a clean chroot environment using pbuilder $SUDO_CMD "$SCRIPT_DIR/internals/_pbuilder.sh" - build_retval=$? - if [ "`whoami`" != "root" ]; then - cd "$MOD_DEB_PATH" - $SUDO_CMD chown -R `id -u -n`:`id -g -n` . &>/dev/null - cd "$MOD_BUILD_PATH/.." - $SUDO_CMD chown `id -u -n`:`id -g -n` *.dsc *.changes *.tar.xz *.tar.bz2 *.tar.gz *.buildinfo &>/dev/null - $SUDO_CMD chown `id -u -n`:`id -g -n` "$TDE_DEBS_DIR/Packages" &>/dev/null - cd "$MOD_BUILD_PATH" - fi + build_retval=$? + if [ "`whoami`" != "root" ]; then + cd "$MOD_DEB_PATH" + $SUDO_CMD chown -R `id -u -n`:`id -g -n` . &>/dev/null + cd "$MOD_BUILD_PATH/.." + $SUDO_CMD chown `id -u -n`:`id -g -n` *.dsc *.changes *.tar.xz *.tar.bz2 *.tar.gz *.buildinfo &>/dev/null + $SUDO_CMD chown `id -u -n`:`id -g -n` "$TDE_DEBS_DIR/Packages" &>/dev/null + cd "$MOD_BUILD_PATH" + fi fi if [ $build_retval -eq 0 ]; then @@ -467,11 +444,11 @@ fi if [ -x "$HOOK_DIR/$MOD_NAME/post_build.sh" ]; then echo -e "${CYellow}> Applying post-build hook${CNone}" . "$HOOK_DIR/$MOD_NAME/post_build.sh" - if [ $? -eq 0 ]; then - echo -e "${CBrown}Post-build hook applied successfully${CNone}" - else - echo -e "${CLightBlue}Post-build hook failed${CNone}" - fi + if [ $? -eq 0 ]; then + echo -e "${CBrown}Post-build hook applied successfully${CNone}" + else + echo -e "${CLightBlue}Post-build hook failed${CNone}" + fi fi #---------------------------- |