Skip to content

Commit cb48ec4

Browse files
authored
Merge pull request #79 from Scalingo/feat/pkg/gzip
feat(support): use gzip to create the buildpack archive
2 parents e99377d + 2275983 commit cb48ec4

File tree

2 files changed

+49
-21
lines changed

2 files changed

+49
-21
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,12 @@ behavior and versioning on Scalingo.
4444
# Determine the root directory of your own (host) buildpack
4545
HOST_BUILDPACK_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && cd .. && pwd)"
4646

47-
JVM_BUILDPACK_URL="https://buildpacks-repository.s3.eu-central-1.amazonaws.com/jvm-common.tar.xz"
47+
JVM_BUILDPACK_URL="https://buildpacks-repository.s3.eu-central-1.amazonaws.com/jvm.tgz"
4848

4949
mkdir -p /tmp/jvm-common
5050
curl --silent --fail --retry 3 --retry-connrefused --connect-timeout 5 \
5151
--location "${JVM_BUILDPACK_URL}" \
52-
| tar --extract --xz --touch --directory=/tmp/jvm-common --strip-components=1
52+
| tar --extract --gzip --touch --directory=/tmp/jvm-common --strip-components=1
5353

5454
# Source in a sub-shell to keep your buildpack's environment clean
5555
( source /tmp/jvm-common/bin/java \

upload-jvm-common.sh

Lines changed: 47 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,46 +19,58 @@ set -e
1919
# set -x
2020

2121
print_usage() {
22-
echo "Synopsis:" >&2
23-
echo "$0" >&2
22+
echo "Synopsis:" >&2
23+
echo "$0" >&2
2424
}
2525

2626
if [[ $# -gt 0 ]]; then
27-
print_usage
28-
exit 1
27+
print_usage
28+
exit 1
2929
fi
3030

3131
cur_dir="$(cd "$(dirname "${0}")" && pwd)"
3232
cd "${cur_dir}"
3333

34-
archive_name="jvm-common.tar.xz"
34+
archive_name="jvm"
3535

36-
echo "---> Creating the archive ${archive_name}"
36+
echo "---> Creating archives"
3737

3838
jvm_common_dir="$(mktemp --tmpdir=/tmp --directory jvm-common-XXXX)"
3939
ignore_files="$(./tools/stoml ./buildpack.toml publish.Ignore.files)"
4040
exclude_opts="--exclude=tools"
4141

4242
for f in ${ignore_files}; do
43-
exclude_opts="${exclude_opts} --exclude=${f}"
43+
exclude_opts="${exclude_opts} --exclude=${f}"
4444
done
4545

4646
# We use rsync instead of cp to copy files excluding some other files
47-
rsync --recursive --perms --times --group --owner "${exclude_opts}" ./* "${jvm_common_dir}"
47+
rsync --recursive --perms --times --group --owner "${exclude_opts}" ./* \
48+
"${jvm_common_dir}"
4849

4950
if [[ $? -ne 0 ]]; then
50-
echo "Fail to copy the files to the temporary directory (${jvm_common_dir})" >&2
51-
exit 1
51+
echo "Fail to copy the files to the temporary directory (${jvm_common_dir})" >&2
52+
exit 1
5253
fi
5354

54-
tar --create --xz --file "${archive_name}" --directory "${jvm_common_dir}" .
55+
# Create legacy .tar.xz archive:
56+
tar --create --xz --file "${archive_name}-common.tar.xz" \
57+
--directory "${jvm_common_dir}" .
5558

5659
if [[ $? -ne 0 ]]; then
57-
echo "Error when creating the archive" >&2
58-
exit 1
60+
echo "Error when creating the .tar.xz archive" >&2
61+
exit 1
5962
fi
63+
echo " .tar.xz: OK."
6064

61-
echo "---> Archive created"
65+
# Create .tgz archive:
66+
tar --create --gzip --file "${archive_name}.tgz" \
67+
--directory "${jvm_common_dir}" .
68+
69+
if [[ $? -ne 0 ]]; then
70+
echo "Error when creating the .tgz archive" >&2
71+
exit 1
72+
fi
73+
echo " .tgz: OK."
6274

6375
which s3cmd >/dev/null ||
6476
echo "s3cmd is not available in your PATH" >&2 ||
@@ -67,20 +79,36 @@ which s3cmd >/dev/null ||
6779

6880
s3_bucket="buildpacks-repository"
6981

70-
echo "---> Uploading ${archive_name} to S3 (${s3_bucket})"
82+
echo "---> Uploading archives to S3 (${s3_bucket})"
7183

7284
s3cmd \
7385
--access_key="${AWS_ACCESS_KEY_ID}" \
7486
--secret_key="${AWS_SECRET_ACCESS_KEY}" \
7587
--access_token="${AWS_SESSION_TOKEN}" \
7688
--acl-public --quiet \
77-
put "${archive_name}" \
89+
put "${archive_name}-common.tar.xz" \
7890
"s3://${s3_bucket}/"
7991

8092
if [[ $? -ne 0 ]]; then
81-
echo "Error uploading the archive to S3" >&2
82-
exit 1
93+
echo "Error uploading the .tar.xz archive to S3" >&2
94+
exit 1
95+
fi
96+
echo " .tar.xz: OK."
97+
98+
s3cmd \
99+
--access_key="${AWS_ACCESS_KEY_ID}" \
100+
--secret_key="${AWS_SECRET_ACCESS_KEY}" \
101+
--access_token="${AWS_SESSION_TOKEN}" \
102+
--acl-public --quiet \
103+
put "${archive_name}.tgz" \
104+
"s3://${s3_bucket}/"
105+
106+
if [[ $? -ne 0 ]]; then
107+
echo "Error uploading the .tgz archive to S3" >&2
108+
exit 1
83109
fi
110+
echo " .tgz: OK."
111+
84112

85113
echo "---> Deleting the temporary files"
86-
rm -r "${jvm_common_dir}" "${archive_name}"
114+
rm -r "${jvm_common_dir}" "${archive_name}-common.tar.xz" "${archive_name}.tgz"

0 commit comments

Comments
 (0)