Skip to content

Commit

Permalink
Added a create_nix.sh.in file that turns into create_nix.sh after var…
Browse files Browse the repository at this point in the history
…iable 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
  • Loading branch information
bluescan committed Aug 26, 2024
1 parent cbfb28a commit 409049e
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
17 changes: 17 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
32 changes: 32 additions & 0 deletions Linux/create_nix.sh.in
Original file line number Diff line number Diff line change
@@ -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 <ViewerVersionString> with the actual version string.
sed -i "s/<ViewerVersionString>/${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}

0 comments on commit 409049e

Please sign in to comment.