Updated deployment scripts for Windows.

This commit is contained in:
klayoutmatthias 2017-08-06 22:19:31 +02:00
parent 7ddc0d6b39
commit e6642f41f6
4 changed files with 321 additions and 1 deletions

130
scripts/deploy-win-mingw.sh Normal file
View File

@ -0,0 +1,130 @@
#!/bin/sh -e
if [ "$MSYSTEM" == "MINGW32" ]; then
arch=win32
mingw_inst=/mingw32
elif [ "$MSYSTEM" == "MINGW64" ]; then
arch=win64
mingw_inst=/mingw64
else
echo "ERROR: not in mingw32 or mingw64 system."
fi
pwd=$(pwd)
target=$pwd/bin-release-$arch
build=$pwd/build-release-$arch
src=$pwd/src
scripts=$pwd/scripts
python="python3.5m"
ruby="ruby"
makensis=/c/Program\ Files\ \(x86\)/NSIS/makensis.exe
version=$(cat $src/klayout_main/version.h | grep prg_version | sed 's/.*"\(.*\)".*/\1/')
echo "Version is $version"
echo "Running build .."
rm -rf $target
./build.sh -python $python -ruby $ruby -bin $target -build $build -j2
if ! [ -e $target ]; then
echo "ERROR: Target directory $target not found"
exit 1
fi
if ! [ -e $target/klayout.exe ]; then
echo "ERROR: Target directory $target does not contain klayout.exe"
exit 1
fi
# ----------------------------------------------------------
# Binary dependencies
libs=$(ldd $target/klayout.exe | grep $mingw_inst | sed 's/ *=>.*//' | sort)
for l in $libs; do
echo "Copying binary installation partial $mingw_inst/$l -> $target/$l .."
cp $mingw_inst/bin/$l $target/$l
done
# ----------------------------------------------------------
# Ruby dependencies
rm -rf $target/.ruby-paths.txt
echo '# Builds the Python paths.' >$target/.ruby-paths.txt
echo '# KLayout will load the paths listed in this file into sys.path' >>$target/.ruby-paths.txt
echo '# unless $KLAYOUT_PYTHONHOME ist set.' >>$target/.ruby-paths.txt
echo '# Use KLayout EXPRESSIONS syntax to specify a list of file paths.' >>$target/.ruby-paths.txt
echo '[' >>$target/.ruby-paths.txt
first=1
rubys=$($ruby -e 'puts $:' | sort)
for p in $rubys; do
p=$(cygpath $p)
if [[ $p == "$mingw_inst"* ]] && [ -e "$p" ]; then
rp=${p/"$mingw_inst/"}
if [ $first == "0" ]; then
echo "," >>$target/.ruby-paths.txt
fi
first=0
echo -n " combine(inst_path, '$rp')" >>$target/.ruby-paths.txt
echo "Copying Ruby installation partial $p -> $target/$rp .."
rm -rf $target/$rp
mkdir -p $target/$rp
rmdir $target/$rp
cp -vR $p $target/$rp | sed -u 's/.*/echo -n ./' | sh
echo ""
fi
done
echo '' >>$target/.ruby-paths.txt
echo ']' >>$target/.ruby-paths.txt
# ----------------------------------------------------------
# Image formats
echo "Installing image format plugins .."
cp -R $mingw_inst/share/qt5/plugins/imageformats $target
# ----------------------------------------------------------
# Python dependencies
rm -rf $target/.python-paths.txt
echo '# Builds the Python paths.' >$target/.python-paths.txt
echo '# KLayout will load the paths listed in this file into sys.path' >>$target/.python-paths.txt
echo '# unless $KLAYOUT_PYTHONHOME ist set.' >>$target/.python-paths.txt
echo '# Use KLayout EXPRESSIONS syntax to specify a list of file paths.' >>$target/.python-paths.txt
echo '[' >>$target/.python-paths.txt
first=1
pythons=$($python -c "import sys; print('\n'.join(sys.path))" | sort)
for p in $pythons; do
p=$(cygpath $p)
if [[ $p == "$mingw_inst"* ]] && [ -e "$p" ]; then
rp=${p/"$mingw_inst/"}
if [ $first == "0" ]; then
echo "," >>$target/.python-paths.txt
fi
first=0
echo -n " combine(inst_path, '$rp')" >>$target/.python-paths.txt
echo "Copying Python installation partial $p -> $target/$rp .."
rm -rf $target/$rp
mkdir -p $target/$rp
rmdir $target/$rp
cp -vR $p $target/$rp | sed -u 's/.*/echo -n ./' | sh
echo ""
fi
done
echo '' >>$target/.python-paths.txt
echo ']' >>$target/.python-paths.txt
# ----------------------------------------------------------
# Run NSIS
# TODO: NSIS now supports /nocd with which we would no
# longer require the copy
cp $scripts/klayout-inst.nsis $target
cd $target
NSIS_VERSION=$version NSIS_ARCH=$arch "$makensis" klayout-inst.nsis

13
scripts/deploy-win.sh Normal file
View File

@ -0,0 +1,13 @@
#!/bin/sh -e
inst_dir=$(dirname $(which $0))
if ! [ -e ./build.sh ]; then
echo "ERROR: build script not found (not in the main directory?)"
exit 1
fi
pwd=$(pwd)
MSYSTEM=MINGW32 bash --login -c "cd $pwd ; $inst_dir/deploy-win-mingw.sh"
MSYSTEM=MINGW64 bash --login -c "cd $pwd ; $inst_dir/deploy-win-mingw.sh"

177
scripts/klayout-inst.nsis Normal file
View File

@ -0,0 +1,177 @@
# ---------------------------------------------------------------------------
# NSIS installer script
#
# for NSIS v 2.38
# compile with: makensis.exe klayout-inst.nsis
# ---------------------------------------------------------------------------
!define NAME "KLayout"
!define DISPNAME "Klayout - Layout Viewer And Editor"
!define EXEBASE "klayout"
!define EXENAME "klayout_app"
!define EXENAME_VO "klayout_vo_app"
!define VERSION "$%NSIS_VERSION%"
Name "${NAME} v${VERSION}"
# request normal user rights, but switch to "all" mode if the user has admin rights
RequestExecutionLevel user
# define installer name
outFile "${EXEBASE}-${VERSION}-$%NSIS_ARCH%-install.exe"
# set Program Files or Application Data as install directory depending on the
# installer's permissions
Function .onInit
UserInfo::GetAccountType
Pop $0
StrCmp $0 "Admin" 0 +3
StrCpy $InstDir "$PROGRAMFILES\${NAME}"
Goto +2
StrCpy $InstDir "$APPDATA\${NAME}"
FunctionEnd
InstProgressFlags smooth
# detect installation path from uninstall string if available
InstallDirRegKey HKLM \
"Software\Microsoft\Windows\CurrentVersion\Uninstall\${NAME}" \
"UninstallString"
# The text to prompt the user to enter a directory
DirText "Please select your ${NAME} installation path below:"
# automatically close the installer when done.
AutoCloseWindow true
# adds xp style support
XPStyle on
# Pages
Page directory
Page instfiles
# default section start
section
UserInfo::GetAccountType
Pop $0
StrCmp $0 "Admin" 0 +2
SetShellVarContext all
# define output path
setOutPath $INSTDIR
# specify files to go in output path
# not installed because of disk space:
# file strm2gds.exe
# file strm2oas.exe
# file strmclip.exe
# file strmcmp.exe
file *.dll
file .*-paths.txt
file /r imageformats
file /r lib
file /oname=${EXENAME}.exe ${EXEBASE}.exe
file /oname=${EXENAME_VO}.exe ${EXEBASE}.exe
# create a shortcut
createDirectory "$SMPROGRAMS\${NAME}"
createShortCut "$SMPROGRAMS\${NAME}\${NAME} (Default).lnk" "$INSTDIR\${EXENAME}.exe"
createShortCut "$SMPROGRAMS\${NAME}\${NAME} (Editor).lnk" "$INSTDIR\${EXENAME}.exe" "-e"
createShortCut "$SMPROGRAMS\${NAME}\${NAME} (Viewer).lnk" "$INSTDIR\${EXENAME}.exe" "-ne"
# define uninstaller name
writeUninstaller $INSTDIR\${EXEBASE}-uninstall.exe
WriteRegStr SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\${NAME}" \
"DisplayName" "${DISPNAME}"
WriteRegStr SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\${NAME}" \
"DisplayVersion" "${VERSION}"
WriteRegStr SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\${NAME}" \
"Publisher" "Matthias Koefferlein"
WriteRegStr SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\${NAME}" \
"UninstallString" "$INSTDIR\${EXEBASE}-uninstall.exe"
WriteRegStr SHCTX "Software\Classes\${NAME}.Application\DefaultIcon" \
"" "$INSTDIR\${EXENAME}.exe"
WriteRegStr SHCTX "Software\Classes\${NAME}.Application\Document.1\DefaultIcon" \
"" "$INSTDIR\${EXENAME}.exe"
WriteRegStr SHCTX "Software\Classes\${NAME}.Application\Document.1\Shell\Open\Command" \
"" "$INSTDIR\${EXENAME}.exe $\"%1$\""
WriteRegStr SHCTX "Software\Classes\${NAME}.Application\Document.2\DefaultIcon" \
"" "$INSTDIR\${EXENAME}.exe"
WriteRegStr SHCTX "Software\Classes\${NAME}.Application\Document.2\Shell\Open\Command" \
"" "$INSTDIR\${EXENAME}.exe $\"%1$\""
WriteRegStr SHCTX "Software\Classes\${NAME}.Application\Document.3\DefaultIcon" \
"" "$INSTDIR\${EXENAME}.exe"
WriteRegStr SHCTX "Software\Classes\${NAME}.Application\Document.3\Shell\Open\Command" \
"" "$INSTDIR\${EXENAME}.exe -rm $\"%1$\""
WriteRegStr SHCTX "Software\Classes\${NAME}.Application\Document.4\DefaultIcon" \
"" "$INSTDIR\${EXENAME}.exe"
WriteRegStr SHCTX "Software\Classes\${NAME}.Application\Document.4\Shell\Open\Command" \
"" "$INSTDIR\${EXENAME}.exe -u $\"%1$\""
WriteRegStr SHCTX "Software\Classes\${NAME}.Application\Document.5\DefaultIcon" \
"" "$INSTDIR\${EXENAME}.exe"
WriteRegStr SHCTX "Software\Classes\${NAME}.Application\Document.5\Shell\Open\Command" \
"" "$INSTDIR\${EXENAME}.exe -r $\"%1$\""
WriteRegStr SHCTX "Software\Classes\.gds" \
"" "${NAME}.Application\Document.1"
WriteRegStr SHCTX "Software\Classes\.oas" \
"" "${NAME}.Application\Document.2"
WriteRegStr SHCTX "Software\Classes\.rba" \
"" "${NAME}.Application\Document.3"
WriteRegStr SHCTX "Software\Classes\.rbm" \
"" "${NAME}.Application\Document.3"
WriteRegStr SHCTX "Software\Classes\.lys" \
"" "${NAME}.Application\Document.4"
WriteRegStr SHCTX "Software\Classes\.lym" \
"" "${NAME}.Application\Document.5"
# default section end
sectionEnd
# create a section to define what the uninstaller does.
# the section will always be named "Uninstall"
section "Uninstall"
# determine, if the user has admin rights and use "all" context in this case
UserInfo::GetAccountType
Pop $0
StrCmp $0 "Admin" 0 +2
SetShellVarContext all
# Always delete uninstaller first
delete $INSTDIR\${EXEBASE}-uninstall.exe
# now delete installed files
rmDir /r "$INSTDIR"
# create a shortcut
rmDir /r "$SMPROGRAMS\${NAME}"
DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\${NAME}"
DeleteRegKey SHCTX "Software\Classes\${NAME}.Application\DefaultIcon"
DeleteRegKey SHCTX "Software\Classes\${NAME}.Application\Document.1\DefaultIcon"
DeleteRegKey SHCTX "Software\Classes\${NAME}.Application\Document.1\Shell\Open\Command"
DeleteRegKey SHCTX "Software\Classes\${NAME}.Application\Document.2\DefaultIcon"
DeleteRegKey SHCTX "Software\Classes\${NAME}.Application\Document.2\Shell\Open\Command"
DeleteRegKey SHCTX "Software\Classes\${NAME}.Application\Document.3\DefaultIcon"
DeleteRegKey SHCTX "Software\Classes\${NAME}.Application\Document.3\Shell\Open\Command"
DeleteRegKey SHCTX "Software\Classes\${NAME}.Application\Document.4\DefaultIcon"
DeleteRegKey SHCTX "Software\Classes\${NAME}.Application\Document.4\Shell\Open\Command"
DeleteRegKey SHCTX "Software\Classes\${NAME}.Application\Document.5\DefaultIcon"
DeleteRegKey SHCTX "Software\Classes\${NAME}.Application\Document.5\Shell\Open\Command"
DeleteRegKey SHCTX "Software\Classes\${NAME}.Application"
DeleteRegKey SHCTX "Software\Classes\.gds"
DeleteRegKey SHCTX "Software\Classes\.oas"
DeleteRegKey SHCTX "Software\Classes\.rba"
DeleteRegKey SHCTX "Software\Classes\.rbm"
DeleteRegKey SHCTX "Software\Classes\.lys"
DeleteRegKey SHCTX "Software\Classes\.lym"
sectionEnd

View File

@ -36,7 +36,7 @@ const char *prg_about_text =
"For feedback and bug reports mail to: contact@klayout.de\n" "For feedback and bug reports mail to: contact@klayout.de\n"
"\n" "\n"
"\n" "\n"
"Copyright (C) 2006-2016 Matthias K\303\266fferlein\n" "Copyright (C) 2006-2017 Matthias K\303\266fferlein\n"
"\n" "\n"
"This program is free software; you can redistribute it and/or modify\n" "This program is free software; you can redistribute it and/or modify\n"
"it under the terms of the GNU General Public License as published by\n" "it under the terms of the GNU General Public License as published by\n"