Merge pull request #147 from brthor/deb-versioning

Match Debian Package Version to CI Build Version
This commit is contained in:
Bryan Thornbury 2015-11-10 15:00:07 -08:00
commit 317ca5e2a8
6 changed files with 36 additions and 22 deletions

View file

@ -23,4 +23,4 @@ fi
echo Building dotnet tools verison - $DOTNET_BUILD_VERSION echo Building dotnet tools verison - $DOTNET_BUILD_VERSION
$DIR/scripts/bootstrap.sh $DIR/scripts/bootstrap.sh
$DIR/scripts/package.sh $1 $DIR/scripts/package.sh

View file

@ -1,23 +1,23 @@
#!/bin/bash #!/bin/bash
# #
# Takes Parameters: # Takes Parameters:
# $0 = Input Directory # $1 = Input Directory
# $1 = Output Directory # $2 = Output Directory
# $3 = Package Version
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
## Load Functions ## ## Load Functions ##
source $SCRIPT_DIR/scripts/debian_build_lib.sh source $SCRIPT_DIR/scripts/debian_build_lib.sh
INPUT_DIR=$1 INPUT_DIR="$1"
OUTPUT_DIR=$2 OUTPUT_DIR="$2"
INPUT_PACKAGE_VERSION="$3"
# Special Input Directories + Paths # Special Input Directories + Paths
ABSOLUTE_PLACEMENT_DIR="${INPUT_DIR}/\$" ABSOLUTE_PLACEMENT_DIR="${INPUT_DIR}/\$"
PACKAGE_ROOT_PLACEMENT_DIR="${INPUT_DIR}/package_root" PACKAGE_ROOT_PLACEMENT_DIR="${INPUT_DIR}/package_root"
# Output Directories
# Inputs # Inputs
INPUT_SAMPLES_DIR="$INPUT_DIR/samples" INPUT_SAMPLES_DIR="$INPUT_DIR/samples"
INPUT_DOCS_DIR="$INPUT_DIR/docs" 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" extract_base_cmd="python $SCRIPT_DIR/scripts/extract_json_value.py"
PACKAGE_NAME=$($extract_base_cmd $CONFIG "package_name") 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}" PACKAGE_SOURCE_DIR="${OUTPUT_DIR}/${PACKAGE_NAME}-${PACKAGE_VERSION}"
INSTALL_ROOT="/usr/share/${PACKAGE_NAME}" INSTALL_ROOT="/usr/share/${PACKAGE_NAME}"
@ -154,7 +160,7 @@ package_docs(){
## Generation Functions ## ## Generation Functions ##
generate_config_templates(){ 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(){ generate_manpages(){

View file

@ -29,9 +29,9 @@ class UTC(datetime.tzinfo):
return datetime.timedelta(0) return datetime.timedelta(0)
# Generation Functions # 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: 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) control_contents = generate_control(config_data, template_dir)
copyright_contents = generate_copyright(config_data, template_dir) copyright_contents = generate_copyright(config_data, template_dir)
symlink_contents = generate_symlinks(config_data) symlink_contents = generate_symlinks(config_data)
@ -50,13 +50,18 @@ def generate_and_write_all(config_data, template_dir, output_dir):
return 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) template = get_template(template_dir, FILE_CHANGELOG)
release_data = config_data["release"] 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(\ template_dict = dict(\
PACKAGE_VERSION=release_data["package_version"], PACKAGE_VERSION=package_version,
PACKAGE_REVISION=release_data["package_revision"], PACKAGE_REVISION=release_data["package_revision"],
CHANGELOG_MESSAGE=release_data["changelog_message"], CHANGELOG_MESSAGE=release_data["changelog_message"],
URGENCY=release_data.get("urgency", "low"), URGENCY=release_data.get("urgency", "low"),
@ -188,7 +193,7 @@ def help_and_exit(msg):
sys.exit(1) sys.exit(1)
def print_usage(): 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(): def parse_and_validate_args():
if len(sys.argv) < 4: if len(sys.argv) < 4:
@ -198,6 +203,10 @@ def parse_and_validate_args():
config_path = sys.argv[1] config_path = sys.argv[1]
template_dir = sys.argv[2] template_dir = sys.argv[2]
output_dir = sys.argv[3] 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): if not os.path.isfile(config_path):
help_and_exit("Error: Invalid config file 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): if not os.path.isdir(output_dir):
help_and_exit("Error: Invalid output directory path") 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(): 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) 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__": if __name__ == "__main__":
execute() execute()

View file

@ -3,7 +3,6 @@
# #
# Relies on these environment variables: # Relies on these environment variables:
# PACKAGE_SOURCE_DIR :: Package Source Staging Directory # PACKAGE_SOURCE_DIR :: Package Source Staging Directory
# PACKAGE_DIR :: Package Build Directory
# INSTALL_ROOT :: Absolute path of package installation root # INSTALL_ROOT :: Absolute path of package installation root
# write_debian_install_file # write_debian_install_file

View file

@ -14,7 +14,7 @@ DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
source "$DIR/_common.sh" source "$DIR/_common.sh"
if [ "$UNAME" != "Linux" ]; then if [ "$UNAME" != "Linux" ]; then
errro "Debian Package build only supported on Linux" error "Debian Package build only supported on Linux"
exit 1 exit 1
fi fi
@ -59,7 +59,7 @@ create_debian_package(){
mkdir -p $PACKAGE_OUTPUT_DIR 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(){ test_debian_package(){
@ -76,4 +76,4 @@ test_debian_package(){
execute execute
DEBIAN_FILE=$(find $PACKAGE_OUTPUT_DIR -iname "*.deb") DEBIAN_FILE=$(find $PACKAGE_OUTPUT_DIR -iname "*.deb")
$DIR/publish.sh $DEBIAN_FILE $DIR/publish.sh $DEBIAN_FILE

View file

@ -19,7 +19,7 @@ fi
# Create Dnvm Package # Create Dnvm Package
$DIR/package-dnvm.sh $DIR/package-dnvm.sh
if [[ "$1" == "debian" ]]; then if [[ "$(uname)" == "Linux" ]]; then
# Create Debian package # Create Debian package
$DIR/package-debian.sh $DIR/package-debian.sh
fi fi