summaryrefslogtreecommitdiffstats
path: root/redhat/docker/mageia.sh
blob: 7f208caf3c4d604bb7bd5a0b48bc7381c2941e75 (plain)
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
29
30
31
32
33
34
35
#!/bin/bash -e

NAME="mageia"
VERSION="${1:-9}" # E.g: '9'
IMAGE="${NAME}:${VERSION}"
INSTALLROOT="/dev/shm/${IMAGE}"
ARCH="x86_64"
[ -x /usr/bin/pigz ] && GZIP=pigz || GZIP=gzip

sudo rm -rf "${INSTALLROOT}"
sudo mkdir -p "${INSTALLROOT}"
sudo dnf -y \
  --disablerepo="*" \
  --enablerepo="mageia-${ARCH},updates-${ARCH}" \
  --installroot="${INSTALLROOT}" \
  --releasever="${VERSION}" \
  install \
  \
  bash \
  mageia-release-common \
  urpmi \
  vim

sudo chroot "${INSTALLROOT}" rpmdb --rebuilddb

FILE="${IMAGE//\//_}.tar"
sudo tar -C "${INSTALLROOT}" -c . >"${FILE}"
sudo rm -rf "${INSTALLROOT}"

docker rmi -f "${IMAGE}"
docker import "${FILE}" "${IMAGE}"

${GZIP} "${FILE}"
mkdir -p "${HOME}/tde/docker"
mv -fv "${FILE}.gz" "${HOME}/tde/docker"