minecraft-pi-docker/scripts/package.sh

77 lines
2.1 KiB
Bash
Raw Normal View History

2020-09-27 00:48:46 +00:00
#!/bin/sh
2020-12-04 21:27:28 +00:00
# Current Version
DEB_VERSION='1.0.0'
# Dependencies
REQUIRED_DOCKER_VERSION='19.03'
COMMON_DEPENDENCIES="docker.io (>=${REQUIRED_DOCKER_VERSION}) | docker-ce (>=${REQUIRED_DOCKER_VERSION}), libseccomp2 (>=2.4.2), docker-compose, binfmt-support"
2020-12-16 22:55:06 +00:00
CLIENT_DEPENDENCIES="zenity, policykit-1, passwd, login, x11-xserver-utils"
RECOMMENDED_DEPENDENCIES="qemu-user-static"
2020-09-27 00:48:46 +00:00
set -e
# Docker Messes With SetGID
chmod -R g-s debian
# Clean out Directory
rm -rf out
2020-10-03 20:18:53 +00:00
mkdir -p out/deb
2020-09-27 00:48:46 +00:00
2020-12-04 21:27:28 +00:00
# Prepare
rm -rf debian/tmp
mkdir debian/tmp
# Prepare DEBIAN/control
prepare_control() {
2020-12-04 21:32:17 +00:00
sed -i 's/${VERSION}/'"${DEB_VERSION}.$(date --utc '+%Y%m%d.%H%M')"'/g' "$1/DEBIAN/control"
sed -i 's/${DEPENDENCIES}/'"${COMMON_DEPENDENCIES}$2"'/g' "$1/DEBIAN/control"
sed -i 's/${RECOMMENDED_DEPENDENCIES}/'"${RECOMMENDED_DEPENDENCIES}$2"'/g' "$1/DEBIAN/control"
2020-12-04 21:27:28 +00:00
}
2020-10-16 19:39:04 +00:00
# Package Client DEBs
2020-12-04 21:27:28 +00:00
docker save thebrokenrail/minecraft-pi:client | gzip > debian/tmp/client-image.tar.gz
2020-10-16 19:39:04 +00:00
package_client() {
2020-12-04 21:27:28 +00:00
# Clean
rm -rf "debian/tmp/$1"
# Prepare
rsync -r debian/client/common/ "debian/tmp/$1"
rsync -r "debian/client/$1/" "debian/tmp/$1"
cp debian/tmp/client-image.tar.gz "debian/tmp/$1/usr/share/minecraft-pi/client/image.tar.gz"
prepare_control "debian/tmp/$1" ", ${CLIENT_DEPENDENCIES}"
2020-12-04 21:27:28 +00:00
# Build
dpkg -b "debian/tmp/$1" out/deb
2020-10-16 19:39:04 +00:00
}
package_client virgl
package_client native
# Package Server DEB
2020-12-04 21:27:28 +00:00
docker save thebrokenrail/minecraft-pi:server | gzip > debian/tmp/server-image.tar.gz
package_server() {
# Clean
rm -rf debian/tmp/server
# Prepare
rsync -r debian/server/ debian/tmp/server
cp debian/tmp/server-image.tar.gz debian/tmp/server/usr/share/minecraft-pi/server/image.tar.gz
prepare_control debian/tmp/server ''
2020-12-04 21:27:28 +00:00
# Build
dpkg -b debian/tmp/server out/deb
}
package_server
# Clean Up
rm -rf debian/tmp
2020-10-03 20:18:53 +00:00
# Export Libraries
mkdir -p out/lib
# Copy Headers
cp -r mods/include out/lib/include
# Copy Shared Library
2020-10-10 23:02:13 +00:00
IMG_ID="$(docker create thebrokenrail/minecraft-pi:client)"
2020-10-15 02:39:30 +00:00
docker cp "${IMG_ID}":/app/minecraft-pi/mods/. ./out/lib/. || :
RET="$?"
2020-10-06 15:08:10 +00:00
docker rm -v "${IMG_ID}"
2020-10-15 02:39:30 +00:00
exit "${RET}"