Skip to content

Commit

Permalink
Add xz support for FCOS
Browse files Browse the repository at this point in the history
  • Loading branch information
Steven Hardy committed Nov 20, 2019
1 parent 6658b2d commit e86fdae
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
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

0 comments on commit e86fdae

Please sign in to comment.