Skip to content

Commit 8e7b8cc

Browse files
committed
clean it a bit
1 parent b48711e commit 8e7b8cc

File tree

1 file changed

+31
-12
lines changed

1 file changed

+31
-12
lines changed

docker-brew-openmandriva/mkimage-dnf.sh

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,34 @@ while true; do
3838
esac
3939
done
4040

41+
errorCatch() {
42+
printf '%s\n' "Error caught. Exiting"
43+
rm -rf "${target}"
44+
exit 1
45+
}
46+
47+
trap errorCatch ERR SIGHUP SIGINT SIGTERM
48+
49+
[ ! -S /var/run/docker.sock ] && printf '%s\n' "The /var/run/docker.sock is missing. Check your docker installation and configuration. Exiting." && exit 1
50+
51+
if [ -z $(command -v docker) ]; then
52+
printf '%s\n' "Missing docker. Installing..."
53+
54+
dnf --refresh \
55+
--nogpgcheck \
56+
--setopt=install_weak_deps=False \
57+
--nodocs \
58+
--assumeyes \
59+
install docker
60+
61+
if [ $? != 0 ]; then
62+
printf '%s\n' "Installing docker failed."
63+
errorCatch
64+
fi
65+
fi
66+
4167
if [ -z "${installversion}" ]; then
42-
# Attempt to match host version
68+
# Attempt to match host version
4369
if grep -q Cooker /etc/os-release; then
4470
installversion=cooker
4571
elif grep -q Rolling /etc/os-release; then
@@ -56,7 +82,7 @@ fi
5682
[ -z "$arch" ] && arch="$(uname -m)"
5783
[ -z "$rootfsdir" ] && rootfsdir="$common_pwd/docker-brew-openmandriva/${installversion}"
5884

59-
target=$(mktemp -d --tmpdir="$(realpath $(dirname $0))" $(basename $0).XXXXXX)
85+
target="$(mktemp -d --tmpdir=$(realpath $(dirname $0)) $(basename $0).XXXXXX)"
6086
mkdir -m 755 "$target"/dev
6187
mknod -m 600 "$target"/dev/console c 5 1
6288
mknod -m 600 "$target"/dev/initctl p
@@ -69,13 +95,6 @@ mknod -m 666 "$target"/dev/tty0 c 4 0
6995
mknod -m 666 "$target"/dev/urandom c 1 9
7096
mknod -m 666 "$target"/dev/zero c 1 5
7197

72-
errorCatch() {
73-
printf '%s\n' "Error caught. Exiting"
74-
rm -rf "${target}"
75-
exit 1
76-
}
77-
78-
trap errorCatch ERR SIGHUP SIGINT SIGTERM
7998

8099
if [ -n "${mirror}" ]; then
81100
# If mirror provided, use it exclusively
@@ -201,11 +220,11 @@ else
201220
tarFile="${rootfsdir}"/rootfs-"${installversion}".tar.xz
202221
fi
203222

204-
pushd "${target}"
223+
cd "${target}"
205224

206225
tar --numeric-owner -caf "${tarFile}" -c .
207226
[ "${rootfsdir}" = "$common_pwd/docker-brew-openmandriva/$installversion" ] || mv -f "${tarFile}" $common_pwd/docker-brew-openmandriva/$installversion/
208-
pushd $common_pwd/docker-brew-openmandriva/$installversion/
227+
cd $common_pwd/docker-brew-openmandriva/$installversion/
209228
docker build --tag=openmandriva/$installversion:$arch --file Dockerfile .
210229

211230
docker run -i -t --rm openmandriva/$installversion:$arch /bin/sh -c "printf '%s\n' success"
@@ -237,5 +256,5 @@ if [ ! -z "${builder}" ]; then
237256
docker manifest push openmandriva/builder:latest
238257
fi
239258

240-
popd
259+
cd ..
241260
rm -rf "${target}"

0 commit comments

Comments
 (0)