-
Notifications
You must be signed in to change notification settings - Fork 1
/
export.sh
executable file
·29 lines (23 loc) · 970 Bytes
/
export.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/bin/env bash
set -ex
readonly SEMVER=${SEMVER_MAJOR_MINOR}${SEMVER_PATCH}
readonly DOCKER_IMAGE="quay.io/metalstack/${OS_NAME}:${SEMVER}"
readonly IMAGE_BASENAME=img
readonly SEMVER_PATCH_DIR=$(echo "${SEMVER_PATCH}" | tr -d ".")
readonly TARGET_PATH="images${OUTPUT_FOLDER}/${OS_NAME}/${SEMVER_MAJOR_MINOR}/${SEMVER_PATCH_DIR}"
readonly EXPORT_DIRECTORY="../${TARGET_PATH}"
readonly TAR="${IMAGE_BASENAME}.tar"
readonly LZ4="${IMAGE_BASENAME}.tar.lz4"
readonly MD5="${IMAGE_BASENAME}.tar.lz4.md5"
readonly PKG="packages.txt"
# export tarball with checksum from docker image and package list
mkdir -p "${EXPORT_DIRECTORY}"
cd "${EXPORT_DIRECTORY}"
docker export "$(docker create "${DOCKER_IMAGE}")" > ${TAR}
docker run --rm "${DOCKER_IMAGE}" bash -c "dpkg -l" > ${PKG}
lz4 -f -9 ${TAR} ${LZ4}
rm -f ${TAR}
md5sum ${LZ4} > ${MD5}
# export a list with the generated fqdn image names
# mkdir -p workdir
echo "${OS_NAME}-${SEMVER_MAJOR_MINOR}-${SEMVER_PATCH}"