From b63af7e6493019bdb57eafdc32199bbd097a8f1c Mon Sep 17 00:00:00 2001 From: Bryan Thornbury Date: Tue, 3 Nov 2015 14:13:25 -0800 Subject: [PATCH 1/3] Match CI build version to Debian Package Build Version. The Debian Package should have the same version as the rest of the packages being created as a part of the full build. These changes enable that. NOTE: The debian package revision is unused but still included in the package to allow for hyphens in the package version. (https://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-Version) --- build.sh | 2 +- package_tool/package_tool | 20 +++++++++++++------- scripts/package-debian.sh | 5 ++--- scripts/package.sh | 2 +- 4 files changed, 17 insertions(+), 12 deletions(-) diff --git a/build.sh b/build.sh index 457b0307f..016e47399 100755 --- a/build.sh +++ b/build.sh @@ -23,4 +23,4 @@ fi echo Building dotnet tools verison - $DOTNET_BUILD_VERSION $DIR/scripts/bootstrap.sh -$DIR/scripts/package.sh $1 +$DIR/scripts/package.sh diff --git a/package_tool/package_tool b/package_tool/package_tool index 7689adfea..aa9a5f08f 100755 --- a/package_tool/package_tool +++ b/package_tool/package_tool @@ -1,23 +1,23 @@ #!/bin/bash # # Takes Parameters: -# $0 = Input Directory -# $1 = Output Directory +# $1 = Input Directory +# $2 = Output Directory +# $3 = Package Version SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" ## Load Functions ## source $SCRIPT_DIR/scripts/debian_build_lib.sh -INPUT_DIR=$1 -OUTPUT_DIR=$2 +INPUT_DIR="$1" +OUTPUT_DIR="$2" +INPUT_PACKAGE_VERSION="$3" # Special Input Directories + Paths ABSOLUTE_PLACEMENT_DIR="${INPUT_DIR}/\$" PACKAGE_ROOT_PLACEMENT_DIR="${INPUT_DIR}/package_root" -# Output Directories - # Inputs INPUT_SAMPLES_DIR="$INPUT_DIR/samples" INPUT_DOCS_DIR="$INPUT_DIR/docs" @@ -70,7 +70,13 @@ parse_config_and_set_env_vars(){ extract_base_cmd="python $SCRIPT_DIR/scripts/extract_json_value.py" PACKAGE_NAME=$($extract_base_cmd $CONFIG "package_name") - PACKAGE_VERSION=$($extract_base_cmd $CONFIG "release.package_version") + + # Override JSON Defined Version w/ Cmd Line ARG + if [ -z $INPUT_PACKAGE_VERSION ]; then + PACKAGE_VERSION=$($extract_base_cmd $CONFIG "release.package_version") + else + PACKAGE_VERSION=$INPUT_PACKAGE_VERSION + fi PACKAGE_SOURCE_DIR="${OUTPUT_DIR}/${PACKAGE_NAME}-${PACKAGE_VERSION}" INSTALL_ROOT="/usr/share/${PACKAGE_NAME}" diff --git a/scripts/package-debian.sh b/scripts/package-debian.sh index 97c6e87ad..ee9da11ed 100755 --- a/scripts/package-debian.sh +++ b/scripts/package-debian.sh @@ -14,7 +14,7 @@ DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" source "$DIR/_common.sh" if [ "$UNAME" != "Linux" ]; then - errro "Debian Package build only supported on Linux" + error "Debian Package build only supported on Linux" exit 1 fi @@ -59,7 +59,7 @@ create_debian_package(){ mkdir -p $PACKAGE_OUTPUT_DIR - $REPO_ROOT/package_tool/package_tool $PACKAGE_LAYOUT_DIR $PACKAGE_OUTPUT_DIR + $REPO_ROOT/package_tool/package_tool $PACKAGE_LAYOUT_DIR $PACKAGE_OUTPUT_DIR $DOTNET_BUILD_VERSION } test_debian_package(){ @@ -76,4 +76,3 @@ test_debian_package(){ execute DEBIAN_FILE=$(find $PACKAGE_OUTPUT_DIR -iname "*.deb") -$DIR/publish.sh $DEBIAN_FILE diff --git a/scripts/package.sh b/scripts/package.sh index 26bdb2c2f..fcaefd059 100755 --- a/scripts/package.sh +++ b/scripts/package.sh @@ -12,7 +12,7 @@ DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" # Create Dnvm Package $DIR/package-dnvm.sh -if [[ "$1" == "debian" ]]; then +if [[ "$(uname)" == "Linux" ]]; then # Create Debian package $DIR/package-debian.sh fi From 4971df9f9abedfddca67ebcb5d0e56c542e1237b Mon Sep 17 00:00:00 2001 From: Bryan Date: Tue, 10 Nov 2015 14:23:54 -0800 Subject: [PATCH 2/3] Changes to propagate PACKAGE_VERSION from build to deb template generation scripts --- package_tool/package_tool | 2 +- .../scripts/config_template_generator.py | 25 +++++++++++++------ package_tool/scripts/debian_build_lib.sh | 1 - 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/package_tool/package_tool b/package_tool/package_tool index aa9a5f08f..72bd79422 100755 --- a/package_tool/package_tool +++ b/package_tool/package_tool @@ -160,7 +160,7 @@ package_docs(){ ## Generation Functions ## generate_config_templates(){ - python ${SCRIPT_DIR}/scripts/config_template_generator.py $CONFIG $SCRIPT_DIR/templates/debian $DEBIAN_DIR + python ${SCRIPT_DIR}/scripts/config_template_generator.py $CONFIG $SCRIPT_DIR/templates/debian $DEBIAN_DIR $PACKAGE_VERSION } generate_manpages(){ diff --git a/package_tool/scripts/config_template_generator.py b/package_tool/scripts/config_template_generator.py index 1ce61d734..4da935fcd 100644 --- a/package_tool/scripts/config_template_generator.py +++ b/package_tool/scripts/config_template_generator.py @@ -29,9 +29,9 @@ class UTC(datetime.tzinfo): return datetime.timedelta(0) # Generation Functions -def generate_and_write_all(config_data, template_dir, output_dir): +def generate_and_write_all(config_data, template_dir, output_dir, package_version=None): try: - changelog_contents = generate_changelog(config_data, template_dir) + changelog_contents = generate_changelog(config_data, template_dir, package_version=package_version) control_contents = generate_control(config_data, template_dir) copyright_contents = generate_copyright(config_data, template_dir) symlink_contents = generate_symlinks(config_data) @@ -50,13 +50,18 @@ def generate_and_write_all(config_data, template_dir, output_dir): return -def generate_changelog(config_data, template_dir): +def generate_changelog(config_data, template_dir, package_version=None): template = get_template(template_dir, FILE_CHANGELOG) release_data = config_data["release"] + + # Allow for Version Override + config_package_version = release_data["package_version"] + if package_version is None: + package_version = config_package_version template_dict = dict(\ - PACKAGE_VERSION=release_data["package_version"], + PACKAGE_VERSION=package_version, PACKAGE_REVISION=release_data["package_revision"], CHANGELOG_MESSAGE=release_data["changelog_message"], URGENCY=release_data.get("urgency", "low"), @@ -188,7 +193,7 @@ def help_and_exit(msg): sys.exit(1) def print_usage(): - print "Usage: config_template_generator.py [config file path] [template directory path] [output directory]" + print "Usage: config_template_generator.py [config file path] [template directory path] [output directory] (package version)" def parse_and_validate_args(): if len(sys.argv) < 4: @@ -198,6 +203,10 @@ def parse_and_validate_args(): config_path = sys.argv[1] template_dir = sys.argv[2] output_dir = sys.argv[3] + version_override = None + + if len(sys.argv) >= 5: + version_override = sys.argv[4] if not os.path.isfile(config_path): help_and_exit("Error: Invalid config file path") @@ -208,16 +217,16 @@ def parse_and_validate_args(): if not os.path.isdir(output_dir): help_and_exit("Error: Invalid output directory path") - return (config_path, template_dir, output_dir) + return (config_path, template_dir, output_dir, version_override) def execute(): - config_path, template_dir, output_dir = parse_and_validate_args() + config_path, template_dir, output_dir, version_override = parse_and_validate_args() config_data = load_json(config_path) - generate_and_write_all(config_data, template_dir, output_dir) + generate_and_write_all(config_data, template_dir, output_dir, package_version=version_override) if __name__ == "__main__": execute() \ No newline at end of file diff --git a/package_tool/scripts/debian_build_lib.sh b/package_tool/scripts/debian_build_lib.sh index 14ddbc35a..225db05bd 100644 --- a/package_tool/scripts/debian_build_lib.sh +++ b/package_tool/scripts/debian_build_lib.sh @@ -3,7 +3,6 @@ # # Relies on these environment variables: # PACKAGE_SOURCE_DIR :: Package Source Staging Directory -# PACKAGE_DIR :: Package Build Directory # INSTALL_ROOT :: Absolute path of package installation root # write_debian_install_file From aaf1993c11c60e75d08b8f588d076a5ac7922dc5 Mon Sep 17 00:00:00 2001 From: Bryan Date: Tue, 10 Nov 2015 14:47:43 -0800 Subject: [PATCH 3/3] Address PR Feedback. Add back publish in package script: --- scripts/package-debian.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/package-debian.sh b/scripts/package-debian.sh index ee9da11ed..4a25e5a9c 100755 --- a/scripts/package-debian.sh +++ b/scripts/package-debian.sh @@ -76,3 +76,4 @@ test_debian_package(){ execute DEBIAN_FILE=$(find $PACKAGE_OUTPUT_DIR -iname "*.deb") +$DIR/publish.sh $DEBIAN_FILE \ No newline at end of file