-
Notifications
You must be signed in to change notification settings - Fork 3
/
docker-build.sh
executable file
·62 lines (50 loc) · 1.58 KB
/
docker-build.sh
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/bin/sh
if [[ $UID != 0 ]]; then
echo "Please run this script with sudo:"
echo "sudo $0 $*"
exit 1
fi
## Change ownership variables.
_user=`echo ${SUDO_USER:-$(whoami)}`
_gid=`echo ${SUDO_GID}`
_group=`cat /etc/group | grep ${_gid} | cut -d: -f1 | head -1`
## iso Paths and file
_build="$(pwd)/build/"
_output="$(pwd)/Artix-Iso/"
## iso filename format
_name="artix-runit"
_version="$(date +%Y.%m.%d)"
_arch="x86_64"
_iso_filename="${_name}-${_version}-${_arch}.iso"
_finalize_build() {
local _file=$(find ${_build} -type f -name "*iso")
## Change iso filename to current format
echo "+---------------------->>"
echo "[*] Move Iso '$(basename ${_file})' as '${_iso_filename}'..."
mkdir -p ${_output}
find ${_build} -type f -name "*.iso" -exec mv {} ${_output}${_iso_filename} \;
## Change ownership
echo "+---------------------->>"
echo "[*] Change ${_output} ownership to '${_user}'..."
chown -R ${_user}:${_group} ${_output}
## Remove empty build directory
rm -rf ./build
}
## Delete existing Artix-Iso directory from home user
echo "+---------------------->>"
echo "[*] Delete existing ${_output}..."
if [[ -d ${_output} ]]; then
rm -rf ${_output}
fi
## Build Docker Image
docker build -t artix-build ./
if [ "$?" -ne 0 ]; then
exit 1
fi
## Run The Docker Image
mkdir -p ${_build} ./pacman-cache
docker run --privileged \
--mount type=bind,source="$(pwd)"/build,target=/root/artools-workspace/iso \
--mount type=bind,source="$(pwd)"/pacman-cache,target=/var/cache/pacman/pkg \
-t artix-build &&\
_finalize_build