Revamp Packaging

This commit is contained in:
TheBrokenRail 2021-11-10 22:17:04 -05:00
parent 5cf4d7f915
commit e5fc2a61aa
23 changed files with 204 additions and 140 deletions

10
.gitignore vendored
View File

@ -1,6 +1,6 @@
/out
/debian/tmp
/.vscode
/build
/CMakeLists.txt.user
out
debian/tmp
.vscode
build
CMakeLists.txt.user
*.autosave

View File

@ -34,7 +34,7 @@ endif()
# Setup ARM Cross Compilation
if(USE_ARM32_TOOLCHAIN)
include(cmake/arm-toolchain.cmake)
include(cmake/armhf-toolchain.cmake)
endif()
# Utility Functions
@ -77,6 +77,9 @@ if(CMAKE_C_COMPILER_ID STREQUAL "Clang")
add_link_options("-fuse-ld=lld")
endif()
# PIC
set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)
# Buld LibPNG + ZLib + Download Minecraft: Pi Edition
if(BUILD_ARM_COMPONENTS)
add_subdirectory(dependencies)

View File

@ -1,8 +1,7 @@
# Compile For x86_64
include("${CMAKE_CURRENT_LIST_DIR}/base-toolchain.cmake")
if(NOT HOST_ARCHITECTURE STREQUAL "x86_64")
# Use x86_64 Cross-Compiler
setup_toolchain("x86_64-linux-gnu")
endif()
# Details
set(CMAKE_SYSTEM_NAME "Linux")
set(CMAKE_SYSTEM_PROCESSOR "x86_64")

View File

@ -1,11 +0,0 @@
# Compile For ARM
include("${CMAKE_CURRENT_LIST_DIR}/base-toolchain.cmake")
if(HOST_ARCHITECTURE STREQUAL "aarch64_be" OR HOST_ARCHITECTURE STREQUAL "aarch64" OR HOST_ARCHITECTURE STREQUAL "armv8b" OR HOST_ARCHITECTURE STREQUAL "armv8l")
# Force 32-Bit Compile
add_compile_options("-m32")
elseif((NOT HOST_ARCHITECTURE STREQUAL "arm") AND (NOT HOST_ARCHITECTURE STREQUAL "armv7l"))
# Use ARM Cross-Compiler
setup_toolchain("arm-linux-gnueabihf")
endif()
set(CMAKE_SYSTEM_NAME "Linux")
set(CMAKE_SYSTEM_PROCESSOR "arm")

View File

@ -1,8 +1,7 @@
# Compile For ARM64
include("${CMAKE_CURRENT_LIST_DIR}/base-toolchain.cmake")
if(NOT (HOST_ARCHITECTURE STREQUAL "aarch64_be" OR HOST_ARCHITECTURE STREQUAL "aarch64" OR HOST_ARCHITECTURE STREQUAL "armv8b" OR HOST_ARCHITECTURE STREQUAL "armv8l"))
# Use ARM64 Cross-Compiler
setup_toolchain("aarch64-linux-gnu")
endif()
# Details
set(CMAKE_SYSTEM_NAME "Linux")
set(CMAKE_SYSTEM_PROCESSOR "aarch64")

View File

@ -0,0 +1,7 @@
# Compile For ARM
include("${CMAKE_CURRENT_LIST_DIR}/base-toolchain.cmake")
# Use ARM Cross-Compiler
setup_toolchain("arm-linux-gnueabihf")
# Details
set(CMAKE_SYSTEM_NAME "Linux")
set(CMAKE_SYSTEM_PROCESSOR "arm")

View File

@ -2,19 +2,103 @@
find_program(UNAME uname /bin /usr/bin /usr/local/bin REQUIRED)
execute_process(COMMAND "${UNAME}" "-m" OUTPUT_VARIABLE HOST_ARCHITECTURE ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
# Pick GCC Version
macro(pick_gcc_version gcc_root gcc_version)
file(GLOB children RELATIVE "${gcc_root}" "${gcc_root}/*")
set("${gcc_version}" "")
foreach(child IN LISTS children)
if(IS_DIRECTORY "${gcc_root}/${child}" AND ("${${gcc_version}}" STREQUAL "" OR "${child}" GREATER_EQUAL "${${gcc_version}}"))
set("${gcc_version}" "${child}")
# Get Include Directories
function(get_include_dirs target compiler result)
# Get Tool Name
set(tool "cc1")
if(compiler MATCHES "^.*g\\+\\+$")
set(tool "cc1plus")
endif()
# Get Tool Path
execute_process(
COMMAND "${compiler}" "-print-prog-name=${tool}"
ERROR_QUIET
OUTPUT_VARIABLE tool
OUTPUT_STRIP_TRAILING_WHITESPACE
)
# Run Tool To Get Include Path
set(tool_output "")
execute_process(
COMMAND "${tool}" "-quiet" "-v" "-imultiarch" "${target}"
OUTPUT_QUIET
ERROR_VARIABLE tool_output
ERROR_STRIP_TRAILING_WHITESPACE
INPUT_FILE "/dev/null"
)
string(REPLACE "\n" ";" tool_output "${tool_output}")
# Loop
set(parsing_include_section FALSE)
foreach(line IN LISTS tool_output)
# Check Include Section Status
if(parsing_include_section)
# Check If Include Section Is Over
if(line MATCHES "^End of search list.$")
# Starting Include Section
set(parsing_include_section FALSE)
break()
else()
# Parsing Include Section
if(line MATCHES "^ .*$")
# Strip Line
string(STRIP "${line}" line)
# Add To List
list(APPEND "${result}" "${line}")
endif()
endif()
else()
# Check If Include Section Is Starting
if(line MATCHES "^#include <\\.\\.\\.> search starts here:$")
# Starting Include Section
set(parsing_include_section TRUE)
endif()
endif()
endforeach()
if("${${gcc_version}}" STREQUAL "")
message(FATAL_ERROR "Unable To Pick GCC Version")
# Return
set("${result}" "${${result}}" PARENT_SCOPE)
endfunction()
# Get GCC Prefix
function(get_gcc_prefix target result)
# Get Default Target
set("${result}" "" PARENT_SCOPE)
set(output "")
execute_process(
COMMAND "gcc" "-dumpmachine"
ERROR_QUIET
OUTPUT_VARIABLE output
OUTPUT_STRIP_TRAILING_WHITESPACE
)
# Check
if(NOT output STREQUAL target)
set("${result}" "${target}-" PARENT_SCOPE)
endif()
endmacro()
endfunction()
# Setup Include Directories
function(setup_include_dirs compiler target result)
# Get Full Compiler
set(prefix "")
get_gcc_prefix("${target}" prefix)
set(full_compiler "${prefix}${compiler}")
# Get Include Directories
set(include_dirs "")
get_include_dirs("${target}" "${full_compiler}" include_dirs)
# Loop
set(flags "")
foreach(include_dir IN LISTS include_dirs)
set(flags "${flags} -isystem ${include_dir}")
endforeach()
# Return
set("${result}" "${${result}} ${flags}" PARENT_SCOPE)
endfunction()
# Setup Toolchain
macro(setup_toolchain target)
@ -24,20 +108,17 @@ macro(setup_toolchain target)
set(CMAKE_CXX_COMPILER "clang++")
set(CMAKE_CXX_COMPILER_TARGET "${target}")
set(CMAKE_FIND_ROOT_PATH "/usr/${target}" "/usr/lib/${target}")
# Include Directories
pick_gcc_version("/usr/lib/gcc-cross/${target}" GCC_VERSION)
# Flags
string(CONCAT NEW_FLAGS
"-nostdinc -nostdinc++ -Wno-unused-command-line-argument "
"-isystem /usr/${target}/include/c++/${GCC_VERSION} "
"-isystem /usr/${target}/include/c++/${GCC_VERSION}/${target} "
"-isystem /usr/${target}/include/c++/${GCC_VERSION}/backward "
"-isystem /usr/lib/gcc-cross/${target}/${GCC_VERSION}/include "
"-isystem /usr/lib/gcc-cross/${target}/${GCC_VERSION}/include-fixed "
"-isystem /usr/${target}/include "
"-isystem /usr/include"
"-nostdinc "
"-nostdinc++ "
"-Wno-unused-command-line-argument"
)
set(CMAKE_C_FLAGS_INIT "${CMAKE_C_FLAGS_INIT} ${NEW_FLAGS}")
set(CMAKE_CXX_FLAGS_INIT "${CMAKE_CXX_FLAGS_INIT} ${NEW_FLAGS}")
# Include Directories
setup_include_dirs("gcc" "${target}" CMAKE_C_FLAGS_INIT)
setup_include_dirs("g++" "${target}" CMAKE_CXX_FLAGS_INIT)
# Extra
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
endmacro()

View File

@ -0,0 +1,7 @@
# Compile For i386
include("${CMAKE_CURRENT_LIST_DIR}/base-toolchain.cmake")
# Use i386 Cross-Compiler
setup_toolchain("i386-linux-gnu")
# Details
set(CMAKE_SYSTEM_NAME "Linux")
set(CMAKE_SYSTEM_PROCESSOR "i386")

6
debian/.gitignore vendored Normal file
View File

@ -0,0 +1,6 @@
*
!control
!copyright
!rukes
!source
!.gitignore

7
debian/client-arm vendored
View File

@ -1,7 +0,0 @@
Package: minecraft-pi-reborn-client
Version: ${VERSION}
Maintainer: TheBrokenRail <connor24nolan@live.com>
Description: Fun with Blocks
Homepage: https://www.minecraft.net/en-us/edition/pi
Architecture: armhf
Depends: libc6, libstdc++6, zenity, libgles1, libegl1, libglfw3 | libglfw3-wayland, libfreeimage3, libopenal1

7
debian/client-arm64 vendored
View File

@ -1,7 +0,0 @@
Package: minecraft-pi-reborn-client
Version: ${VERSION}
Maintainer: TheBrokenRail <connor24nolan@live.com>
Description: Fun with Blocks
Homepage: https://www.minecraft.net/en-us/edition/pi
Architecture: arm64
Depends: libc6, libstdc++6, libc6:armhf, libstdc++6:armhf, zenity, libgles1, libegl1, libglfw3 | libglfw3-wayland, libfreeimage3, libopenal1

View File

@ -1,7 +0,0 @@
Package: minecraft-pi-reborn-client
Version: ${VERSION}
Maintainer: TheBrokenRail <connor24nolan@live.com>
Description: Fun with Blocks
Homepage: https://www.minecraft.net/en-us/edition/pi
Architecture: amd64
Depends: libc6, libstdc++6, libc6-armhf-cross, libstdc++6-armhf-cross, zenity, libgles1, libegl1, libglfw3 | libglfw3-wayland, libfreeimage3, libopenal1, qemu-user-static

21
debian/control vendored Normal file
View File

@ -0,0 +1,21 @@
Source: minecraft-pi-reborn
Section: games
Priority: optional
Maintainer: TheBrokenRail <connor24nolan@live.com>
Build-Depends: debhelper-compat (= 12), clang:native, lld:native, cmake, make:native, libglfw3, libglfw3-dev, libfreeimage3, libfreeimage-dev:native, libopenal1, libopenal-dev, crossbuild-essential-armhf
Standards-Version: 4.4.1
Homepage: https://www.minecraft.net/en-us/edition/pi
Vcs-Browser: https://gitea.thebrokenrail.com/TheBrokenRail/minecraft-pi-reborn
Vcs-Git: https://gitea.thebrokenrail.com/TheBrokenRail/minecraft-pi-reborn.git
Package: minecraft-pi-reborn-client
Architecture: amd64 i386 arm64 armhf
Multi-Arch: foreign
Depends: libc6, libstdc++6, libc6-armhf-cross [!arm64 !armhf], libstdc++6-armhf-cross [!arm64 !armhf], zenity, libgles1, libegl1, libglfw3 | libglfw3-wayland, libfreeimage3, libopenal1, qemu-user-static [!arm64 !armhf]
Description: Fun with Blocks
Package: minecraft-pi-reborn-server
Architecture: amd64 i386 arm64 armhf
Multi-Arch: foreign
Depends: libc6, libstdc++6, libc6-armhf-cross [!arm64 !armhf], libstdc++6-armhf-cross [!arm64 !armhf], qemu-user-static [!arm64 !armhf]
Description: Fun with Blocks (Dedicated Server)

21
debian/copyright vendored Normal file
View File

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2021 TheBrokenRail
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

7
debian/server-arm vendored
View File

@ -1,7 +0,0 @@
Package: minecraft-pi-reborn-server
Version: ${VERSION}
Maintainer: TheBrokenRail <connor24nolan@live.com>
Description: Fun with Blocks
Homepage: https://www.minecraft.net/en-us/edition/pi
Architecture: armhf
Depends: libc6, libstdc++6

7
debian/server-arm64 vendored
View File

@ -1,7 +0,0 @@
Package: minecraft-pi-reborn-server
Version: ${VERSION}
Maintainer: TheBrokenRail <connor24nolan@live.com>
Description: Fun with Blocks
Homepage: https://www.minecraft.net/en-us/edition/pi
Architecture: arm64
Depends: libc6, libstdc++6, libc6:armhf, libstdc++6:armhf

View File

@ -1,7 +0,0 @@
Package: minecraft-pi-reborn-server
Version: ${VERSION}
Maintainer: TheBrokenRail <connor24nolan@live.com>
Description: Fun with Blocks
Homepage: https://www.minecraft.net/en-us/edition/pi
Architecture: amd64
Depends: libc6, libstdc++6, libc6-armhf-cross, libstdc++6-armhf-cross, qemu-user-static

View File

@ -1,14 +0,0 @@
#!/bin/sh
set -e
# Clean Prefix
rm -rf out
# Build
./scripts/build.sh client x86_64
./scripts/build.sh server x86_64
./scripts/build.sh client arm64
./scripts/build.sh server arm64
./scripts/build.sh client arm
./scripts/build.sh server arm

View File

@ -48,7 +48,7 @@ build() {
}
# Build For ARM
arm_build() {
armhf_build() {
# Create Build Dir
rm -rf "build/$1-arm"
mkdir -p "build/$1-arm"
@ -81,8 +81,8 @@ if [ "$1" != "client" ] && [ "$1" != "server" ]; then
fi
# Build
if [ "$2" = "arm" ]; then
arm_build "$1"
if [ "$2" = "armhf" ]; then
armhf_build "$1"
else
build "$1" "$2"
fi

View File

@ -14,13 +14,12 @@ echo '==== Installing Dependencies ===='
./scripts/install-dependencies.sh
# Build
echo '==== Building ===='
./scripts/build-all.sh
echo '==== Building & Packaging ===='
rm -rf out build
./scripts/package.sh amd64
./scripts/package.sh arm64
./scripts/package.sh armhf
# Test
echo '==== Testing ===='
./scripts/test.sh
# Package
echo '==== Packaging ===='
./scripts/package.sh

View File

@ -20,6 +20,7 @@ sudo apt-get dist-upgrade -y
# Install
sudo apt-get install --no-install-recommends -y \
build-essential \
ca-certificates \
lsb-release \
git \
@ -27,6 +28,10 @@ sudo apt-get install --no-install-recommends -y \
lld \
cmake \
make \
dpkg-dev \
debhelper \
devscripts \
libdistro-info-perl \
libglfw3 libglfw3-dev \
libfreeimage3 libfreeimage-dev \
crossbuild-essential-armhf \

View File

@ -3,35 +3,18 @@
set -e
# Prepare
rm -f debian/changelog
PACKAGE='minecraft-pi-reborn'
VERSION="$(cat VERSION)"
DISTRO="$(lsb_release -cs)"
EDITOR='true' NAME='TheBrokenRail' EMAIL='connor24nolan@live.com' dch -u low -v "${VERSION}" --create --distribution "${DISTRO}" --package "${PACKAGE}" "Release ${VERSION}"
# Common
package() {
local dir="out/$1"
# Create DEBIAN Dir
rm -rf "${dir}/DEBIAN"
mkdir -p "${dir}/DEBIAN"
cp "debian/$1" "${dir}/DEBIAN/control"
# Format DEBIAN/control
sed -i "s/\${VERSION}/${VERSION}/g" "${dir}/DEBIAN/control"
# Fix Permissions On Jenkins
chmod -R g-s "${dir}"
# Package
dpkg-deb --root-owner-group --build "${dir}" out
}
# Find And Package
for dir in out/*; do
# Check If Directory Exists
if [ -d "${dir}" ]; then
# Check If Debian Package Exists
pkg="$(basename ${dir})"
if [ -f "debian/${pkg}" ]; then
package "${pkg}"
# Custom Architecture
ARCH="$(dpkg-architecture -qDEB_BUILD_ARCH)"
if [ -z "$1" ]; then
ARCH="$1"
fi
fi
done
# Build
export DEB_CUSTOM_OUTPUT_DIR='out'
debuild --no-lintian -a"${ARCH}" -us -uc --buildinfo-option=-u"${DEB_CUSTOM_OUTPUT_DIR}" --changes-option=-u"${DEB_CUSTOM_OUTPUT_DIR}" -b

View File

@ -3,7 +3,7 @@
set -e
# Add minecraft-pi-reborn-server To PATH
export PATH="$(pwd)/out/server-x86_64/usr/bin:${PATH}"
export PATH="$(pwd)/out/server-$(dpkg-architecture -qDEB_HOST_ARCH)/usr/bin:${PATH}"
# Create Test Directory
rm -rf build/test