Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add xz support for FCOS #15

Merged
merged 1 commit into from
Nov 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
FROM docker.io/centos:centos7

RUN yum install -y epel-release && yum update -y && yum install -y qemu-img jq && yum clean all
RUN yum install -y epel-release && yum update -y && yum install -y qemu-img jq xz && yum clean all

COPY ./get-resource.sh /usr/local/bin/get-resource.sh
2 changes: 1 addition & 1 deletion Dockerfile.ocp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM ubi8

RUN yum update -y \
&& yum install -y qemu-img jq \
&& yum install -y qemu-img jq xz \
&& yum clean all

COPY ./get-resource.sh /usr/local/bin/get-resource.sh
Expand Down
12 changes: 7 additions & 5 deletions get-resource.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ if [ -z "$RHCOS_IMAGE_URL" ] ; then
fi

# When provided by openshift-installer the URL is like
# "https://releases-art-rhcos.svc.ci.openshift.org/art/storage/releases/rhcos-4.2/420.8.20190708.2/rhcos-420.8.20190708.2-openstack.qcow2?sha256=xxx"
# "https://releases-art-rhcos.svc.ci.openshift.org/art/storage/releases/rhcos-4.2/420.8.20190708.2/rhcos-420.8.20190708.2-openstack.qcow2.gz?sha256=xxx"
# NOTE: strip sha256 query string in the image url
RHCOS_IMAGE_URL_STRIPPED=`echo $RHCOS_IMAGE_URL | cut -f 1 -d \?`
if [[ $RHCOS_IMAGE_URL_STRIPPED = *.qcow2 ]] || [[ $RHCOS_IMAGE_URL_STRIPPED = *.qcow2.gz ]]
then
if [[ $RHCOS_IMAGE_URL_STRIPPED =~ qcow2.[gx]z$ ]]; then
RHCOS_IMAGE_FILENAME_RAW=$(basename $RHCOS_IMAGE_URL_STRIPPED)
RHCOS_IMAGE_FILENAME_OPENSTACK=${RHCOS_IMAGE_FILENAME_RAW/.gz}
RHCOS_IMAGE_FILENAME_OPENSTACK=${RHCOS_IMAGE_FILENAME_RAW/.[gx]z}
IMAGE_FILENAME_EXTENSION=${RHCOS_IMAGE_FILENAME_RAW/$RHCOS_IMAGE_FILENAME_OPENSTACK}
IMAGE_URL=$(dirname $RHCOS_IMAGE_URL_STRIPPED)
else
echo "Unexpected image format $RHCOS_IMAGE_URL"
Expand All @@ -38,8 +38,10 @@ elif curl -I --fail "$CACHEURL/$RHCOS_IMAGE_FILENAME_OPENSTACK/$RHCOS_IMAGE_FILE
else
curl -g --insecure --compressed -L -o "${RHCOS_IMAGE_FILENAME_RAW}" "${IMAGE_URL}/${RHCOS_IMAGE_FILENAME_RAW}"

if [[ $RHCOS_IMAGE_FILENAME_RAW == *.gz ]]; then
if [[ $IMAGE_FILENAME_EXTENSION == .gz ]]; then
gzip -d "$RHCOS_IMAGE_FILENAME_RAW"
elif [[ $IMAGE_FILENAME_EXTENSION == .xz ]]; then
unxz "$RHCOS_IMAGE_FILENAME_RAW"
fi

qemu-img convert -O qcow2 -c "$RHCOS_IMAGE_FILENAME_OPENSTACK" "$RHCOS_IMAGE_FILENAME_COMPRESSED"
Expand Down