minecraft-pi-docker/scripts/package.sh

82 lines
2.2 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"
2021-03-05 00:27:24 +00:00
CLIENT_DEPENDENCIES='zenity, login, policykit-1, passwd'
2021-01-31 20:33:31 +00:00
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
2021-02-16 17:26:40 +00:00
# Version Time
DEB_VERSION_TIME="$(date --utc '+%Y%m%d.%H%M')"
# Prepare DEBIAN/control
prepare_control() {
2021-02-16 17:26:40 +00:00
sed -i 's/${VERSION}/'"${DEB_VERSION}.${DEB_VERSION_TIME}"'/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
2021-01-27 21:26:19 +00:00
docker save thebrokenrail/minecraft-pi-reborn: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
2021-01-31 02:32:20 +00:00
dpkg-deb -b --root-owner-group "debian/tmp/$1" out/deb
2020-10-16 19:39:04 +00:00
}
package_client virgl
package_client native
# Package Server DEB
2021-01-27 21:26:19 +00:00
docker save thebrokenrail/minecraft-pi-reborn:server | gzip > debian/tmp/server-image.tar.gz
2020-12-04 21:27:28 +00:00
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
2021-01-31 02:32:20 +00:00
dpkg-deb -b --root-owner-group debian/tmp/server out/deb
2020-12-04 21:27:28 +00:00
}
package_server
# Clean Up
rm -rf debian/tmp
2020-10-03 20:18:53 +00:00
# Export Libraries
mkdir -p out/lib
2021-01-27 22:05:05 +00:00
## Extract libreborn
2020-10-03 20:18:53 +00:00
# Copy Headers
2021-01-27 22:05:05 +00:00
cp -r libreborn/include out/lib/include
2020-10-03 20:18:53 +00:00
# Copy Shared Library
2021-01-27 21:26:19 +00:00
IMG_ID="$(docker create thebrokenrail/minecraft-pi-reborn:client)"
2021-01-27 22:05:05 +00:00
docker cp "${IMG_ID}:/app/minecraft-pi/mods/libreborn.so" ./out/lib || :
2021-02-03 17:28:44 +00:00
RET=$?
2020-10-06 15:08:10 +00:00
docker rm -v "${IMG_ID}"
2021-02-03 17:28:44 +00:00
exit ${RET}