From 409049e41fd2e77540c7b875c368ddbbecf883fa Mon Sep 17 00:00:00 2001 From: tgrimmer <19311462+bluescan@users.noreply.github.com> Date: Mon, 26 Aug 2024 02:17:15 -0700 Subject: [PATCH] Added a create_nix.sh.in file that turns into create_nix.sh after variable substitution. The substituted variables are enclosed in @ symbols. The script is then run when building so long as -DPACKAGE_NIX was passed to the configure step of cmake and install was specified when building. See https://github.com/bluescan/tacentview/wiki/Distributing --- CMakeLists.txt | 17 +++++++++++++++++ Linux/create_nix.sh.in | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 Linux/create_nix.sh.in diff --git a/CMakeLists.txt b/CMakeLists.txt index 08df587..558fbb7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -312,6 +312,23 @@ if (CMAKE_SYSTEM_NAME MATCHES Linux) endif() " ) + elseif (PACKAGE_NIX) + install(DIRECTORY Linux/ DESTINATION "${VIEWER_PACKAGE_DIR}") + configure_file("Linux/create_nix.sh.in" "${VIEWER_PACKAGE_DIR}/create_nix.sh" @ONLY) + install(CODE + " + execute_process(COMMAND \"chmod\" \"a+x\" \"ViewerInstall/Package/create_nix.sh\") + execute_process( + COMMAND \"ViewerInstall/Package/create_nix.sh\" + RESULT_VARIABLE package_result + ) + if (NOT package_result EQUAL \"0\") + message(FATAL_ERROR \"Viewer -- Nix package creation failed.\") + else() + message(STATUS \"Viewer -- Nix package creation succeeded.\") + endif() + " + ) endif() endif() diff --git a/Linux/create_nix.sh.in b/Linux/create_nix.sh.in new file mode 100644 index 0000000..2a3d384 --- /dev/null +++ b/Linux/create_nix.sh.in @@ -0,0 +1,32 @@ +#!/bin/bash + +cd @VIEWER_PACKAGE_DIR@ +declare -a Numbers=() + +# Version string is replaced here. +VersionString="@PROJECT_VERSION_MAJOR@.@PROJECT_VERSION_MINOR@-@PROJECT_VERSION_PATCH@" + +PackageName="tacentview_${VersionString}" +echo "Creating nix package: ${PackageName}" +rm -rf ${PackageName} +mkdir ${PackageName} + +# +# THE BELOW IS DEB-SPECIFIC AND NEEDS TO BE UPDATED FOR NIX. +# If a nix equivalent of deb_template is needed for Nix it should be +# created. The main content in the template are the control files needed to +# make a deb, plus the desktop icon files. +# +cp -rf deb_template/* ${PackageName}/ + +# Here we do a replacement of some fields in one of the deb script files. +# We replace with the actual version string. +sed -i "s//${VersionString}/" "${PackageName}/DEBIAN/control" + +cp ../tacentview "${PackageName}/usr/bin/tacentview" + +# png txt ttf +cp -f ../Assets/*.png "${PackageName}/usr/share/tacentview/Assets/" +cp -f ../Assets/*.txt "${PackageName}/usr/share/tacentview/Assets/" +cp -f ../Assets/*.ttf "${PackageName}/usr/share/tacentview/Assets/" +fakeroot dpkg-deb --build ${PackageName}