Rework Packaging

This commit is contained in:
TheBrokenRail 2020-12-04 16:27:28 -05:00
parent 4bf4cfee8e
commit 0dbb53e0e7
15 changed files with 102 additions and 63 deletions

View File

@ -1,23 +1,33 @@
FROM arm32v7/debian:bullseye
# Runtime Base Environment
FROM arm32v7/debian:bullseye-slim AS runtime-base
# Install Dependencies
ENV DEBIAN_FRONTEND noninteractive
RUN \
# Install Runtime Dependencies
apt-get update && \
apt-get install -y libglvnd-dev libsdl1.2-dev libx11-dev build-essential cmake zlib1g-dev git curl libfreeimage-dev libglfw3-dev xinput libxfixes-dev
apt-get install -y --no-install-recommends libgles1 libx11-6 libsdl1.2debian zlib1g libfreeimage3 libglfw3 xinput libxfixes3 && \
rm -rf /var/lib/apt/lists/*
# Setup GLES Location
RUN ln -s /usr/lib/arm-linux-gnueabihf/libGLESv2.so.2 /usr/lib/libGLESv2.so
# Compile Environment
FROM runtime-base AS build
ENV DEBIAN_FRONTEND noninteractive
RUN \
# Install Dependencies
apt-get update && \
apt-get install -y --no-install-recommends libgles-dev libx11-dev libxrandr-dev libsdl1.2-dev gcc g++ libc-dev make cmake zlib1g-dev git wget ca-certificates libfreeimage-dev libglfw3-dev xinput libxfixes-dev && \
rm -rf /var/lib/apt/lists/*
# Add Build Scripts
ADD ./build /app/build
WORKDIR /app
# Download MCPI
RUN ./build/download-minecraft-pi.sh
# Build LibPNG12
RUN ./build/build-libpng12.sh
RUN \
# Download MCPI
./build/download-minecraft-pi.sh && \
# Build LibPNG12
./build/build-libpng12.sh
# Add Code
ADD . /app
@ -25,6 +35,14 @@ ADD . /app
# Build Mods
RUN ./build/build-mods.sh
WORKDIR ./minecraft-pi
# Runtime Environment
FROM runtime-base AS runtime
# Include Exported Libraries
COPY --from=build /app/export /
# Include Mods
COPY --from=build /app/minecraft-pi /app/minecraft-pi
WORKDIR /app/minecraft-pi
ENTRYPOINT ./launcher

View File

@ -9,7 +9,7 @@ cd libpng
./configure --prefix /usr
make -j$(nproc)
make install
make install DESTDIR=/app/export
cd ../

View File

@ -5,4 +5,4 @@ set -e
URL="https://www.minecraft.net/content/dam/minecraft/edition-pi/minecraft-pi-0.1.1.tar.gz"
mkdir minecraft-pi
curl "${URL}" | tar -xz --strip-components 1 -C minecraft-pi
wget -O - "${URL}" | tar -xz --strip-components 1 -C minecraft-pi

View File

@ -7,4 +7,9 @@ add_compile_options(-Wall -Wextra -Werror)
add_library(bcm_host SHARED src/stubs/bcm_host.c)
add_library(EGL SHARED src/stubs/EGL.c)
# MCPI Links Against GLESv2 But Requires GLESv1_CM
add_library(GLESv2 SHARED src/stubs/GLESv2.c)
target_link_libraries(GLESv2 GLESv1_CM)
target_link_options(GLESv2 PRIVATE "-Wl,--no-as-needed")
add_executable(launcher src/launcher.c)

1
core/src/stubs/GLESv2.c Normal file
View File

@ -0,0 +1 @@
// NOP

View File

@ -2,4 +2,4 @@
set -e
MCPI_FEATURES='' MCPI_USERNAME='' docker-compose -f /usr/share/minecraft-pi/client/docker-compose.yml pull
docker load < /usr/share/minecraft-pi/client/image.tar.gz

View File

@ -33,7 +33,6 @@ xhost local:root
# Update Docker Container
export DOCKER_COMPOSE="docker-compose -f /usr/share/minecraft-pi/client/docker-compose.yml"
(${DOCKER_COMPOSE} pull || :) | zenity --class 'Minecraft - Pi edition' --progress --pulsate --no-cancel --auto-close --text 'Updating Minecraft...'
# Run
exec sg docker /usr/lib/minecraft-pi/run.sh

View File

@ -1,5 +1,5 @@
Package: minecraft-pi-native
Version: 1.0.0
Version: ${VERSION}
Maintainer: TheBrokenRail <connor24nolan@live.com>
Description: Fun with Blocks
Homepage: https://www.minecraft.net/en-us/edition/pi

View File

@ -1,5 +1,5 @@
Package: minecraft-pi-virgl
Version: 1.0.0
Version: ${VERSION}
Maintainer: TheBrokenRail <connor24nolan@live.com>
Description: Fun with Blocks
Homepage: https://www.minecraft.net/en-us/edition/pi

View File

@ -1,5 +1,5 @@
Package: minecraft-pi-server
Version: 1.0.0
Version: ${VERSION}
Maintainer: TheBrokenRail <connor24nolan@live.com>
Description: Fun with Blocks
Homepage: https://www.minecraft.net/en-us/edition/pi

View File

@ -2,4 +2,4 @@
set -e
MCPI_ROOT='' docker-compose -f /usr/share/minecraft-pi/server/docker-compose.yml pull
docker load < /usr/share/minecraft-pi/server/image.tar.gz

View File

@ -6,5 +6,4 @@ export MCPI_ROOT="${PWD}"
# Launch Minecraft
DOCKER_COMPOSE="docker-compose -f /usr/share/minecraft-pi/server/docker-compose.yml"
${DOCKER_COMPOSE} pull || :
${DOCKER_COMPOSE} run --rm minecraft-pi-server

View File

@ -2,20 +2,24 @@ cmake_minimum_required(VERSION 3.13.0)
project(mods)
add_compile_options(-g -Wall -Wextra -Werror)
add_compile_options(-Wall -Wextra -Werror)
add_link_options(-Wl,--no-undefined)
# Disable C++11 String ABI
add_definitions(-D_GLIBCXX_USE_CXX11_ABI=0)
add_subdirectory(../core core)
# Include Libraries Exported To Runtime Environment
include_directories(/app/export/include)
# Include Headers
include_directories(include)
# Find GLFW
find_package(glfw3 3.3 REQUIRED)
add_library(compat SHARED src/compat/compat.c)
target_link_libraries(compat feature input screenshot SDL GLESv1_CM GLESv2 X11 dl glfw Xfixes)
# Force GLESv1 Link
target_link_options(compat PRIVATE "-Wl,--no-as-needed")
target_link_libraries(compat feature input screenshot SDL GLESv1_CM X11 dl glfw Xfixes)
add_library(readdir SHARED src/compat/readdir.c)

View File

@ -22,22 +22,9 @@
#include "../init/init.h"
static GLFWwindow *glfw_window;
static Display *x11_display;
static Window x11_window;
static Window x11_root_window;
static int window_loaded = 0;
static int is_server = 0;
// Get Reference To X Window
static void store_x11_window() {
x11_display = glfwGetX11Display();
x11_window = glfwGetX11Window(glfw_window);
x11_root_window = RootWindow(x11_display, DefaultScreen(x11_display));
window_loaded = 1;
}
// Handle GLFW Error
static void glfw_error(__attribute__((unused)) int error, const char *description) {
ERR("GLFW Error: %s", description);
@ -211,8 +198,6 @@ HOOK(SDL_WM_SetCaption, void, (const char *title, __attribute__((unused)) const
glfwSetMouseButtonCallback(glfw_window, glfw_click);
glfwSetScrollCallback(glfw_window, glfw_scroll);
store_x11_window();
glfwMakeContextCurrent(glfw_window);
}
}
@ -247,7 +232,7 @@ static void toggle_fullscreen() {
} else {
glfwGetWindowSize(glfw_window, &old_width, &old_height);
glfwGetWindowPos(glfw_window, &old_x, &old_y);
Screen *screen = DefaultScreenOfDisplay(x11_display);
Screen *screen = DefaultScreenOfDisplay(glfwGetX11Display());
glfwSetWindowMonitor(glfw_window, glfwGetPrimaryMonitor(), 0, 0, WidthOfScreen(screen), HeightOfScreen(screen), GLFW_DONT_CARE);
}
@ -334,14 +319,14 @@ HOOK(SDL_WM_GrabInput, SDL_GrabMode, (SDL_GrabMode mode)) {
glfwSetInputMode(glfw_window, GLFW_RAW_MOUSE_MOTION, mode == SDL_GRAB_OFF ? GLFW_FALSE : GLFW_TRUE);
// GLFW Cursor Hiding is Broken
if (window_loaded) {
if (mode == SDL_GRAB_OFF) {
XFixesShowCursor(x11_display, x11_window);
} else {
XFixesHideCursor(x11_display, x11_window);
}
XFlush(x11_display);
Display *x11_display = glfwGetX11Display();
Window x11_window = glfwGetX11Window(glfw_window);
if (mode == SDL_GRAB_OFF) {
XFixesShowCursor(x11_display, x11_window);
} else {
XFixesHideCursor(x11_display, x11_window);
}
XFlush(x11_display);
}
return mode == SDL_GRAB_QUERY ? (glfwGetInputMode(glfw_window, GLFW_CURSOR) == GLFW_CURSOR_NORMAL ? SDL_GRAB_OFF : SDL_GRAB_ON) : mode;
}
@ -364,12 +349,9 @@ HOOK(SDL_SetVideoMode, SDL_Surface *, (__attribute__((unused)) int width, __attr
HOOK(XTranslateCoordinates, int, (Display *display, Window src_w, Window dest_w, int src_x, int src_y, int *dest_x_return, int *dest_y_return, Window *child_return)) {
if (!is_server) {
// Use X11
ensure_XTranslateCoordinates();
if (window_loaded) {
return (*real_XTranslateCoordinates)(x11_display, x11_window, x11_root_window, src_x, src_y, dest_x_return, dest_y_return, child_return);
} else {
return (*real_XTranslateCoordinates)(display, src_w, dest_w, src_x, src_y, dest_x_return, dest_y_return, child_return);
}
return (*real_XTranslateCoordinates)(display, src_w, dest_w, src_x, src_y, dest_x_return, dest_y_return, child_return);
} else {
// No X11
*dest_x_return = src_x;
@ -380,12 +362,9 @@ HOOK(XTranslateCoordinates, int, (Display *display, Window src_w, Window dest_w,
HOOK(XGetWindowAttributes, int, (Display *display, Window w, XWindowAttributes *window_attributes_return)) {
if (!is_server) {
// Use X11
ensure_XGetWindowAttributes();
if (window_loaded) {
return (*real_XGetWindowAttributes)(x11_display, x11_window, window_attributes_return);
} else {
return (*real_XGetWindowAttributes)(display, w, window_attributes_return);
}
return (*real_XGetWindowAttributes)(display, w, window_attributes_return);
} else {
// No X11
XWindowAttributes attributes;
@ -406,6 +385,9 @@ HOOK(SDL_GetWMInfo, int, (SDL_SysWMinfo *info)) {
SDL_SysWMinfo ret;
ret.info.x11.lock_func = x11_nop;
ret.info.x11.unlock_func = x11_nop;
ret.info.x11.display = glfwGetX11Display();
ret.info.x11.window = glfwGetX11Window(glfw_window);
ret.info.x11.wmwindow = ret.info.x11.window;
*info = ret;
return 1;
}

View File

@ -1,5 +1,8 @@
#!/bin/sh
# Current Version
DEB_VERSION='1.0.0'
set -e
# Docker Messes With SetGID
@ -9,19 +12,47 @@ chmod -R g-s debian
rm -rf out
mkdir -p out/deb
# Prepare
rm -rf debian/tmp
mkdir debian/tmp
# Set Version
prepare_version() {
sed -i 's/${VERSION}/'"${DEB_VERSION}.$(date '+%Y%m%d.%H%M')"'/g' "$1/DEBIAN/control"
}
# Package Client DEBs
docker save thebrokenrail/minecraft-pi:client | gzip > debian/tmp/client-image.tar.gz
package_client() {
rm -rf debian/tmp
rsync -r debian/client/common/ debian/tmp
rsync -r "debian/client/$1/" debian/tmp
dpkg -b debian/tmp out/deb
rm -rf debian/tmp
# 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_version "debian/tmp/$1"
# Build
dpkg -b "debian/tmp/$1" out/deb
}
package_client virgl
package_client native
# Package Server DEB
dpkg -b debian/server out/deb
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_version debian/tmp/server
# Build
dpkg -b debian/tmp/server out/deb
}
package_server
# Clean Up
rm -rf debian/tmp
# Export Libraries
mkdir -p out/lib