From dd0dbc2510f8223ee1c8266d89da275a6544f5d5 Mon Sep 17 00:00:00 2001 From: Fincer Date: Thu, 22 Nov 2018 23:00:19 +0200 Subject: [PATCH] Debian: add dxvk.debdata, improve dxvkbuild.sh --- debian/dxvkroot/dxvk.debdata | 41 +++++++++- debian/dxvkroot/dxvkbuild.sh | 136 +++++++++++++------------------- debian/dxvkroot/glslang.debdata | 14 +++- debian/dxvkroot/meson.debdata | 14 +++- 4 files changed, 117 insertions(+), 88 deletions(-) diff --git a/debian/dxvkroot/dxvk.debdata b/debian/dxvkroot/dxvk.debdata index abb9710..ec4ca97 100755 --- a/debian/dxvkroot/dxvk.debdata +++ b/debian/dxvkroot/dxvk.debdata @@ -1,3 +1,6 @@ +######################################################## +# Common properties + pkg_name="dxvk-git" pkg_license="custom --copyrightfile ../LICENSE" pkg_maintainer="${USER} <${USER}@unknown>" @@ -5,6 +8,8 @@ pkg_section="otherosfs" pkg_priority="optional" pkg_arch="all" +dxvx_relative_builddir="debian/source/dxvk-master" + pkg_commondesc="Vulkan-based D3D11 and D3D10 implementation for Linux / Wine" pkg_longdesc=" A Vulkan-based translation layer for Direct3D 10/11 which @@ -17,11 +22,12 @@ pkg_homeurl="https://github.com/doitsujin/dxvk" git_commithash=${git_commithash_dxvk} pkg_gitver="git describe --long | sed 's/\-[a-z].*//; s/\-/\./; s/[a-z]//g'" +pkg_installfile="./debian/install" pkg_controlfile="./debian/control" pkg_rulesfile="./debian/rules" ######################################################## -# Debian rules file override +# Debian rules file section pkg_debrules="\ #!/usr/bin/make -f @@ -32,9 +38,34 @@ pkg_debrules="\ override_dh_auto_configure: override_dh_usrlocal: + +override_dh_install: + + # Compile DXVK + bash ./package-release.sh master debian/source/ --no-package + + # Tell deb builder to create DXVK x32 & x64 subfolders + for arch in 32 64; do mkdir -p ${dxvx_relative_builddir}/x${arch}; done + + # Make a proper executable script folder for setup_dxvk.verb file + mkdir -p ${dxvx_relative_builddir}/bin + + echo -e \"#!/bin/sh\nwinetricks --force /usr/share/dxvk/setup_dxvk.verb\" > \"${dxvx_relative_builddir}/bin/setup_dxvk\" + chmod +x "${dxvx_relative_builddir}/bin/setup_dxvk" + dh_install " ######################################################## +# Debian install file section + +pkg_debinstall="\ +${dxvx_relative_builddir}/setup_dxvk.verb usr/share/dxvk/ +${dxvx_relative_builddir}/bin/* usr/bin/ +$(for arch in 32 64; do echo -e ${dxvx_relative_builddir}/x${arch}/* usr/share/dxvk/x${arch}/; done) +" + +######################################################## +# Debian control file subfields # Debian control file Overrides section pkg_overrides=( @@ -66,7 +97,7 @@ pkg_provides=( empty ) -############## +############################ # Build time dependencies pkg_deps_build=( @@ -97,6 +128,12 @@ pkg_extra_2=( empty ) +############################ + +# Deb builder execution field +# Do not build either debug symbols or doc files +pkg_debbuilder="DEB_BUILD_OPTIONS=\"strip nodocs noddebs\" dpkg-buildpackage -us -uc -b --source-option=--include-binaries" + ######################################################## # Contents of Debian control file diff --git a/debian/dxvkroot/dxvkbuild.sh b/debian/dxvkroot/dxvkbuild.sh index eb0ded0..7ff74b3 100755 --- a/debian/dxvkroot/dxvkbuild.sh +++ b/debian/dxvkroot/dxvkbuild.sh @@ -85,6 +85,8 @@ done ######################################################## +# PRESENCE OF WINE + # Check presence of Wine. Some version of Wine should # be found in the system in order to install DXVK. @@ -180,11 +182,10 @@ function pkgcompilecheck() { ######################################################## -# DXVK COMPILATION & INSTALLATION +# DXVK CUSTOM INSTALLATION HOOKS # These are custom installation instructions for DXVK -# They are not used independently, but as a part of -# preparepackage function below. +# They are not used independently. function dxvk_install_custom() { @@ -212,6 +213,7 @@ function dxvk_install_custom() { } ############################ +# DXVK - CUSTOM PATCHES # Add and apply custom DXVK patches function dxvk_custompatches() { @@ -256,74 +258,23 @@ function dxvk_install_custom() { } ############################ +# DXVK - CUSTOM HOOKS EXECUTION -# DXVK - - # Debian-specific compilation & installation rules for DXVK - function dxvk_custom_deb_build() { - - local dxvx_relative_builddir="debian/source/dxvk-master" - - # Tell deb builder to bundle these files - printf "${dxvx_relative_builddir}/setup_dxvk.verb usr/share/dxvk/" > debian/install - printf "\n${dxvx_relative_builddir}/bin/* usr/bin/" >> debian/install - - # Start DXVK compilation - bash ./package-release.sh master debian/source/ --no-package - - if [[ $? -ne 0 ]]; then - echo -e "\e[1mERROR:\e[0m Error while compiling ${pkg_name}. Check messages above. Aborting\n" - buildpkg_removal - exit 1 - fi - - # Make a proper executable script for setup_dxvk.verb file - mkdir -p ${dxvx_relative_builddir}/bin - - echo -e "#!/bin/sh\nwinetricks --force /usr/share/dxvk/setup_dxvk.verb" \ - > "${dxvx_relative_builddir}/bin/setup_dxvk" - chmod +x "${dxvx_relative_builddir}/bin/setup_dxvk" - - # Tell deb builder to install DXVK x32 & x64 subfolders - for arch in 64 32; do - mkdir -p ${dxvx_relative_builddir}/x${arch} - printf "\n${dxvx_relative_builddir}/x${arch}/* usr/share/dxvk/x${arch}/" >> debian/install - done - - # Start deb builder. Do not build either debug symbols or doc files - DEB_BUILD_OPTIONS="strip nodocs noddebs" dpkg-buildpackage -us -uc -b --source-option=--include-binaries - - # Once compiled, possibly install and store the compiled deb archive - if [[ $? -eq 0 ]]; then - - if [[ ! -v NO_INSTALL ]]; then - sudo dpkg -i ../${pkgname}*.deb - fi - - rm -rf ../*.{changes,buildinfo,tar.xz} - mv ../${pkg_name}*.deb ../../../compiled_deb/"${datedir}" && \ - echo -e "Compiled ${pkg_name} is stored at '$(readlink -f ../../../compiled_deb/"${datedir}")/'\n" - cd ../.. - rm -rf ${pkg_name} - else - exit 1 - fi - } - -############################ - -# DXVK dxvk_custompatches && \ dxvk_posixpkgs && \ dxvk_custom_deb_build } ######################################################## +# COMMON - COMPILE AND INSTALL DEB PACKAGE + +# Instructions to compile and install a deb package +# on Debian system # Global variable to track buildtime dependencies z=0 -function preparepackage() { +function compile_and_install_deb() { ############################ @@ -333,19 +284,23 @@ function preparepackage() { local _pkg_giturl="${3}" local _git_commithash="${4}" local _pkg_gitver="${5}" - local _pkg_debcontrol="${6}" - local _pkg_debrules="${7}" - local _pkg_controlfile="${8}" - local _pkg_rulesfile="${9}" - local _pkg_deps_build="${10}" - local _pkg_deps_runtime="${11}" - local _pkg_debbuilder="${12}" + local _pkg_debinstall="${6}" + local _pkg_debcontrol="${7}" + local _pkg_debrules="${8}" + local _pkg_installfile="${9}" + local _pkg_controlfile="${10}" + local _pkg_rulesfile="${11}" + local _pkg_deps_build="${12}" + local _pkg_deps_runtime="${13}" + local _pkg_debbuilder="${14}" ############################ +# COMMON - ARRAY PARAMETER FIX + +# Separate array indexes correctly +# We have streamed all array indexes, separated +# by | symbol. We reconstruct the arrays here. - # Separate array indexes correctly - # We have streamed all array indexes, separated - # by | symbol. We reconstruct the arrays here. function arrayparser_reverse() { local arrays=( @@ -375,8 +330,10 @@ function preparepackage() { echo -e "Starting compilation$(if [[ ! -v NO_INSTALL ]] || [[ ${_pkg_name} =~ ^meson|glslang$ ]]; then printf " & installation"; fi) of ${_pkg_name}\n" ############################ +# COMMON - PACKAGE DEPENDENCIES CHECK + +# Check and install package related dependencies if they are missing - # Check and install package related dependencies if they are missing function pkg_dependencies() { local _pkg_list="${1}" @@ -432,10 +389,13 @@ function preparepackage() { } ############################ +# COMMON - RETRIEVE PACKAGE +# GIT VERSION TAG + +# Get git-based version in order to rename the package main folder +# This is required by deb builder. It retrieves the version number +# from that folder name - # Get git-based version in order to rename the package main folder - # This is required by deb builder. It retrieves the version number - # from that folder name function pkg_gitversion() { if [[ -n "${_pkg_gitver}" ]] && [[ "${_pkg_gitver}" =~ ^git ]]; then @@ -452,13 +412,18 @@ function preparepackage() { } ############################ +# COMMON - OVERWRITE +# DEBIAN BUILD ENV FILES + +# Overwrite a file which is given as user input +# The contents are supplied as input, too. function pkg_override_debianfile() { local contents=${1} local targetfile=${2} - if [[ $(echo ${contents} | wc -w) -ne 0 ]]; then + if [[ ${contents} != "empty" ]]; then echo "${contents}" > "${targetfile}" if [[ $? -ne 0 ]]; then echo -e "\e[1mERROR:\e[0m Couldn't create Debian file '${targetfile}' for ${_pkg_name}. Aborting\n" @@ -468,6 +433,8 @@ function preparepackage() { } ############################ +# COMMON - GET SOURCE AND +# PREPARE SOURCE FOLDER function pkg_folderprepare() { @@ -489,6 +456,7 @@ function preparepackage() { cd ${_pkg_name}-${_pkg_gitver} dh_make --createorig -s -y -c ${_pkg_license} && \ + pkg_override_debianfile "${_pkg_debinstall}" "${_pkg_installfile}" pkg_override_debianfile "${_pkg_debcontrol}" "${_pkg_controlfile}" pkg_override_debianfile "${_pkg_debrules}" "${_pkg_rulesfile}" @@ -500,6 +468,8 @@ function preparepackage() { } ############################ +# COMMON - COMPILE, INSTALL +# AND STORE DEB PACKAGE function pkg_debianbuild() { @@ -516,14 +486,15 @@ function preparepackage() { cd ../.. rm -rf ${_pkg_name} else + buildpkg_removal exit 1 fi } ############################ +# COMMON - EXECUTION HOOKS - # Execute above functions pkg_dependencies "${_pkg_deps_build[*]}" buildtime && \ if [[ ${_pkg_deps_runtime[0]} != "empty" ]] && [[ ! -v NO_INSTALL ]]; then @@ -533,11 +504,10 @@ function preparepackage() { pkg_folderprepare # TODO use package name or separate override switch here? - if [[ ${_pkg_name} != "dxvk-git" ]]; then - pkg_debianbuild - else + if [[ ${_pkg_name} == *"dxvk"* ]]; then dxvk_install_custom - fi + fi + pkg_debianbuild unset _pkg_gitver @@ -585,7 +555,7 @@ function pkg_install_main() { ############################ - # Prepare these arrays for preparepackage input + # Prepare these arrays for 'compile_and_install_deb' input # Separate each array index with | in these arrays function pkg_arrayparser() { @@ -610,14 +580,16 @@ function pkg_install_main() { # Execute package installation procedure pkg_arrayparser && \ - preparepackage \ + compile_and_install_deb \ "${pkg_name}" \ "${pkg_license}" \ "${pkg_giturl}" \ "${git_commithash}" \ "${pkg_gitver}" \ + "${pkg_debinstall}" \ "${pkg_debcontrol}" \ "${pkg_debrules}" \ + "${pkg_installfile}" \ "${pkg_controlfile}" \ "${pkg_rulesfile}" \ "${pkg_deps_build}" \ diff --git a/debian/dxvkroot/glslang.debdata b/debian/dxvkroot/glslang.debdata index a73be65..0063b05 100755 --- a/debian/dxvkroot/glslang.debdata +++ b/debian/dxvkroot/glslang.debdata @@ -1,3 +1,6 @@ +######################################################## +# Common properties + pkg_name="glslang" pkg_license="bsd" pkg_maintainer="${USER} <${USER}@unknown>" @@ -16,11 +19,12 @@ pkg_homeurl="https://www.khronos.org/opengles/sdk/tools/Reference-Compiler/" git_commithash=${git_commithash_glslang} pkg_gitver="git describe --long | sed 's/\-[a-z].*//; s/\-/\./; s/[a-z]//g'" +pkg_installfile="./debian/install" pkg_controlfile="./debian/control" pkg_rulesfile="./debian/rules" ######################################################## -# Debian rules file override +# Debian rules file section pkg_debrules="\ #!/usr/bin/make -f @@ -32,6 +36,12 @@ override_dh_usrlocal: " ######################################################## +# Debian install file section + +pkg_debinstall="empty" + +######################################################## +# Debian control file subfields # Debian control file Overrides section pkg_overrides=( @@ -63,7 +73,7 @@ pkg_provides=( empty ) -############## +############################ # Build time dependencies pkg_deps_build=( diff --git a/debian/dxvkroot/meson.debdata b/debian/dxvkroot/meson.debdata index eabe1e6..5372697 100755 --- a/debian/dxvkroot/meson.debdata +++ b/debian/dxvkroot/meson.debdata @@ -1,3 +1,6 @@ +######################################################## +# Common properties + pkg_name="meson" pkg_license="apache" pkg_maintainer="${USER} <${USER}@unknown>" @@ -18,11 +21,12 @@ pkg_homeurl="http://mesonbuild.com" git_commithash=${git_commithash_meson} pkg_gitver="git describe --long | sed 's/\-[a-z].*//; s/\-/\./; s/[a-z]//g'" +pkg_installfile="./debian/install" pkg_controlfile="./debian/control" pkg_rulesfile="./debian/rules" ######################################################## -# MESON - Debian rules file override +# Debian rules file section pkg_debrules="\ #!/usr/bin/make -f @@ -63,6 +67,12 @@ override_dh_install: " ######################################################## +# Debian install file section + +pkg_debinstall="empty" + +######################################################## +# Debian control file subfields # Debian control file Overrides section pkg_overrides=( @@ -94,7 +104,7 @@ pkg_provides=( empty ) -############## +############################ # Build time dependencies pkg_deps_build=(