From e83277b1792bd0a1e79038d6120af7b20bc10957 Mon Sep 17 00:00:00 2001 From: Costas Papastathis Date: Wed, 5 Jun 2024 16:44:26 +0300 Subject: [PATCH 1/2] fixing package.sh script to conditionally package an extension or a buildpack, buildpack type --- implementation/scripts/package.sh | 49 +++++++++++++++++++++++-------- 1 file changed, 36 insertions(+), 13 deletions(-) diff --git a/implementation/scripts/package.sh b/implementation/scripts/package.sh index d58f61cd..52a47be8 100755 --- a/implementation/scripts/package.sh +++ b/implementation/scripts/package.sh @@ -64,20 +64,25 @@ function main { tools::install "${token}" - buildpack::archive "${version}" - buildpackage::create "${output}" + buildpack_type=buildpack + if [ -f "extension.toml" ]; then + buildpack_type=extension + fi + + buildpack::archive "${version}" "${buildpack_type}" + buildpackage::create "${output}" "${buildpack_type}" } function usage() { cat <<-USAGE package.sh --version [OPTIONS] -Packages the buildpack into a buildpackage .cnb file. +Packages a buildpack or an extension into a buildpackage .cnb file. OPTIONS --help -h prints the command usage - --version -v specifies the version number to use when packaging the buildpack - --output -o location to output the packaged buildpackage artifact (default: ${ROOT_DIR}/build/buildpackage.cnb) + --version -v specifies the version number to use when packaging a buildpack or an extension + --output -o location to output the packaged buildpackage or extension artifact (default: ${ROOT_DIR}/build/buildpackage.cnb) --token Token used to download assets from GitHub (e.g. jam, pack, etc) (optional) USAGE } @@ -114,8 +119,9 @@ function tools::install() { function buildpack::archive() { local version version="${1}" + buildpack_type="${2}" - util::print::title "Packaging buildpack into ${BUILD_DIR}/buildpack.tgz..." + util::print::title "Packaging ${buildpack_type} into ${BUILD_DIR}/buildpack.tgz..." if [[ -f "${ROOT_DIR}/.libbuildpack" ]]; then packager \ @@ -125,7 +131,7 @@ function buildpack::archive() { "${BUILD_DIR}/buildpack" else jam pack \ - --buildpack "${ROOT_DIR}/buildpack.toml" \ + "--${buildpack_type}" "${ROOT_DIR}/${buildpack_type}.toml"\ --version "${version}" \ --output "${BUILD_DIR}/buildpack.tgz" fi @@ -134,13 +140,30 @@ function buildpack::archive() { function buildpackage::create() { local output output="${1}" + buildpack_type="${2}" + + util::print::title "Packaging ${buildpack_type}... ${output}" - util::print::title "Packaging buildpack..." + if [ "$buildpack_type" == "extension" ]; then + cwd=$(pwd) + cd ${BUILD_DIR} + mkdir cnbdir + cd cnbdir + cp ../buildpack.tgz . + tar -xvf buildpack.tgz + rm buildpack.tgz - pack \ - buildpack package "${output}" \ - --path "${BUILD_DIR}/buildpack.tgz" \ - --format file + pack \ + extension package "${output}" \ + --format file + + cd $cwd + else + pack \ + buildpack package "${output}" \ + --path "${BUILD_DIR}/buildpack.tgz" \ + --format file + fi } -main "${@:-}" +main "${@:-}" \ No newline at end of file From c418eb54cd5f34b328103b44113645006b152fed Mon Sep 17 00:00:00 2001 From: Costas Papastathis Date: Mon, 17 Jun 2024 18:19:03 +0300 Subject: [PATCH 2/2] setting extension filepath to absolute --- implementation/scripts/package.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/implementation/scripts/package.sh b/implementation/scripts/package.sh index 52a47be8..916363eb 100755 --- a/implementation/scripts/package.sh +++ b/implementation/scripts/package.sh @@ -65,7 +65,7 @@ function main { tools::install "${token}" buildpack_type=buildpack - if [ -f "extension.toml" ]; then + if [ -f "${ROOT_DIR}/extension.toml" ]; then buildpack_type=extension fi