diff options
Diffstat (limited to 'redhat/docker/opensuse32.sh')
-rwxr-xr-x | redhat/docker/opensuse32.sh | 52 |
1 files changed, 38 insertions, 14 deletions
diff --git a/redhat/docker/opensuse32.sh b/redhat/docker/opensuse32.sh index 1a78e6340..82d315ed9 100755 --- a/redhat/docker/opensuse32.sh +++ b/redhat/docker/opensuse32.sh @@ -1,9 +1,13 @@ #!/bin/bash -e +if [ "$(whoami)" != "root" ]; then + sudo exec $0 $@ +fi + VERSION="$1" # E.g: '42.3' if [ "${VERSION}" = "tumbleweed" ]; then - URL="http://download.opensuse.org/tumbleweed" + URL="https://download.opensuse.org/ports/i586/tumbleweed" NAME="opensuse32/tumbleweed" else URL="http://download.opensuse.org/distribution/leap/${VERSION}" @@ -13,25 +17,38 @@ fi IMAGE="${NAME}:latest" INSTALLROOT="/dev/shm/${IMAGE}" -sudo rm -rf "${INSTALLROOT}" -sudo mkdir -p "${INSTALLROOT}" +for dir in dev proc sys; do + if [ -d "${INSTALLROOT}/${dir}" ]; then + umount "${INSTALLROOT}/${dir}" + fi +done + +rm -rf "${INSTALLROOT}" +mkdir -p "${INSTALLROOT}" -sudo zypper --root "${INSTALLROOT}" \ +for dir in dev proc sys; do + mkdir -p "${INSTALLROOT}/${dir}" + mount --bind "/${dir}" "${INSTALLROOT}/${dir}" +done + +zypper --root "${INSTALLROOT}" \ ar "${URL}/repo/oss/" "oss" -sudo zypper --root "${INSTALLROOT}" \ +zypper --root "${INSTALLROOT}" \ ar "${URL}/repo/non-oss/" "non-oss" if [ "${VERSION}" != "tumbleweed" ]; then - sudo zypper --root "${INSTALLROOT}" \ + zypper --root "${INSTALLROOT}" \ ar "http://download.opensuse.org/update/leap/${VERSION}/oss/" "update-oss" - sudo zypper --root "${INSTALLROOT}" \ + zypper --root "${INSTALLROOT}" \ ar "http://download.opensuse.org/update/leap/${VERSION}/non-oss/" "update-non-oss" fi -sudo zypper --root "${INSTALLROOT}" \ +zypper --root "${INSTALLROOT}" \ --gpg-auto-import-keys ref -sudo setarch i686 zypper --root "${INSTALLROOT}" \ +setarch i686 zypper --root "${INSTALLROOT}" \ install --download-only -y \ bash \ + ca-certificates \ + curl \ docbook-utils \ filesystem \ gawk \ @@ -47,16 +64,23 @@ sudo setarch i686 zypper --root "${INSTALLROOT}" \ xz \ zlib \ zypper -sudo rpm -Uvh --root "${INSTALLROOT}" "${INSTALLROOT}/var/cache/zypp/packages/oss/"*"/"*".rpm" +rpm -Uvh --root "${INSTALLROOT}" "${INSTALLROOT}/var/cache/zypp/packages/oss/"*"/"*".rpm" + +chroot "${INSTALLROOT}" rpmdb --rebuilddb + +for dir in dev proc sys; do + umount "${INSTALLROOT}/${dir}" +done -sudo chroot "${INSTALLROOT}" rpmdb --rebuilddb +rm -rfv "${INSTALLROOT}//var/cache/zypp/packages/"* FILE="${IMAGE//\//_}.tar" -sudo tar -C "${INSTALLROOT}" -c . >"${FILE}" -sudo rm -rf "${INSTALLROOT}" +tar -C "${INSTALLROOT}" -c . >"${FILE}" +rm -rf "${INSTALLROOT}" docker rmi -f "${IMAGE}" docker import "${FILE}" "${IMAGE}" pigz "${FILE}" -mv -fv "${FILE}.gz" "${HOME}/tde/docker" +mkdir -p "/home/${SUDO_USER}/tde/docker" +mv -fv "${FILE}.gz" "/home/${SUDO_USER}/tde/docker" |