Browse Source

add windows build

copy-dylibs-in-bottle
Alexandros Theodotou 3 years ago
parent
commit
c5eb63fdc1
Signed by: alex
GPG Key ID: 022EAE42313D70F3
  1. 80
      Makefile
  2. 54
      PKGBUILD-w10.in
  3. 6
      README-dev.md
  4. 1
      ansible-conf.ini
  5. 412
      tools/gen_windows_installer.sh
  6. 190
      tools/nsis/Include/FileAssociation.nsh

80
Makefile

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
ZRYTHM_VERSION=0.7.295
ZRYTHM_VERSION=0.7.345
ZRYTHM_TARBALL=zrythm-$(ZRYTHM_VERSION).tar.xz
ZRYTHM_DIR=zrythm-$(ZRYTHM_VERSION)
ZRYTHM_DEBIAN_TARBALL=zrythm_$(ZRYTHM_VERSION).orig.tar.xz
@ -11,6 +11,11 @@ BUILD_DEBIAN10_DIR=$(BUILD_DIR)/debian10 @@ -11,6 +11,11 @@ BUILD_DEBIAN10_DIR=$(BUILD_DIR)/debian10
MESON_DIR=meson-0.52.1
MESON_TARBALL=$(MESON_DIR).tar.gz
BUILD_ARCH_DIR=$(BUILD_DIR)/arch
BUILD_WINDOWS_DIR=$(BUILD_DIR)/windows10
WIN_CHROOT_DIR=/tmp/zrythm-root
# This is the directory to rsync into
MINGW_SRC_DIR=../../msys64/home/alex/zrythm-build
WINDOWS_ZRYTHM_PKG_TAR_XZ=
RPMBUILD_ROOT=/home/ansible/rpmbuild
BUILD_FEDORA31_DIR=$(BUILD_DIR)/fedora31
BUILD_OPENSUSE_TUMBLEWEED_DIR=$(BUILD_DIR)/opensuse-tumbleweed
@ -18,6 +23,7 @@ ARCH_PKG_FILE=zrythm-$(ZRYTHM_VERSION)-1-x86_64.pkg.tar.xz @@ -18,6 +23,7 @@ ARCH_PKG_FILE=zrythm-$(ZRYTHM_VERSION)-1-x86_64.pkg.tar.xz
DEBIAN_PKG_FILE=zrythm_$(ZRYTHM_VERSION)-1_amd64.deb
FEDORA31_PKG_FILE=zrythm-$(ZRYTHM_VERSION)-1.fc31.x86_64.rpm
OPENSUSE_TUMBLEWEED_PKG_FILE=zrythm-$(ZRYTHM_VERSION)-1.opensuse-tumbleweed.x86_64.rpm
WINDOWS_INSTALLER=zrythm-$(ZRYTHM_VERSION)-setup.exe
ANSIBLE_PLAYBOOK_CMD=ansible-playbook -i ./ansible-conf.ini playbook.yml --extra-vars "version=$(ZRYTHM_VERSION)" -v
define start_vm
@ -80,6 +86,8 @@ zrythm_installer.zip: artifacts tools/gen_installer.sh README.in installer.sh.in @@ -80,6 +86,8 @@ zrythm_installer.zip: artifacts tools/gen_installer.sh README.in installer.sh.in
mkdir -p bin/arch
mkdir -p bin/fedora
mkdir -p bin/opensuse
cp artifacts/debian9/$(DEBIAN_PKG_FILE) \
bin/debian/zrythm-$(ZRYTHM_VERSION)-1_9_amd64.deb
cp artifacts/debian10/$(DEBIAN_PKG_FILE) \
bin/debian/zrythm-$(ZRYTHM_VERSION)-1_10_amd64.deb
cp artifacts/ubuntu1904/$(DEBIAN_PKG_FILE) \
@ -103,6 +111,9 @@ zrythm_installer.zip: artifacts tools/gen_installer.sh README.in installer.sh.in @@ -103,6 +111,9 @@ zrythm_installer.zip: artifacts tools/gen_installer.sh README.in installer.sh.in
.PHONY: artifacts
artifacts: artifacts/debian10/$(DEBIAN_PKG_FILE) artifacts/ubuntu1904/$(DEBIAN_PKG_FILE) artifacts/ubuntu1910/$(DEBIAN_PKG_FILE) artifacts/arch/$(ARCH_PKG_FILE) artifacts/fedora31/$(FEDORA31_PKG_FILE) artifacts/opensuse-tumbleweed/$(OPENSUSE_TUMBLEWEED_PKG_FILE)
artifacts/debian9/$(DEBIAN_PKG_FILE): debian.changelog.in debian.compat debian.control debian.copyright debian.rules $(BUILD_DIR)/$(ZRYTHM_TARBALL) $(BUILD_DIR)/meson/meson.py
$(call run_build_in_vm,debian9)
artifacts/debian10/$(DEBIAN_PKG_FILE): debian.changelog.in debian.compat debian.control debian.copyright debian.rules $(BUILD_DIR)/$(ZRYTHM_TARBALL) $(BUILD_DIR)/meson/meson.py
$(call run_build_in_vm,debian10)
@ -121,6 +132,19 @@ artifacts/fedora31/$(FEDORA31_PKG_FILE): zrythm.spec.in $(BUILD_DIR)/$(ZRYTHM_TA @@ -121,6 +132,19 @@ artifacts/fedora31/$(FEDORA31_PKG_FILE): zrythm.spec.in $(BUILD_DIR)/$(ZRYTHM_TA
artifacts/opensuse-tumbleweed/$(OPENSUSE_TUMBLEWEED_PKG_FILE): zrythm.spec.in $(BUILD_DIR)/$(ZRYTHM_TARBALL) $(BUILD_DIR)/meson/meson.py
$(call run_build_in_vm,opensuse-tumbleweed)
artifacts/windows10/$(WINDOWS_INSTALLER): PKGBUILD-w10.in $(BUILD_DIR)/$(ZRYTHM_TARBALL)
$(call start_vm,windows10)
echo "Copying files, enter password (alex) to continue"
rsync -r ./* alex@192.168.100.247:$(MINGW_SRC_DIR)/
echo "Go into the VM and run make windows10 in the zrythm-build directory. When the installer is built, press y to continue" && \
read -d "y"
scp alex@193.168.100.247:$(MINGW_SRC_DIR)/build/windows10/$(WINDOWS_INSTALLER) artifacts/windows10/$(WINDOWS_INSTALLER)
cp $(BUILD_DIR)/$(WINDOWS_INSTALLER) artifacts/windows10/$(WINDOWS_INSTALLER)
$(call stop_vm,windows10)
.PHONY: debian9
debian10: $(BUILD_DIR)/$(DEBIAN_PKG_FILE)
# Debian 10 target to be used by ansible inside the
# debian VM
.PHONY: debian10
@ -162,6 +186,49 @@ $(BUILD_DIR)/$(ARCH_PKG_FILE): PKGBUILD.in @@ -162,6 +186,49 @@ $(BUILD_DIR)/$(ARCH_PKG_FILE): PKGBUILD.in
sed -i -e 's/@VERSION@/$(ZRYTHM_VERSION)/' $(BUILD_ARCH_DIR)/PKGBUILD
cd $(BUILD_ARCH_DIR) && makepkg -f
.PHONY: windows10
windows10: $(BUILD_DIR)/$(WINDOWS_INSTALLER)
$(BUILD_WINDOWS_DIR)/mingw-w64-x86_64-zrythm-$(ZRYTHM_VERSION)-2-any.pkg.tar.xz: PKGBUILD-w10.in
rm -rf $(BUILD_WINDOWS_DIR)
mkdir -p $(BUILD_WINDOWS_DIR)/src
cp PKGBUILD-w10.in $(BUILD_WINDOWS_DIR)/PKGBUILD
cp $(BUILD_DIR)/$(ZRYTHM_TARBALL) $(BUILD_WINDOWS_DIR)/
sed -i -e 's/@VERSION@/$(ZRYTHM_VERSION)/' $(BUILD_WINDOWS_DIR)/PKGBUILD
cd $(BUILD_WINDOWS_DIR) && makepkg-mingw -f
$(WIN_CHROOT_DIR)/mingw64/bin/zrythm.exe: $(BUILD_WINDOWS_DIR)/mingw-w64-x86_64-zrythm-$(ZRYTHM_VERSION)-2-any.pkg.tar.xz
# create chroot
mkdir -p $(WIN_CHROOT_DIR)
mkdir -p $(WIN_CHROOT_DIR)/var/lib/pacman
mkdir -p $(WIN_CHROOT_DIR)/var/log
mkdir -p $(WIN_CHROOT_DIR)/tmp
pacman -Syu --root $(WIN_CHROOT_DIR)
pacman -S filesystem bash pacman --noconfirm --needed --root $(WIN_CHROOT_DIR)
# install package in chroot
pacman -U $(BUILD_WINDOWS_DIR)/mingw-w64-x86_64-zrythm-$(ZRYTHM_VERSION)-2-any.pkg.tar.xz --noconfirm --needed --root $(WIN_CHROOT_DIR)
ls $(WIN_CHROOT_DIR)/mingw64/bin/zrythm.exe
# compile glib schemas
glib-compile-schemas.exe $(WIN_CHROOT_DIR)/mingw64/share/glib-2.0/schemas
$(BUILD_DIR)/$(WINDOWS_INSTALLER): $(WIN_CHROOT_DIR)/mingw64/bin/zrythm.exe FORCE
# create sources distribution
-rm $(BUILD_WINDOWS_DIR)/installer/dist/THIRDPARTY_INFO
mkdir -p $(BUILD_WINDOWS_DIR)/installer/dist
pacman -Si $(shell pacman -Q --root $(WIN_CHROOT_DIR) | grep mingw | grep -v zrythm | cut -d" " -f1) > $(BUILD_WINDOWS_DIR)/installer/dist/THIRDPARTY_INFO
# copy other files
cp $(BUILD_WINDOWS_DIR)/src/zrythm-$(ZRYTHM_VERSION)/AUTHORS $(BUILD_WINDOWS_DIR)/installer/dist/
cp $(BUILD_WINDOWS_DIR)/src/zrythm-$(ZRYTHM_VERSION)/COPYING* $(BUILD_WINDOWS_DIR)/installer/dist/
cp $(BUILD_WINDOWS_DIR)/src/zrythm-$(ZRYTHM_VERSION)/README.md $(BUILD_WINDOWS_DIR)/installer/dist/
cp $(BUILD_WINDOWS_DIR)/src/zrythm-$(ZRYTHM_VERSION)/CONTRIBUTING.md $(BUILD_WINDOWS_DIR)/installer/dist/
cp $(BUILD_WINDOWS_DIR)/src/zrythm-$(ZRYTHM_VERSION)/THANKS $(BUILD_WINDOWS_DIR)/installer/dist/
cp $(BUILD_WINDOWS_DIR)/src/zrythm-$(ZRYTHM_VERSION)/TRANSLATORS $(BUILD_WINDOWS_DIR)/installer/dist/
cp $(BUILD_WINDOWS_DIR)/src/zrythm-$(ZRYTHM_VERSION)/CHANGELOG.md $(BUILD_WINDOWS_DIR)/installer/dist/
cp $(BUILD_WINDOWS_DIR)/src/zrythm-$(ZRYTHM_VERSION)/data/windows/zrythm.ico $(BUILD_WINDOWS_DIR)/installer/dist/zrythm.ico
# create installer
tools/gen_windows_installer.sh $(WIN_CHROOT_DIR)/mingw64 $(ZRYTHM_VERSION) $(BUILD_WINDOWS_DIR)/installer $(shell pwd)/tools/nsis
cp $(BUILD_WINDOWS_DIR)/installer/dist/Install_v$(ZRYTHM_VERSION).exe $(BUILD_DIR)/$(WINDOWS_INSTALLER)
.PHONY: fedora31
fedora31: $(BUILD_DIR)/$(FEDORA31_PKG_FILE)
@ -206,8 +273,19 @@ $(BUILD_DIR)/$(ZRYTHM_TARBALL): @@ -206,8 +273,19 @@ $(BUILD_DIR)/$(ZRYTHM_TARBALL):
cd $(BUILD_DIR) && $(CALC_SUM) $(ZRYTHM_TARBALL_SUM)
cd $(BUILD_DIR) && gpg --verify $(ZRYTHM_TARBALL).asc $(ZRYTHM_TARBALL)
# call this if cleaning the chroot environment is needed
.PHONY: clean-windows10-chroot
clean-windows10-chroot:
rm -rf $(WIN_CHROOT_DIR)
# to be called inside the VM
.PHONY: clean-windows-dir
clean-windows-dir:
rm -rf $(BUILD_WINDOWS_DIR)
.PHONY: clean
clean:
rm -rf $(BUILD_DEBIAN10_DIR)
rm -rf $(BUILD_ARCH_DIR)
rm -rf $(BUILD_FEDORA31_DIR)
rm -rf $(BUILD_DIR)/$(ZRYTHM_TARBALL)

54
PKGBUILD-w10.in

@ -0,0 +1,54 @@ @@ -0,0 +1,54 @@
# Maintainer: Alexandros Theodotou <alex at zrythm dot org>
_realname=zrythm
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=@VERSION@
pkgrel=2
arch=('any')
pkgdesc='a highly automated and intuitive digital audio workstation (mingw-w64)'
depends=("${MINGW_PACKAGE_PREFIX}-adwaita-icon-theme"
"${MINGW_PACKAGE_PREFIX}-gtk3"
"${MINGW_PACKAGE_PREFIX}-cantarell-fonts"
"${MINGW_PACKAGE_PREFIX}-rubberband"
"${MINGW_PACKAGE_PREFIX}-libsndfile"
"${MINGW_PACKAGE_PREFIX}-libsamplerate"
"${MINGW_PACKAGE_PREFIX}-dlfcn"
"${MINGW_PACKAGE_PREFIX}-fftw"
"${MINGW_PACKAGE_PREFIX}-libyaml")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc"
"${MINGW_PACKAGE_PREFIX}-gettext"
"${MINGW_PACKAGE_PREFIX}-meson"
"${MINGW_PACKAGE_PREFIX}-ninja"
"${MINGW_PACKAGE_PREFIX}-pkg-config"
"${MINGW_PACKAGE_PREFIX}-python3")
options=('strip' 'staticlibs')
license=("AGPL3")
url="https://www.zrythm.org"
#install=${_realname}-${CARCH}.install
source=(https://www.zrythm.org/releases/zrythm-${pkgver}.tar.xz)
sha256sums=('SKIP')
prepare() {
cd "${srcdir}"/${_realname}-${pkgver}
}
build() {
[[ -d build-${MINGW_CHOST} ]] && rm -rf build-${MINGW_CHOST}
mkdir -p build-${MINGW_CHOST} && cd build-${MINGW_CHOST}
${MINGW_PREFIX}/bin/meson \
--buildtype=debugoptimized \
-Denable_plugins=false \
-Dwindows_release=true \
--buildtype=release \
"../${_realname}-${pkgver}"
ninja
}
package() {
cd "${srcdir}/build-${MINGW_CHOST}"
DESTDIR="${pkgdir}${MINGW_PREFIX}" ninja install
install -Dm644 "${srcdir}/${_realname}-${pkgver}/COPYING" "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/COPYING"
}

6
README-dev.md

@ -0,0 +1,6 @@ @@ -0,0 +1,6 @@
# Note for windows
Can use the following to spawn an MSYS2 shell from the
windows shell
```
C:\msys64\usr\bin\env.exe MSYSTEM=MINGW64 C:\msys64\usr\bin\bash.exe -l
```

1
ansible-conf.ini

@ -5,3 +5,4 @@ ubuntu1910 ansible_user=ansible ansible_host=192.168.100.131 @@ -5,3 +5,4 @@ ubuntu1910 ansible_user=ansible ansible_host=192.168.100.131
fedora31 ansible_user=ansible ansible_host=192.168.100.170
archlinux ansible_user=ansible ansible_host=192.168.100.153
opensuse-tumbleweed ansible_user=ansible ansible_host=192.168.100.195
;windows10 ansible_user=alex ansible_host=192.168.100.247 ansible_password=alex ansible_connection=winrm ansible_winrm_transport=basic

412
tools/gen_windows_installer.sh

@ -0,0 +1,412 @@ @@ -0,0 +1,412 @@
#! /bin/bash
# Copyright (C) 2019-2020 Alexandros Theodotou <alex at zrythm dot org>
#
# This file is part of Zrythm
#
# Zrythm is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Zrythm is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Zrythm. If not, see <https://www.gnu.org/licenses/>.
#
# $1 mingw prefix (chroot/mingw64)
# $2 zrythm version
# $3 build dir, this is the staging directory to use
# to stage files to - the root of the installer is in $3/dist
# $4 path to nsis dir
PROGRAM_VERSION="$2"
NSIS_DIR=$4
BUILD_DIR=$3
MINGW_PREFIX=$1
DIST_DIR=$BUILD_DIR/dist # root of the distribution
DIST_BINDIR=$DIST_DIR/bin
DIST_LIBDIR=$DIST_DIR/lib
DIST_SHAREDIR=$DIST_DIR/share
DIST_ETCDIR=$DIST_DIR/etc
INSTALL_DATA="install -m 644"
GLIB_SCHEMAS_DIR_SUFFIX=share/glib-2.0/schemas
#rm -rf $BUILD_DIR
mkdir -p $DIST_BINDIR
mkdir -p $DIST_LIBDIR
mkdir -p $DIST_SHAREDIR
mkdir -p $DIST_ETCDIR
mkdir -p $DIST_DIR/$GLIB_SCHEMAS_DIR_SUFFIX
cp $MINGW_PREFIX/$GLIB_SCHEMAS_DIR_SUFFIX/* $DIST_DIR/$GLIB_SCHEMAS_DIR_SUFFIX/
# ******************************
echo "Copying dlls..."
DLLS=" \
libatk-1.0-0.dll \
libbz2-1.dll \
libcairo-2.dll \
libcairo-gobject-2.dll \
libcroco-0.6-3.dll \
libdatrie-1.dll \
libdl.dll \
libepoxy-0.dll \
libexpat-1.dll \
libffi-6.dll \
libFLAC-8.dll \
libfontconfig-1.dll \
libfreetype-6.dll \
libfribidi-0.dll \
libgcc_s_seh-1.dll \
libgdk_pixbuf-2.0-0.dll \
libgdk-3-0.dll \
libgio-2.0-0.dll \
libglib-2.0-0.dll \
libgmodule-2.0-0.dll \
libgobject-2.0-0.dll \
libgraphite2.dll \
libgthread-2.0-0.dll \
libgtk-3-0.dll \
libharfbuzz-0.dll \
libiconv-2.dll \
libintl-8.dll \
libjasper-4.dll \
libjpeg-8.dll \
liblzma-5.dll \
libogg-0.dll \
libpango-1.0-0.dll \
libpangocairo-1.0-0.dll \
libpangoft2-1.0-0.dll \
libpangowin32-1.0-0.dll \
libpcre-1.dll \
libpng16-16.dll \
libportaudio-2.dll \
librsvg-2-2.dll \
libsamplerate-0.dll \
libsndfile-1.dll \
libstdc++-6.dll \
libthai-0.dll \
libtiff-5.dll \
libvorbis-0.dll \
libvorbisenc-2.dll \
libvorbisfile-3.dll \
libwinpthread-1.dll \
libxml2-2.dll \
zlib1.dll"
#for file in $DLLS; do
#echo "copying $file"
#cp $MINGW_PREFIX/bin/$file $DIST_BINDIR/
#done
cp $MINGW_PREFIX/bin/*.dll $DIST_BINDIR/
# ******************************
# ******************************
#echo "packaging settings.ini"
#mkdir -p $DIST_ETCDIR/gtk-3.0
#cp data/settings.ini $ETC_GTK_DIR/
cp -R $MINGW_PREFIX/etc/gtk-3.0 $MINGW_PREFIX/etc/fonts $DIST_ETCDIR
# ******************************
# ******************************
#echo "packaging glib schema"
#SCHEMAS_DIR="$SHAREDIR/glib-2.0/schemas"
#mkdir -p "$SCHEMAS_DIR"
#cp "$BUILD_DIR/schemas/gschemas.compiled" \
#"$SCHEMAS_DIR/"
# ******************************
# ******************************
echo "packaging Adwaita icons"
mkdir -p "$DIST_SHAREDIR/icons"
cp -R "$MINGW_PREFIX/share/icons/Adwaita" "$DIST_SHAREDIR/icons/"
echo "packaging existing hicolor icons"
cp -R "$MINGW_PREFIX/share/icons/hicolor" "$DIST_SHAREDIR/icons/"
# ******************************
# ******************************
echo "packaging locales"
cp -R $MINGW_PREFIX/share/locale $DIST_SHAREDIR/
# ******************************
# ******************************
echo "packaging other assets"
cp -R $MINGW_PREFIX/share/zrythm $DIST_SHAREDIR/
# ******************************
# ******************************
echo "packaging fonts"
cp -R $MINGW_PREFIX/share/fonts $DIST_SHAREDIR/
# ******************************
# ******************************
echo "packaging gdk pixbuf loaders"
PIXBUF_DIR="lib/gdk-pixbuf-2.0/2.10.0"
mkdir -p "$DIST_DIR/$PIXBUF_DIR/loaders"
cp "$MINGW_PREFIX/$PIXBUF_DIR/loaders/"*.dll \
"$DIST_DIR/$PIXBUF_DIR/loaders/"
cp "$MINGW_PREFIX/$PIXBUF_DIR/loaders.cache" \
"$DIST_DIR/$PIXBUF_DIR/"
# ******************************
# ******************************
#echo "packaging immodules"
#IMMODULES_DIR="lib/gtk-3.0/3.0.0"
#mkdir -p "$DIST_DIR/$IMMODULES_DIR/immodules"
#cp "$PREFIX/$IMMODULES_DIR/immodules/"*.dll \
#"$DIST_DIR/$IMMODULES_DIR/immodules/"
#cat /usr/x86_64-w64-mingw32/lib/gtk-3.0/3.0.0/immodules.cache | sed 's/\".*\/lib/lib/g' | sed 's/\/usr\/.*\/share/share/g' | sed 's/\//\\\\/g' > "$DIST_DIR/$IMMODULES_DIR/immodules.cache"
# ******************************
# ******************************
echo "packaging zrythm.exe"
cp "$MINGW_PREFIX/bin/zrythm.exe" "$DIST_BINDIR/"
cp "$MINGW_PREFIX/bin/zrythm_vst_check.exe" "$DIST_BINDIR/"
# ******************************
# ******************************
#echo "packaging licenses"
#cp $MINGW_PREFIX/share/licenses/zrythm/COPYING "$DIST_DIR/COPYING"
# ******************************
# ******************************
# original taken from ardour/tools/x-win/package.sh
# no license header, but ardour itself is GPLv2+
echo "Preparing Windows Installer"
cp -R $NSIS_DIR $DIST_DIR/
cd $DIST_DIR
NSISFILE=zrythm.nsis
PROGRAM_NAME=Zrythm
PROGRAM_KEY=Zrythm
major_version=${PROGRAM_VERSION:0:1}
PRODUCT_ID=${PROGRAM_NAME}
PRODUCT_EXE=zrythm.exe
PRODUCT_ICON=zrythm.ico
OUTFILE="Install_v$PROGRAM_VERSION.exe"
ZRYTHMDATE=$(date -R)
STATEFILE_SUFFIX=zpj # project file
QUICKZIP=1
if [[ $MINGW_PREFIX == *"mingw64"* ]]; then
PGF=PROGRAMFILES64
SFX=
WARCH=w64
else
PGF=PROGRAMFILES
# TODO we should only add this for 32bit on 64bit windows!
SFX=" (x86)"
WARCH=w32
fi
if test -n "$QUICKZIP" ; then
cat > $NSISFILE << EOF
SetCompressor zlib
EOF
else
cat > $NSISFILE << EOF
SetCompressor /SOLID lzma
SetCompressorDictSize 32
EOF
fi
cat >> $NSISFILE << EOF
!addincludedir "nsis\Include"
!addplugindir "nsis\Plugins"
!include MUI2.nsh
!include FileAssociation.nsh
!include FontName.nsh
!include FontRegAdv.nsh
!include WinVer.nsh
!define FontBackup Software\\${PRODUCT_NAME}\\${PRODUCT_ID}\\FontBackup
Name "${PROGRAM_NAME}"
OutFile "${OUTFILE}"
RequestExecutionLevel admin
InstallDir "\$${PGF}\\${PRODUCT_ID}"
InstallDirRegKey HKLM "Software\\${PRODUCT_NAME}\\${PRODUCT_ID}\\$WARCH" "Install_Dir"
!define MUI_ICON "${PRODUCT_ICON}"
EOF
cat >> $NSISFILE << EOF
!define MUI_FINISHPAGE_TITLE "Welcome to Zrythm"
!define MUI_FINISHPAGE_TEXT "Thank you for installing Zrythm.\$\\r\$\\nIf you would like to join the discussion, Zrythm has an IRC chatroom and a Matrix chatroom.\$\\r\$\\n\$\\r\$\\nPlease visit the website below to find out more."
!define MUI_FINISHPAGE_LINK "Zrythm website"
!define MUI_FINISHPAGE_LINK_LOCATION "https://www.zrythm.org/"
#this would run as admin - see http://forums.winamp.com/showthread.php?t=353366
#!define MUI_FINISHPAGE_RUN "\$INSTDIR\\bin\\${PRODUCT_EXE}"
!define MUI_FINISHPAGE_NOREBOOTSUPPORT
EOF
cat >> $NSISFILE << EOF
!define MUI_ABORTWARNING
!insertmacro MUI_PAGE_LICENSE "COPYING"
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
!insertmacro MUI_LANGUAGE "English"
Section "${PROGRAM_NAME} v${PROGRAM_VERSION} (required)" SecMainProg
SectionIn RO
SetOutPath \$INSTDIR
File /r bin
File /r COPYING
File /r COPYING.GPL3
File /r THANKS
File /r TRANSLATORS
File /r CONTRIBUTING.md
File /r CHANGELOG.md
File /r README.md
File /r AUTHORS
File /r lib
File /r share
File /r THIRDPARTY_INFO
File /r etc
WriteRegStr HKLM "Software\\${PROGRAM_KEY}\\v${major_version}\\$WARCH" "Install_Dir" "\$INSTDIR"
WriteRegStr HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\${PRODUCT_ID}-${WARCH}" "DisplayName" "${PROGRAM_NAME}"
WriteRegStr HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\${PRODUCT_ID}-${WARCH}" "UninstallString" '"\$INSTDIR\\uninstall.exe"'
WriteRegDWORD HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\${PRODUCT_ID}-${WARCH}" "NoModify" 1
WriteRegDWORD HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\${PRODUCT_ID}-${WARCH}" "NoRepair" 1
WriteUninstaller "\$INSTDIR\uninstall.exe"
CreateShortCut "\$INSTDIR\\${PROGRAM_NAME}.lnk" "\$INSTDIR\\bin\\${PRODUCT_EXE}" "" "\$INSTDIR\\bin\\${PRODUCT_EXE}" 0
\${registerExtension} "\$INSTDIR\\bin\\zrythm" ".${STATEFILE_SUFFIX}" "${PROGRAM_NAME} Session"
SetOutPath "\$WINDIR\\Fonts"
File /r share\\fonts\\zrythm\\DSEG14-Classic-MINI\\DSEG14ClassicMini-Italic.ttf
WriteRegStr HKLM "Software\\Microsoft\\Windows NT\\CurrentVersion\\Fonts" "DSEG14 Classic MINI (TrueType)" "DSEG14ClassicMini-Italic.ttf"
SetOutPath \$INSTDIR
SectionEnd
Section "WASAPI sound driver" SecWASAPI
SectionEnd
EOF
cat >> $NSISFILE << EOF
Section "Start Menu Shortcuts" SecMenu
SetShellVarContext all
CreateDirectory "\$SMPROGRAMS\\${PRODUCT_ID}${SFX}"
CreateShortCut "\$SMPROGRAMS\\${PRODUCT_ID}${SFX}\\${PROGRAM_NAME}.lnk" "\$INSTDIR\\bin\\${PRODUCT_EXE}" "" "\$INSTDIR\\bin\\${PRODUCT_EXE}" 0
EOF
cat >> $NSISFILE << EOF
CreateShortCut "\$SMPROGRAMS\\${PRODUCT_ID}${SFX}\\Uninstall.lnk" "\$INSTDIR\\uninstall.exe" "" "\$INSTDIR\\uninstall.exe" 0
SectionEnd
LangString DESC_SecMainProg \${LANG_ENGLISH} "${PROGRAM_NAME} v${PROGRAM_VERSION}\$\\r\$\\n${ZRYTHMDATE}"
LangString DESC_SecWASAPI \${LANG_ENGLISH} "WASAPI Audio Driver\$\\r\$\\nOnly works on Vista or later."
EOF
cat >> $NSISFILE << EOF
LangString DESC_SecMenu \${LANG_ENGLISH} "Create Start-Menu Shortcuts (recommended)."
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
!insertmacro MUI_DESCRIPTION_TEXT \${SecMainProg} \$(DESC_SecMainProg)
!insertmacro MUI_DESCRIPTION_TEXT \${SecWASAPI} \$(DESC_SecWASAPI)
EOF
cat >> $NSISFILE << EOF
!insertmacro MUI_DESCRIPTION_TEXT \${SecMenu} \$(DESC_SecMenu)
!insertmacro MUI_FUNCTION_DESCRIPTION_END
Section "Uninstall"
SetShellVarContext all
DeleteRegKey HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\${PRODUCT_ID}-${WARCH}"
DeleteRegKey HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\${PRODUCT_ID}"
DeleteRegKey HKLM "Software\\${PROGRAM_KEY}\\v${major_version}"
DeleteRegKey HKLM "Software\\${PROGRAM_KEY}\\v${major_version}"
RMDir /r "\$INSTDIR\\bin"
RMDir /r "\$INSTDIR\\lib"
RMDir /r "\$INSTDIR\\share"
RMDir /r "\$INSTDIR\\etc"
Delete "\$INSTDIR\\COPYING"
Delete "\$INSTDIR\\COPYING.GPL3"
Delete "\$INSTDIR\\THANKS"
Delete "\$INSTDIR\\TRANSLATORS"
Delete "\$INSTDIR\\CONTRIBUTING.md"
Delete "\$INSTDIR\\CHANGELOG.md"
Delete "\$INSTDIR\\README.md"
Delete "\$INSTDIR\\AUTHORS"
Delete "\$INSTDIR\\THIRDPARTY_INFO"
Delete "\$INSTDIR\\uninstall.exe"
Delete "\$INSTDIR\\${PROGRAM_NAME}.lnk"
RMDir "\$INSTDIR"
Delete "\$SMPROGRAMS\\${PRODUCT_ID}${SFX}\\*.*"
RMDir "\$SMPROGRAMS\\${PRODUCT_ID}${SFX}"
\${unregisterExtension} ".${STATEFILE_SUFFIX}" "${PROGRAM_NAME} Session"
DeleteRegValue HKLM "Software\\Microsoft\\Windows NT\\CurrentVersion\\Fonts" "DSEG14 Classic MINI (TrueType)"
SectionEnd
Function .onInit
ReadRegStr \$R0 HKLM \
"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\${PRODUCT_ID}-${WARCH}" \
"UninstallString"
StrCmp \$R0 "" done
MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION \
"${PROGRAM_NAME} is already installed. Click 'OK' to remove the previous version or 'Cancel' to cancel this upgrade." \
IDOK uninst
Abort
uninst:
ClearErrors
ExecWait '\$R0 _?=\$INSTDIR'
IfErrors uninstall_error
ReadRegStr \$R1 HKLM \
"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\${PRODUCT_ID}-${WARCH}" \
"UninstallString"
StrCmp \$R1 "" 0 done
Delete "\$INSTDIR\\uninstall.exe"
RMDir "\$INSTDIR"
goto done
uninstall_error:
MessageBox MB_OK|MB_ICONEXCLAMATION \
"Uninstaller did not complete successfully. Continue at your own risk..." \
IDOK done
done:
\${If} \${AtMostWinXP}
SectionSetFlags \${SecWASAPI} \${SF_RO}
\${Else}
SectionSetFlags \${SecWASAPI} 0
\${EndIf}
FunctionEnd
Function .onInstSuccess
\${If} \${AtMostWinXP}
goto endportaudio
\${EndIf}
endportaudio:
FunctionEnd
EOF
rm -f ${OUTFILE}
echo " === OutFile: $OUTFILE"
if test -n "$QUICKZIP" ; then
echo " === Building Windows Installer (fast zip)"
else
echo " === Building Windows Installer (lzma compression takes ages)"
fi
time makensis -V2 $NSISFILE
ls -lgGh "$OUTFILE"
cd $src_dir

190
tools/nsis/Include/FileAssociation.nsh

@ -0,0 +1,190 @@ @@ -0,0 +1,190 @@
/*
_____________________________________________________________________________
File Association
_____________________________________________________________________________
Based on code taken from http://nsis.sourceforge.net/File_Association
Usage in script:
1. !include "FileAssociation.nsh"
2. [Section|Function]
${FileAssociationFunction} "Param1" "Param2" "..." $var
[SectionEnd|FunctionEnd]
FileAssociationFunction=[RegisterExtension|UnRegisterExtension]
_____________________________________________________________________________
${RegisterExtension} "[executable]" "[extension]" "[description]"
"[executable]" ; executable which opens the file format
;
"[extension]" ; extension, which represents the file format to open
;
"[description]" ; description for the extension. This will be display in Windows Explorer.
;
${UnRegisterExtension} "[extension]" "[description]"
"[extension]" ; extension, which represents the file format to open
;
"[description]" ; description for the extension. This will be display in Windows Explorer.
;
_____________________________________________________________________________
Macros
_____________________________________________________________________________
Change log window verbosity (default: 3=no script)
Example:
!include "FileAssociation.nsh"
!insertmacro RegisterExtension
${FileAssociation_VERBOSE} 4 # all verbosity
!insertmacro UnRegisterExtension
${FileAssociation_VERBOSE} 3 # no script
*/
!ifndef FileAssociation_INCLUDED
!define FileAssociation_INCLUDED
!include Util.nsh
!verbose push
!verbose 3
!ifndef _FileAssociation_VERBOSE
!define _FileAssociation_VERBOSE 3
!endif
!verbose ${_FileAssociation_VERBOSE}
!define FileAssociation_VERBOSE `!insertmacro FileAssociation_VERBOSE`
!verbose pop
!macro FileAssociation_VERBOSE _VERBOSE
!verbose push
!verbose 3
!undef _FileAssociation_VERBOSE
!define _FileAssociation_VERBOSE ${_VERBOSE}
!verbose pop
!macroend
!macro RegisterExtensionCall _EXECUTABLE _EXTENSION _DESCRIPTION
!verbose push
!verbose ${_FileAssociation_VERBOSE}
Push `${_DESCRIPTION}`
Push `${_EXTENSION}`
Push `${_EXECUTABLE}`
${CallArtificialFunction} RegisterExtension_
!verbose pop
!macroend
!macro UnRegisterExtensionCall _EXTENSION _DESCRIPTION
!verbose push
!verbose ${_FileAssociation_VERBOSE}
Push `${_EXTENSION}`
Push `${_DESCRIPTION}`
${CallArtificialFunction} UnRegisterExtension_
!verbose pop
!macroend
!define RegisterExtension `!insertmacro RegisterExtensionCall`
!define un.RegisterExtension `!insertmacro RegisterExtensionCall`
!macro RegisterExtension
!macroend
!macro un.RegisterExtension
!macroend
!macro RegisterExtension_
!verbose push
!verbose ${_FileAssociation_VERBOSE}
Exch $R2 ;exe
Exch
Exch $R1 ;ext
Exch
Exch 2
Exch $R0 ;desc
Exch 2
Push $0
Push $1
ReadRegStr $1 HKCR $R1 "" ; read current file association
StrCmp "$1" "" NoBackup ; is it empty
StrCmp "$1" "$R0" NoBackup ; is it our own
WriteRegStr HKCR $R1 "backup_val" "$1" ; backup current value
NoBackup:
WriteRegStr HKCR $R1 "" "$R0" ; set our file association
ReadRegStr $0 HKCR $R0 ""
StrCmp $0 "" 0 Skip
WriteRegStr HKCR "$R0" "" "$R0"
WriteRegStr HKCR "$R0\shell" "" "open"
WriteRegStr HKCR "$R0\DefaultIcon" "" "$R2,0"
Skip:
WriteRegStr HKCR "$R0\shell\open\command" "" '"$R2" "%1"'
WriteRegStr HKCR "$R0\shell\edit" "" "Edit $R0"
WriteRegStr HKCR "$R0\shell\edit\command" "" '"$R2" "%1"'
Pop $1
Pop $0
Pop $R2
Pop $R1
Pop $R0
!verbose pop
!macroend
!define UnRegisterExtension `!insertmacro UnRegisterExtensionCall`
!define un.UnRegisterExtension `!insertmacro UnRegisterExtensionCall`
!macro UnRegisterExtension
!macroend
!macro un.UnRegisterExtension
!macroend
!macro UnRegisterExtension_
!verbose push
!verbose ${_FileAssociation_VERBOSE}
Exch $R1 ;desc
Exch
Exch $R0 ;ext
Exch
Push $0
Push $1
ReadRegStr $1 HKCR $R0 ""
StrCmp $1 $R1 0 NoOwn ; only do this if we own it
ReadRegStr $1 HKCR $R0 "backup_val"
StrCmp $1 "" 0 Restore ; if backup="" then delete the whole key
DeleteRegKey HKCR $R0
Goto NoOwn
Restore:
WriteRegStr HKCR $R0 "" $1
DeleteRegValue HKCR $R0 "backup_val"
DeleteRegKey HKCR $R1 ;Delete key with association name settings
NoOwn:
Pop $1
Pop $0
Pop $R1
Pop $R0
!verbose pop
!macroend
!endif # !FileAssociation_INCLUDED
Loading…
Cancel
Save