-
Notifications
You must be signed in to change notification settings - Fork 1
/
docker-ce.SlackBuild
executable file
·139 lines (111 loc) · 4.16 KB
/
docker-ce.SlackBuild
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#!/bin/sh
# Copyright 2018 Zak B. Elep, Makati, Metro Manila, Philippines
# All rights reserved.
#
# Redistribution and use of this script, with or without modification, is
# permitted provided that the following conditions are met:
#
# 1. Redistributions of this script must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR IMPLIED
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
PKGNAM=docker-ce
RELEASE=${RELEASE:-20.10.12}
ARCH="x86_64"
BUILD=${BUILD:-1zakame}
if [ ! "$(id -u)" = 0 ]; then
cat << EOF
This script must be run as root.
EOF
exit 1
fi
if ! /bin/ls "docker-${RELEASE}.tgz" 1> /dev/null 2> /dev/null ; then
cat << EOF
This is a script to repackage a statically-linked Docker CE release
for Slackware. Run this script in the same directory as this
binary package:
docker-${RELEASE}.tgz
This will create a Slackware .txz package. Install it with installpkg
or use upgradepkg to upgrade from a previous version.
EOF
exit 1
fi
DOCKER_GID=${DOCKER_GID:-281}
if ! /bin/grep ^docker: /etc/group 1> /dev/null 2> /dev/null ; then
cat << EOF
You must have a docker group to run this script:
# groupadd -r -g $DOCKER_GID docker
EOF
exit 1
fi
CWD=$(pwd)
TMP=${TMP:-/tmp}
PKG=$TMP/package-$PKGNAM
OUTPUT=${OUTPUT:-/tmp}
rm -rf "$PKG"
mkdir -p "$TMP" "$PKG" "$OUTPUT"
cd "$PKG" || exit 1
tar xf "$CWD/docker-${RELEASE}.tgz" || exit 1
chown -R root:root .
chmod -R u+w,go+r-w,a-s .
# Make sure top-level perms are correct:
chmod 0755 .
# Move the binaries into place:
install -d -m 755 "$PKG/usr/bin/"
install -p -m 755 "$PKG/docker/docker" "$PKG/usr/bin/"
install -p -m 755 "$PKG/docker/containerd" "$PKG/usr/bin/"
install -p -m 755 "$PKG/docker/ctr" "$PKG/usr/bin/"
install -p -m 755 "$PKG/docker/containerd-shim" "$PKG/usr/bin/"
install -p -m 755 "$PKG/docker/containerd-shim-runc-v2" "$PKG/usr/bin/"
install -p -m 755 "$PKG/docker/docker-init" "$PKG/usr/bin/"
install -p -m 755 "$PKG/docker/docker-proxy" "$PKG/usr/bin/"
install -p -m 755 "$PKG/docker/runc" "$PKG/usr/bin/"
install -p -m 755 "$PKG/docker/dockerd" "$PKG/usr/bin/"
rm -fr "$PKG/docker/"
# Install configuration:
install -D -m644 "$CWD/config/docker.default" "$PKG/etc/default/docker.new"
install -D -m644 "$CWD/config/docker.logrotate" "$PKG/etc/logrotate.d/docker.new"
install -D -m755 "$CWD/config/rc.docker" "$PKG/etc/rc.d/rc.docker.new"
# Track containerd managed /opt
install -d -m 711 "$PKG/opt/containerd/"
install -d -m 711 "$PKG/opt/containerd/bin/"
install -d -m 711 "$PKG/opt/containerd/lib/"
mkdir -p "$PKG/install"
cat "$CWD/slack-desc" > "$PKG/install/slack-desc"
cat <<EOINS >> "$PKG/install/doinst.sh"
# Handle the incoming configuration files:
config() {
for infile in \$1; do
NEW="\$infile"
OLD="\`dirname \$NEW\`/\`basename \$NEW .new\`"
# If there's no config file by that name, mv it over:
if [ ! -r \$OLD ]; then
mv \$NEW \$OLD
elif [ "\`cat \$OLD | md5sum\`" = "\`cat \$NEW | md5sum\`" ]; then
# toss the redundant copy
rm \$NEW
fi
# Otherwise, we leave the .new copy for the admin to consider...
done
}
# Keep same perms on rc.docker.new:
if [ -e etc/rc.d/rc.docker ]; then
cp -a etc/rc.d/rc.docker etc/rc.d/rc.docker.new.incoming
cat etc/rc.d/rc.docker.new > etc/rc.d/rc.docker.new.incoming
mv etc/rc.d/rc.docker.new.incoming etc/rc.d/rc.docker.new
fi
config etc/rc.d/rc.docker.new
config etc/default/docker.new
config etc/logrotate.d/docker.new
EOINS
cd "$PKG" || exit 1
/sbin/makepkg -l y -c n "$OUTPUT/$PKGNAM-$RELEASE-$ARCH-$BUILD.txz"