summaryrefslogtreecommitdiff
path: root/distribution
diff options
context:
space:
mode:
Diffstat (limited to 'distribution')
-rw-r--r--distribution/CMakeLists.txt10
-rw-r--r--distribution/fedora/README26
-rw-r--r--distribution/fedora/xtrkcad-5.2.2GA-xtrkcad.desktop.patch106
-rw-r--r--distribution/fedora/xtrkcad.spec97
-rw-r--r--distribution/osx/CMakeLists.txt2
-rwxr-xr-xdistribution/osx/gtk-bundle/xtrkcad-launcher.sh4
-rw-r--r--distribution/osx/gtk-bundle/xtrkcad-template.dmg.zipbin3990654 -> 2641265 bytes
-rw-r--r--distribution/posix/CMakeLists.txt67
-rwxr-xr-xdistribution/posix/postinst14
-rwxr-xr-xdistribution/posix/prerm15
-rw-r--r--distribution/win32/CMakeLists.txt5
-rw-r--r--distribution/win32/nsis/CMakeLists.txt29
-rw-r--r--distribution/win32/nsis/install.nsh27
-rw-r--r--distribution/win32/nsis/uninstall.nsh29
14 files changed, 388 insertions, 43 deletions
diff --git a/distribution/CMakeLists.txt b/distribution/CMakeLists.txt
index fc63769..30acac7 100644
--- a/distribution/CMakeLists.txt
+++ b/distribution/CMakeLists.txt
@@ -1,11 +1,16 @@
# Setup global packaging parameters ...
SET(CPACK_PACKAGE_DESCRIPTION "XTrackCad is a CAD program for designing model railroad layouts.")
SET(CPACK_PACKAGE_EXECUTABLES "xtrkcad;XTrkCAD ${XTRKCAD_VERSION}")
-SET(CPACK_PACKAGE_FILE_NAME "xtrkcad-setup-${XTRKCAD_VERSION}")
+IF(WIN32)
+ # Add suffix
+ SET(CPACK_PACKAGE_FILE_NAME "xtrkcad-setup-${XTRKCAD_VERSION}-${XTRKCAD_ARCH_SUBDIR}")
+ELSE(WIN32)
+ SET(CPACK_PACKAGE_FILE_NAME "xtrkcad-setup-${XTRKCAD_VERSION}")
+ENDIF(WIN32)
SET(CPACK_PACKAGE_INSTALL_DIRECTORY "XTrkCAD ${XTRKCAD_VERSION}")
SET(CPACK_PACKAGE_INSTALL_REGISTRY_KEY "XTrkCAD ${XTRKCAD_VERSION}")
SET(CPACK_PACKAGE_NAME "xtrkcad")
-SET(CPACK_PACKAGE_VENDOR "http://www.xtrkcad.org")
+SET(CPACK_PACKAGE_VENDOR "XTrackCAD Project")
SET(CPACK_PACKAGE_VERSION ${XTRKCAD_VERSION})
SET(CPACK_PACKAGE_VERSION_MAJOR ${XTRKCAD_MAJOR_VERSION})
SET(CPACK_PACKAGE_VERSION_MINOR ${XTRKCAD_MINOR_VERSION})
@@ -28,4 +33,3 @@ ENDIF(UNIX AND NOT APPLE)
IF(WIN32)
ADD_SUBDIRECTORY(win32)
ENDIF(WIN32)
-
diff --git a/distribution/fedora/README b/distribution/fedora/README
new file mode 100644
index 0000000..239b454
--- /dev/null
+++ b/distribution/fedora/README
@@ -0,0 +1,26 @@
+202220315
+This is repository of the files needed to make a fedora release.
+
+Temporary patches needed for 5.2.2, delete on next GA
+xtrkcad-5.2.2GA-xtrkcad.desktop.patch
+
+Builds the needed fedora rpms
+xtrkcad.spec
+Also needs (not saved here)
+xtrkcad-source-5.2.2GA.tar.gz
+
+builds the fc37 rpms
+fedpkg --release rawhide mockbuild
+
+builds fc35 rpms
+fedpkg --release f 35 mockbuild
+
+Built xtrkcad-5.2.2-1.fc35.x86_64.rpm installs as
+a graphical app, Can be selected by Applications->Graphics->XTrackCAD
+
+https://bugzilla.redhat.com/show_bug.cgi?id=2040728
+2040728 - xtrkcad - CAD for Model Railroad layout
+Approved 03/15 Comment #21
+
+
+
diff --git a/distribution/fedora/xtrkcad-5.2.2GA-xtrkcad.desktop.patch b/distribution/fedora/xtrkcad-5.2.2GA-xtrkcad.desktop.patch
new file mode 100644
index 0000000..54f74dc
--- /dev/null
+++ b/distribution/fedora/xtrkcad-5.2.2GA-xtrkcad.desktop.patch
@@ -0,0 +1,106 @@
+diff -ru orig/xtrkcad-source-5.2.2GA/app/bin/CMakeLists.txt xtrkcad-source-5.2.2GA/app/bin/CMakeLists.txt
+--- orig/xtrkcad-source-5.2.2GA/app/bin/CMakeLists.txt 2021-12-18 12:12:02.000000000 -0500
++++ xtrkcad-source-5.2.2GA/app/bin/CMakeLists.txt 2022-02-21 15:22:10.656926058 -0500
+@@ -169,7 +169,6 @@
+ utility.c
+ utility.h
+ validator.c
+- cJSON.c
+ archive.h
+ directory.h
+ manifest.h
+@@ -237,10 +236,7 @@
+ # This ensures that messages.h has been generated before we build xtrkcad-lib
+ ADD_DEPENDENCIES(xtrkcad-lib Help)
+
+-TARGET_LINK_LIBRARIES(xtrkcad xtrkcad-lib)
+-TARGET_LINK_LIBRARIES(xtrkcad xtrkcad-wlib)
+-TARGET_LINK_LIBRARIES(xtrkcad xtrkcad-cornu)
+-TARGET_LINK_LIBRARIES(xtrkcad dynstring)
++TARGET_LINK_LIBRARIES(xtrkcad xtrkcad-lib xtrkcad-wlib xtrkcad-cornu dynstring cjson)
+ if(XTRKCAD_CREATE_SVG)
+ IF(UNIX)
+ if (NOT APPLE)
+diff -ru orig/xtrkcad-source-5.2.2GA/app/bin/fileio.c xtrkcad-source-5.2.2GA/app/bin/fileio.c
+--- orig/xtrkcad-source-5.2.2GA/app/bin/fileio.c 2021-12-18 10:31:35.000000000 -0500
++++ xtrkcad-source-5.2.2GA/app/bin/fileio.c 2022-02-20 10:51:17.258176965 -0500
+@@ -20,7 +20,7 @@
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+-#include <cJSON.h>
++#include <cjson/cJSON.h>
+
+ #include "archive.h"
+ #include "common.h"
+Only in orig/xtrkcad-source-5.2.2GA/app/bin/include: dirent.h
+Only in xtrkcad-source-5.2.2GA/app/bin/include: dirent.h.phil
+diff -ru orig/xtrkcad-source-5.2.2GA/app/bin/manifest.c xtrkcad-source-5.2.2GA/app/bin/manifest.c
+--- orig/xtrkcad-source-5.2.2GA/app/bin/manifest.c 2021-12-18 10:31:34.000000000 -0500
++++ xtrkcad-source-5.2.2GA/app/bin/manifest.c 2022-02-20 10:51:14.426213927 -0500
+@@ -21,7 +21,7 @@
+
+ #include <string.h>
+
+-#include "cJSON.h"
++#include <cjson/cJSON.h>
+ #include "fileio.h"
+ #include "layout.h"
+ #include "misc2.h"
+diff -ru orig/xtrkcad-source-5.2.2GA/app/help/CMakeLists.txt xtrkcad-source-5.2.2GA/app/help/CMakeLists.txt
+--- orig/xtrkcad-source-5.2.2GA/app/help/CMakeLists.txt 2021-12-18 10:27:44.000000000 -0500
++++ xtrkcad-source-5.2.2GA/app/help/CMakeLists.txt 2022-02-21 15:24:51.868816364 -0500
+@@ -1,6 +1,6 @@
+ PROJECT(help)
+
+-ADD_EXECUTABLE(genhelp genhelp.c cJSON.c cJSON.h)
++ADD_EXECUTABLE(genhelp genhelp.c)
+
+ ADD_EXECUTABLE(genmessages genmessages.c)
+
+@@ -10,6 +10,8 @@
+ SET(GENMESSAGES_OPTS "")
+ ENDIF(XTRKCAD_USE_GETTEXT)
+
++TARGET_LINK_LIBRARIES(genhelp PUBLIC cjson)
++
+ ADD_CUSTOM_COMMAND(
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/messages.h ${CMAKE_CURRENT_BINARY_DIR}/messages.but
+ DEPENDS genmessages ${CMAKE_CURRENT_SOURCE_DIR}/messages.in
+diff -ru orig/xtrkcad-source-5.2.2GA/app/help/genhelp.c xtrkcad-source-5.2.2GA/app/help/genhelp.c
+--- orig/xtrkcad-source-5.2.2GA/app/help/genhelp.c 2021-12-18 10:27:44.000000000 -0500
++++ xtrkcad-source-5.2.2GA/app/help/genhelp.c 2022-02-20 10:28:37.155745877 -0500
+@@ -20,7 +20,7 @@
+ #include <stdlib.h>
+ #include <stdio.h>
+ #include <string.h>
+-#include "cJSON.h"
++#include <cjson/cJSON.h>
+
+ #define I18NHEADERFILE "i18n.h"
+
+diff -ru orig/xtrkcad-source-5.2.2GA/app/lib/CMakeLists.txt xtrkcad-source-5.2.2GA/app/lib/CMakeLists.txt
+--- orig/xtrkcad-source-5.2.2GA/app/lib/CMakeLists.txt 2021-12-18 12:12:02.000000000 -0500
++++ xtrkcad-source-5.2.2GA/app/lib/CMakeLists.txt 2022-02-21 15:25:06.717622045 -0500
+@@ -42,10 +42,6 @@
+ endif()
+
+ if(UNIX AND NOT APPLE)
+- install(PROGRAMS
+- xdg-open xtrkcad-setup
+- DESTINATION ${XTRKCAD_SHARE_INSTALL_DIR}
+- )
+ install(FILES
+ xtrkcad.desktop xtrkcad.xml
+ DESTINATION "${XTRKCAD_SHARE_INSTALL_DIR}/applications"
+diff -ru orig/xtrkcad-source-5.2.2GA/CMakeLists.txt xtrkcad-source-5.2.2GA/CMakeLists.txt
+--- orig/xtrkcad-source-5.2.2GA/CMakeLists.txt 2021-12-18 13:10:04.000000000 -0500
++++ xtrkcad-source-5.2.2GA/CMakeLists.txt 2022-02-21 15:30:10.711643816 -0500
+@@ -1,6 +1,6 @@
+ PROJECT(XTrkCAD)
+ enable_testing()
+-cmake_minimum_required(VERSION 2.8)
++cmake_minimum_required(VERSION 3.22)
+ set(CMAKE_MACOSX_RPATH 0)
+
+ # where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is checked
diff --git a/distribution/fedora/xtrkcad.spec b/distribution/fedora/xtrkcad.spec
new file mode 100644
index 0000000..eae4a74
--- /dev/null
+++ b/distribution/fedora/xtrkcad.spec
@@ -0,0 +1,97 @@
+Name: xtrkcad
+Summary: CAD for Model Railroad layout
+Version: 5.2.2
+Release: 1%{?dist}
+License: GPLv2
+URL: https://sourceforge.net/projects/xtrkcad-fork
+Source0: https://sourceforge.net/projects/xtrkcad-fork/files/XTrackCad/Version%20%{version}/xtrkcad-source-%{version}GA.tar.gz
+# patch (to be removed on next GA release)
+# patch0 adds xtrkcad.desktop to build - Changed upstream
+# It also uses cJSON and xdg-utils packages
+Patch0: xtrkcad-5.2.2GA-xtrkcad.desktop.patch
+
+BuildRequires: gcc
+BuildRequires: gcc-c++
+BuildRequires: cmake >= 2.4.7
+BuildRequires: pkgconfig
+BuildRequires: gtk2-devel
+BuildRequires: libzip-devel
+BuildRequires: desktop-file-utils
+BuildRequires: gettext-devel
+BuildRequires: glibc-devel
+BuildRequires: pandoc
+BuildRequires: doxygen
+BuildRequires: cjson-devel
+
+Requires: xdg-utils
+
+%description
+XTrkCad is a CAD program for designing Model Railroad layouts.
+XTrkCad supports any scale, has libraries of popular brands of x
+turnouts and sectional track (plus you add your own easily), can
+automatically use spiral transition curves when joining track
+XTrkCad lets you manipulate track much like you would with actual
+flex-track to modify, extend and join tracks and turnouts.
+Additional features include tunnels, 'post-it' notes, on-screen
+ruler, parts list, 99 drawing layers, undo/redo commands,
+benchwork, 'Print to BitMap', elevations, train simulation and
+car inventory.
+
+%prep
+%setup -n xtrkcad-source-%{version}GA -q
+
+# removed on next GA release
+%patch0 -p1
+
+%package doc
+Summary: Documentation for %{name}
+BuildArch: noarch
+
+%description doc
+This package contains user documentation for XTrkCad,
+in HTML format. It also contains demos, and examples.
+
+%build
+%cmake -DBUILD_SHARED_LIBS=OFF -DXTRKCAD_USE_DOXYGEN=ON
+%cmake_build
+
+%install
+%cmake_install
+
+desktop-file-install --dir=%{buildroot}/%{_datadir}/applications \
+ %{buildroot}/%{_datadir}/%{name}/applications/xtrkcad.desktop
+rm %{buildroot}/%{_datadir}/%{name}/applications/xtrkcad.desktop
+
+mkdir -p %{buildroot}/%{_datadir}/pixmaps
+mv %{buildroot}/%{_datadir}/%{name}/pixmaps/xtrkcad.png \
+ %{buildroot}/%{_datadir}/pixmaps/xtrkcad.png
+rm -rf %{buildroot}/%{_datadir}/%{name}/pixmaps
+
+mkdir -p %{buildroot}/%{_datadir}/mime/packages
+mv %{buildroot}/%{_datadir}/%{name}/applications/xtrkcad.xml \
+ %{buildroot}/%{_datadir}/mime/packages/xtrkcad.xml
+
+# Tests require a feature in the next release
+#%check
+#%ctest
+
+%files
+%license app/COPYING
+%{_bindir}/%{name}
+%{_datadir}/applications/xtrkcad.desktop
+%{_datadir}/pixmaps/xtrkcad.png
+%{_datadir}/mime/packages/xtrkcad.xml
+%{_datadir}/%{name}
+%exclude %{_datadir}/%{name}/demos
+%exclude %{_datadir}/%{name}/examples
+%exclude %{_datadir}/%{name}/html
+
+%files doc
+%{_datadir}/%{name}/demos
+%{_datadir}/%{name}/examples
+%{_datadir}/%{name}/html
+
+%changelog
+* Mon Feb 21 2022 Phil Cameron <pecameron1 -at- gmail.com> 5.2.2-1
+- V5.2.2 GA
+
diff --git a/distribution/osx/CMakeLists.txt b/distribution/osx/CMakeLists.txt
index 2561fae..6e4dd05 100644
--- a/distribution/osx/CMakeLists.txt
+++ b/distribution/osx/CMakeLists.txt
@@ -1,5 +1,5 @@
# Automatically generate most of our external dependencies ...
-GET_TARGET_PROPERTY(XTRKCAD_LOCATION xtrkcad LOCATION)
+SET(XTRKCAD_LOCATION $<TARGET_FILE:xtrkcad>)
CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/dependencies.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/dependencies.cmake" @ONLY)
INSTALL(SCRIPT "${CMAKE_CURRENT_BINARY_DIR}/dependencies.cmake")
diff --git a/distribution/osx/gtk-bundle/xtrkcad-launcher.sh b/distribution/osx/gtk-bundle/xtrkcad-launcher.sh
index 30988e5..69aac1e 100755
--- a/distribution/osx/gtk-bundle/xtrkcad-launcher.sh
+++ b/distribution/osx/gtk-bundle/xtrkcad-launcher.sh
@@ -36,7 +36,7 @@ if type -p "X" & > /dev/null; then
fi
#XTRKCAD_BUNDLE="`echo "$0" | sed -e 's/\/Contents\/MacOS\/XTrackCAD//'`"
-XTRKCAD_BUNDLE="$bundle"
+XTRKCAD_BUNDLE="`echo "$bundle" | sed -e 's_/Contents/MacOS/XTrackCAD_/_'`"
XTRKCAD_RESOURCES="$XTRKCAD_BUNDLE/Contents/Resources"
XTRKCAD_TEMP="/tmp/xtrkcad/$UID"
XTRKCAD_ETC="$XTRKCAD_TEMP/etc"
@@ -52,7 +52,7 @@ export GTK_DATA_PREFIX="$bundle_res"
export GTK_EXE_PREFIX="$bundle_res"
export GTK_PATH="$bundle_res"
-export GTK2_RC_FILES="$bundle_etc/gtk-2.0/gtkrc"
+# export GTK2_RC_FILES="$bundle_etc/gtk-2.0/gtkrc"
XTRKCAD_PANGO_RC_FILE="$XTRKCAD_RESOURCES/etc/pango/pangorc"
I18NDIR="$bundle_data/locale"
diff --git a/distribution/osx/gtk-bundle/xtrkcad-template.dmg.zip b/distribution/osx/gtk-bundle/xtrkcad-template.dmg.zip
index bb6972a..2e7663b 100644
--- a/distribution/osx/gtk-bundle/xtrkcad-template.dmg.zip
+++ b/distribution/osx/gtk-bundle/xtrkcad-template.dmg.zip
Binary files differ
diff --git a/distribution/posix/CMakeLists.txt b/distribution/posix/CMakeLists.txt
index 96636b0..f202791 100644
--- a/distribution/posix/CMakeLists.txt
+++ b/distribution/posix/CMakeLists.txt
@@ -1,6 +1,6 @@
# Setup packaging ...
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "XTrackCAD is a CAD program for designing model railroad layouts.")
-set(CPACK_GENERATOR "RPM" "STGZ")
+set(CPACK_GENERATOR "DEB" "RPM" "STGZ")
set(CPACK_SOURCE_GENERATOR "TGZ" "TBZ2" "ZIP")
set(CPACK_PACKAGE_RELEASE 1)
set(CPACK_RPM_PACKAGE_LICENSE "GPL")
@@ -8,7 +8,13 @@ set(CPACK_RPM_PACKAGE_GROUP "Applications/Engineering")
set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}////xtrkcad-desc.txt")
set(CPACK_PACKAGE_FILE_NAME "xtrkcad-setup-${XTRKCAD_VERSION}-${CPACK_PACKAGE_RELEASE}.${CMAKE_SYSTEM_PROCESSOR}")
-set(CPACK_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX} )
+if(XTRKCAD_BETA MATCHES "-beta")
+ set(CPACK_INSTALL_PREFIX "/usr/local" )
+else()
+ set(CPACK_INSTALL_PREFIX "/usr" )
+ set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${CMAKE_CURRENT_SOURCE_DIR}/postinst;${CMAKE_CURRENT_SOURCE_DIR}/prerm")
+endif()
+
set(CPACK_PACKAGING_INSTALL_PREFIX ${CPACK_INSTALL_PREFIX})
# get the specific configuration for each packager
@@ -17,14 +23,26 @@ set(CPACK_PROJECT_CONFIG_FILE ${CMAKE_CURRENT_SOURCE_DIR}/package.txt)
set(CPACK_PACKAGE_VENDOR "XTrackCAD Fork Project")
# common dependencies for all Linux builds
-set(CPACK_RPM_PACKAGE_REQUIRES "glibc gtk2")
+set(CPACK_RPM_PACKAGE_REQUIRES "glibc gtk2 zlib")
+
+set(CPACK_RPM_BUILDREQUIRES
+ "gcc, cmake >= 2.4.7, pkgconfig, gtk2-devel"
+ "gettext, gettext-devel, glibc-devel"
+)
# Add dependency to webkitgtk if configured
if(NOT XTRKCAD_USE_BROWSER)
- set(CPACK_RPM_PACKAGE_REQUIRES
- "${CPACK_RPM_PACKAGE_REQUIRES} webkitgtk")
+ set(CPACK_RPM_PACKAGE_REQUIRES
+ "${CPACK_RPM_PACKAGE_REQUIRES} webkitgtk")
+# message(AUTHOR_WARNING "Add dependency to webkitgtk for viewing help!")
endif()
+#Add dependency to MiniXML (mxml) if configured
+if(XTRKCAD_CREATE_SVG)
+ set(CPACK_RPM_PACKAGE_REQUIRES
+ "${CPACK_RPM_PACKAGE_REQUIRES} mxml")
+endif()
+
# exclude these directories from the rpm
set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION
"/usr/local"
@@ -40,5 +58,42 @@ set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION
set(CPACK_RPM_CHANGELOG_FILE "${CMAKE_CURRENT_SOURCE_DIR}////changelog.txt")
-include(CPack)
+set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
+
+set(CPACK_DEBIAN_PACKAGE_NAME "XTrkCad${XTRKCAD_BETA}")
+
+set(CPACK_DEBIAN_PACKAGE_VERSION "1:${XTRKCAD_VERSION}")
+
+set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "amd64")
+
+set(CPACK_DEBIAN_PACKAGE_DEPENDS "xdg-utils")
+
+set(CPACK_DEBIAN_PACKAGE_MAINTAINER "xtrkcad@sillub.com")
+set(CPACK_PACKAGE_CONTACT "xtrkcad@sillub.com")
+
+set(CPACK_DEBIAN_PACKAGE_DESCRIPTION "XTrkCad supports any scale, has libraries of popular brands of \
+turnouts and sectional track (plus you add your own easily), can \
+automatically use spiral transition curves when joining track \
+XTrkCad lets you manipulate track much like you would with actual \
+flex-track to modify, extend and join tracks and turnouts. \
+Additional features include tunnels, 'post-it' notes, on-screen \
+ruler, parts list, 99 drawing layers, undo/redo commands, \
+benchwork, 'Print to BitMap', elevations, train simulation and \
+car inventory. \
+")
+
+
+set(CPACK_DEBIAN_PACKAGE_SECTION "contrib/graphics")
+
+set(CPACK_DEBIAN_PACKAGE_COMPRESSION "gzip")
+
+set(CPACK_DEBIAN_PACKAGE_PRIORITY "optional")
+
+set(CPACK_DEBIAN_PACKAGE_HOMEPAGE "xtrkcad.org")
+
+set(CPACK_PACKAGE_EXECUTABLES "xtrkcad;XTrkCad-5.2.1-Beta")
+
+set(CPACK_CREATE_DESKTOP_LINKS "xtrkcad")
+
+include(CPack)
diff --git a/distribution/posix/postinst b/distribution/posix/postinst
new file mode 100755
index 0000000..969aa7e
--- /dev/null
+++ b/distribution/posix/postinst
@@ -0,0 +1,14 @@
+#!/bin/sh
+LOGF=/tmp/xtrkcad-setup.log
+if [ -f "${LOGF}" ] ; then
+ chmod 666 ${LOGF}
+ echo postinst: $* >> ${LOGF}
+else
+ LOGF=/dev/null
+fi
+
+INSTALLDIR=/usr/share/xtrkcad
+
+( su -c "sh ${INSTALLDIR}/xtrkcad-setup install ${INSTALLDIR}" -l $SUDO_USER ) >> ${LOGF} 2>&1
+
+exit 0
diff --git a/distribution/posix/prerm b/distribution/posix/prerm
new file mode 100755
index 0000000..b5ae917
--- /dev/null
+++ b/distribution/posix/prerm
@@ -0,0 +1,15 @@
+#!/bin/sh
+LOGF=/tmp/xtrkcad-setup.log
+if [ -f "${LOGF}" ] ; then
+ chmod 666 ${LOGF}
+ echo prerm: $* >> ${LOGF}
+else
+ LOGF=/dev/null
+fi
+
+INSTALLDIR=/usr/share/xtrkcad
+
+( su -c "sh ${INSTALLDIR}/xtrkcad-setup remove ${INSTALLDIR}" -l $SUDO_USER ) >> ${LOGF} 2>&1
+
+exit 0
+
diff --git a/distribution/win32/CMakeLists.txt b/distribution/win32/CMakeLists.txt
index 80ecfe3..3a46c7f 100644
--- a/distribution/win32/CMakeLists.txt
+++ b/distribution/win32/CMakeLists.txt
@@ -1,4 +1,3 @@
-SET(CPACK_SOURCE_GENERATOR "ZIP")
-
-ADD_SUBDIRECTORY(nsis)
+set(CPACK_SOURCE_GENERATOR "ZIP")
+add_subdirectory(nsis)
diff --git a/distribution/win32/nsis/CMakeLists.txt b/distribution/win32/nsis/CMakeLists.txt
index 40d3990..ef1775c 100644
--- a/distribution/win32/nsis/CMakeLists.txt
+++ b/distribution/win32/nsis/CMakeLists.txt
@@ -1,17 +1,26 @@
-STRING(REPLACE "/" "\\\\" NATIVE_CURRENT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
+string(REPLACE "/" "\\\\" NATIVE_CURRENT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
-SET(CPACK_GENERATOR "NSIS")
-SET(CPACK_PACKAGE_ICON "${NATIVE_CURRENT_SOURCE_DIR}\\\\headerimage.bmp")
-SET(CPACK_NSIS_INSTALLED_ICON_NAME "bin\\\\xtrkcad.exe")
-SET(CPACK_NSIS_HELP_LINK "http://www.xtrkcad.org")
+set(CPACK_GENERATOR "NSIS")
+set(CPACK_PACKAGE_INSTALL_DIRECTORY "XTrackCAD")
+set(CPACK_NSIS_EXECUTABLE_NAME "bin\\\\xtrkcad.exe")
+set(CPACK_NSIS_DISPLAY_NAME "XTrackCAD ${CPACK_PACKAGE_VERSION}")
+set(CPACK_PACKAGE_ICON "${NATIVE_CURRENT_SOURCE_DIR}\\\\headerimage.bmp")
+set(CPACK_NSIS_INSTALLED_ICON_NAME "bin\\\\xtrkcad.exe")
+set(CPACK_NSIS_HELP_LINK "http://www.xtrkcad.org")
+set(CPACK_NSIS_MUI_FINISHPAGE_RUN "xtrkcad.exe")
+set(CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL "on")
+set(CMAKE_INSTALL_OPENMP_LIBRARIES TRUE)
-SET(CPACK_NSIS_EXTRA_INSTALL_COMMANDS
+set(CPACK_NSIS_STARTMENU_FOLDER "XTrackCAD")
+
+set(CPACK_NSIS_EXTRA_INSTALL_COMMANDS
"; add part specific to XTrackCAD installation
!include \\\"${NATIVE_CURRENT_SOURCE_DIR}\\\\install.nsh\\\"")
-
-SET(CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS
+
+set(CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS
"; add part specific to XTrackCAD uninstall
!include \\\"${NATIVE_CURRENT_SOURCE_DIR}\\\\uninstall.nsh\\\"")
-
-INCLUDE(CPack)
+include (InstallRequiredSystemLibraries)
+
+include(CPack)
diff --git a/distribution/win32/nsis/install.nsh b/distribution/win32/nsis/install.nsh
index dc4ed80..0fc948d 100644
--- a/distribution/win32/nsis/install.nsh
+++ b/distribution/win32/nsis/install.nsh
@@ -5,9 +5,9 @@
CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\XTrackCAD Help.lnk" "$INSTDIR\share\xtrkcad\xtrkcad.chm" "" "" 0
CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\XTrackCAD ReadMe.lnk" "notepad.exe" "$INSTDIR\share\xtrkcad\ReadMe.txt"
CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\XTrackCAD CHANGELOG.lnk" "notepad.exe" "$INSTDIR\share\xtrkcad\CHANGELOG.txt"
-
-
-;
+
+
+;
; create file association
;
; back up old value of .xtc
@@ -17,14 +17,23 @@ CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\XTrackCAD CHANGELOG.lnk" "notepad.
StrCmp $1 "XTrackCAD.Design" "${Index}-NoBackup"
WriteRegStr HKCR ".xtc" "backup_val" $1
"${Index}-NoBackup:"
-
-; create the new association
+
+ ; back up old value of .xtce
+ !define /redef Index "Line${__LINE__}"
+ ReadRegStr $1 HKCR ".xtce" ""
+ StrCmp $1 "" "${Index}-NoBackup"
+ StrCmp $1 "XTrackCAD.Design" "${Index}-NoBackup"
+ WriteRegStr HKCR ".xtce" "backup_xtce" $1
+ "${Index}-NoBackup:"
+
+; create the new association
WriteRegStr HKCR ".xtc" "" "XTrackCAD.Design"
+ WriteRegStr HKCR ".xtce" "" "XTrackCAD.Design"
WriteRegStr HKCR "XTrackCAD.Design" "" "XTrackCAD Layout Design"
WriteRegStr HKCR "XTrackCAD.Design\shell" "" "open"
- WriteRegStr HKCR "XTrackCAD.Design\DefaultIcon" "" "$INSTDIR\bin\xtrkcad.exe,0"
+ WriteRegStr HKCR "XTrackCAD.Design\DefaultIcon" "" '$INSTDIR\bin\xtrkcad.exe,0'
WriteRegStr HKCR "XTrackCAD.Design\shell\open\command" "" '$INSTDIR\bin\xtrkcad.exe "%1"'
-
+
System::Call 'Shell32::SHChangeNotify(i 0x8000000, i 0, i 0, i 0)'
-
- !undef Index \ No newline at end of file
+
+ !undef Index
diff --git a/distribution/win32/nsis/uninstall.nsh b/distribution/win32/nsis/uninstall.nsh
index b568e21..3f47586 100644
--- a/distribution/win32/nsis/uninstall.nsh
+++ b/distribution/win32/nsis/uninstall.nsh
@@ -1,8 +1,8 @@
;
-; additional uninstaller instructions
+; additional uninstaller instructions
;
-; Remove file association
+; Remove file association xtc
!define Index "Line${__LINE__}"
ReadRegStr $1 HKCR ".xtc" ""
StrCmp $1 "XTrackCAD.Design" 0 "${Index}-NoOwn" ; only do this if we own it
@@ -13,18 +13,29 @@
"${Index}-Restore:"
WriteRegStr HKCR ".xtc" "" $1
DeleteRegValue HKCR ".xtc" "backup_val"
-
+
+"${Index}-NoOwn:"
+; Remove file association xtce
+ !define /redef Index "Line${__LINE__}"
+ ReadRegStr $1 HKCR ".xtce" ""
+ StrCmp $1 "XTrackCAD.Design" 0 "${Index}-NoOwn" ; only do this if we own it
+ ReadRegStr $1 HKCR ".xtce" "backup_xtce"
+ StrCmp $1 "" 0 "${Index}-Restore" ; if backup="" then delete the whole key
+ DeleteRegKey HKCR ".xtce"
+ Goto "${Index}-NoOwn"
+ "${Index}-Restore:"
+ WriteRegStr HKCR ".xtce" "" $1
+ DeleteRegValue HKCR ".xtce" "backup_xtce"
+
DeleteRegKey HKCR "XTrackCAD.Design" ;Delete key with association settings
-
+
System::Call 'Shell32::SHChangeNotify(i 0x8000000, i 0, i 0, i 0)'
"${Index}-NoOwn:"
!undef Index
; Remove shortcuts, if any
-; SetShellVarContext all
+SetShellVarContext all
!insertmacro MUI_STARTMENU_GETFOLDER Application $MUI_TEMP
-
-Delete "$SMPROGRAMS\$MUI_TEMP\XTrkCad Help.lnk"
-Delete "$SMPROGRAMS\$MUI_TEMP\XTrkCad ReadMe.lnk"
- \ No newline at end of file
+RMDir /r "$SMPROGRAMS\$MUI_TEMP"
+Delete "$desktop\XTrackCAD.lnk"