diff options
author | Michele Calgaro <[email protected]> | 2018-02-11 21:58:16 +0900 |
---|---|---|
committer | Michele Calgaro <[email protected]> | 2018-05-28 14:46:58 +0900 |
commit | 80b6864a4cd886534f4158130e3c4ef450943ade (patch) | |
tree | 63761e7cb3d68d4c816d97926ee0487bbe6bc720 /debian | |
parent | f7fed43409d307ee2606ddc32c6e5cab3caf4ef8 (diff) | |
download | tde-packaging-80b6864a4cd886534f4158130e3c4ef450943ade.tar.gz tde-packaging-80b6864a4cd886534f4158130e3c4ef450943ade.zip |
DEB build script: added "create_repo" script. Prevent scripts from being
run from tde-packaging git repo, to make sure the user follows the
instructions provided.
Signed-off-by: Michele Calgaro <[email protected]>
Diffstat (limited to 'debian')
-rwxr-xr-x | debian/_buildscripts/local/scripts/_build_common.sh | 19 | ||||
-rw-r--r-- | debian/_buildscripts/local/scripts/_build_config_template.sh | 1 | ||||
-rwxr-xr-x | debian/_buildscripts/local/scripts/create_repo.sh | 55 |
3 files changed, 71 insertions, 4 deletions
diff --git a/debian/_buildscripts/local/scripts/_build_common.sh b/debian/_buildscripts/local/scripts/_build_common.sh index 72649dc89..60f589acf 100755 --- a/debian/_buildscripts/local/scripts/_build_common.sh +++ b/debian/_buildscripts/local/scripts/_build_common.sh @@ -38,6 +38,15 @@ function init_common() # Check script folder SCRIPT_DIR=$(dirname $(readlink -f "$0")) + # Prevent the script to be run from TDE packaging repo + REPO_URL=$(git config --get remote.origin.url 2>/dev/null) + if [ ! -z "$REPO_URL" ] && [ -z "${REPO_URL##*tde-packaging}" ]; then + echo -e "${CYellow} --- ERROR ---${CNone}" + echo "This script cannot be run from the TDE packaging repository." + echo "Please follow the instructions provided, then rerun this script." + exit 1 + fi + # Read config settings CFG_FILE=$SCRIPT_DIR/build_config.sh if [ -f "$CFG_FILE" ]; then @@ -47,7 +56,7 @@ function init_common() echo "Creating TDE build configuration file from template as $CFG_FILE." echo "Please check and modify as required, then rerun this script." cp "$SCRIPT_DIR/_build_config_template.sh" "$CFG_FILE" - exit 1 + exit 2 fi # TDE root folder must exist @@ -56,8 +65,9 @@ function init_common() echo "A valid TDE root folder could not be located. Something is wrong with your configuration" echo "in the config file $CFG_FILE" echo "Please check and modify the TDE_DIR variable as required, then rerun this script." - exit 2 + exit 3 fi + # Search for main TDE repo cd "$TDE_DIR/$CFG_GIT_TDE_MAIN" &>/dev/null CURR_DIR=$(git rev-parse --show-toplevel 2>/dev/null) @@ -66,8 +76,9 @@ function init_common() echo "Main TDE repo could not be located. Something is wrong with your configuration" echo "in the config file $CFG_FILE" echo "Please check and modify the TDE_DIR variable as required, then rerun this script." - exit 3 + exit 4 fi + # Search for TDE packaging repo cd "$TDE_DIR/$CFG_GIT_TDE_PACKAGING" &>/dev/null CURR_DIR=$(git rev-parse --show-toplevel 2>/dev/null) @@ -76,7 +87,7 @@ function init_common() echo "TDE packaging repo could not be located. Something is wrong with your configuration" echo "in the config file $CFG_FILE" echo "Please check and modify the TDE_DIR variable as required, then rerun this script." - exit 4 + exit 5 fi SCRIPT_LOG_DIR=$TDE_DIR/$CFG_SCRIPT_LOG_DIR diff --git a/debian/_buildscripts/local/scripts/_build_config_template.sh b/debian/_buildscripts/local/scripts/_build_config_template.sh index 589278eba..d0c5a9d2c 100644 --- a/debian/_buildscripts/local/scripts/_build_config_template.sh +++ b/debian/_buildscripts/local/scripts/_build_config_template.sh @@ -22,6 +22,7 @@ TDE_DIR="" CFG_SCRIPT_LOG_DIR="0_logs" CFG_GIT_DIR="1_git" CFG_BUILD_DIR="2_build" +CFG_REPO_DIR="3_repo" CFG_GIT_TDE_MAIN="$CFG_GIT_DIR/tde/main" CFG_GIT_TDE_PACKAGING="$CFG_GIT_DIR/tde-packaging/$DISTRO/$D_VERSION" CFG_GIT_EXTRA_DEPENDENCIES="$CFG_GIT_DIR/edeps" diff --git a/debian/_buildscripts/local/scripts/create_repo.sh b/debian/_buildscripts/local/scripts/create_repo.sh new file mode 100755 index 000000000..3fc2f0238 --- /dev/null +++ b/debian/_buildscripts/local/scripts/create_repo.sh @@ -0,0 +1,55 @@ +#!/bin/bash +# +# Create/update TDE local debian repository +# + +# Load common code and initialization +. ./_build_common.sh +init_common + +#---------------------------- +# Check command line arguments +parm_MAKE_BACKUP="n" +for arg in $@; do + if [ "$arg" = "-b" ]; then # backup old repository + parm_MAKE_BACKUP="y" + fi +done + + +#---------------------------- +# Create/update TDE local debian repository +echo -e "${CLightCyan}#### TDE local repository creation begin ####${CNone}" +ARCH_PATH="dists/$D_VERSION/main/binary-$ARCHITECTURE" +REPO_DIR="$TDE_DIR/$CFG_REPO_DIR" +REPO_DIR_BACKUP="$REPO_DIR.backup" +REPO_PKG_DIR="$REPO_DIR/$ARCH_PATH" +TDE_DEBS_DIR="$TDE_DIR/$CFG_TDE_DEBS_DIR" + +# Backup +if [ "$parm_MAKE_BACKUP" = "y" ] && [ -d "$REPO_DIR" ]; then + echo -e "${CYellow}> Backing up old repository${CNone}" + rm -R "$REPO_DIR_BACKUP" &>/dev/null + mv "$REPO_DIR" "$REPO_DIR_BACKUP" &>/dev/null + echo "Copy of the old repository available at \"$REPO_DIR_BACKUP\"" +fi + +# Create repository +echo -e "${CYellow}> Creating new repository${CNone}" +if [ -d "$REPO_DIR" ]; then + rm -R "$REPO_DIR" &>/dev/null +fi +mkdir -p "$REPO_PKG_DIR" +rsync -aHS --exclude="*/src/*.xz" --exclude="*/src/*.dsc" --exclude="*/src/*.changes" --exclude="Packages*" "$TDE_DEBS_DIR/" "$REPO_PKG_DIR/" + +# Create package index file +echo -e "${CYellow}> Creating package index file${CNone}" +cd "$REPO_DIR" +dpkg-scanpackages "./$ARCH_PATH" | gzip -9c > "./$ARCH_PATH/Packages.gz" + + +#---------------------------- +# Repository created +echo -e "${CLightGreen}#### TDE local repository created ####${CNone}" +cd "$SCRIPT_DIR" +exit 0 |