File macros.mingw64-installer of Package mingw64-installer-base
# Windows installer support for mingw64
#
# @author Ralf Habacker <ralf.habacker@freenet.de>
#
# Example:
# ...
#
# %_mingw64_installer_package -n mingw64-dbus-1 -p DBus-1 -P "DBus-1, a message bus system"
#
# %prep
# %_mingw64_installer_prep
#
# %build
# %_mingw64_installer_build -p dbus-1 -P DBus-1 -l $license_file -r mingw64-dbus-1 -s %{SOURCE0}
#
# %install
# %_mingw64_installer_install
#
# Template for portable and installer packages.
#
# -n <name> rpm package name prefix e.g mingw64-kmymoney
# -p <name> package name in summary
# -P <name> Package name in description
#
%_mingw64_installer_package(n:p:P:) \
BuildRequires: cmake >= 2.8.12 \
BuildRequires: mingw64-cross-nsis \
BuildRequires: mingw64-filesystem \
BuildRequires: p7zip \
\
%package %{-n:-n %{-n*}-}portable \
Summary: %{-p*} portable image \
License: %{license} \
Group: %{group} \
BuildArch: noarch \
\
%description %{-n:-n %{-n*}-}portable \
This package contains a 7z compressed portable installation \
image of %{-P*}. \
\
%package %{-n:-n %{-n*}-}setup \
Summary: %{-p*} setup installer \
License: %{license} \
Group: %{group} \
BuildArch: noarch \
\
%description %{-n:-n %{-n*}-}setup \
This package contains a setup installer of %{-P*}. \
\
%package %{-n:-n %{-n*}-}debugpackage \
Summary: %{-p*} debug package \
License: %{license} \
Group: %{group} \
BuildArch: noarch \
\
%description %{-n:-n %{-n*}-}debugpackage \
This package contains debug informations for the portable package and the installer of %{-P*}. \
\
%package %{-n:-n %{-n*}-}src \
Summary: %{-p*} source package \
License: %{license} \
Group: %{group} \
BuildArch: noarch \
\
%description %{-n:-n %{-n*}-}src \
This package contains the source files of %{-P*} \
\
%files %{-n:-n %{-n*}-}setup\
%defattr(-,root,root) \
/*.exe \
\
%files %{-n:-n %{-n*}-}portable \
%defattr(-,root,root) \
/*-portable.7z \
\
%files %{-n:-n %{-n*}-}debugpackage \
%defattr(-,root,root) \
/*-debug.7z \
\
%files %{-n:-n %{-n*}-}src \
%defattr(-,root,root) \
/*-src.7z
#
# %prep macro for creating installer and portable packages
#
# Files created below $PWD/tmp after calling this macro will
# be added to the generated package including the directory
# hierarchy.
#
# This macro is intended to be called in the %prep section.
#
%_mingw64_installer_prep %setup -q -c -T
#
# %build macro for creating installer and portable packages
#
# This macro creates setup installer, portable package,
# 7z compressed source and debug symbol package
#
# -P <name> full package name in installer e.g. KMyMoney
# -c create start.bat pointing to executable provided with -e option in top level directory
# -d Enable debugging of cmake configuring
# -e <executable> Application for which a start menu entry is to be added (e.g kmymoney)
# This option also adds a checkbox to run the given application when the installer exits
# -f "<extension list>"
# Map file extensions (e.g. '.txt') to the installed executable
# <extension list>: <ext>[;<ext>]
# -g <generator> Specify supported output formats (optional, default is NSIS;7Z)
# -h <url> help link for installer (optional, uses global spec variable Url: if not specified)
# -l <file> license file to be included in the installer
# -p <name> short package name in installer e.g. kmymoney
# -r <name> package name to get version from e.g. mingw64-kmymoney
# -s <source tar ball> source tar ball e.g. %{SOURCE0} (optional)
# -u <url> url info for installer (optional, uses global spec variable Url: if not specified)
#
# KDE auto shutdown support (optional, requires mingw32-kwinshutdown(5))
# -a <application> application name(s) to watch for auto shutdown support e.g. kmymoney or kmymoney,onlinequoteseditor
# -t <timeout> timeout for auto shutdown support (default 5 seconds)
# -5 Use KF5 variant for watcher executable and install locations
#
#
# This macro is intended to be called in the %build section.
#
%_mingw64_installer_build(a:cde:f:g:h:l:p:P:r:s:t:u:5) \
pkgname=%{-r:%{-r*}}%{!-r:%{name}} \
tarball=%{-s:%{-s*}} \
name=%{-p:%{-p*}} \
cmake_options=%{-d:--trace-expand} \
display_name=%{-P:%{-P*}}%{!-P:%{-p*}} \
help_link=%{-h:%{-h*}}%{!-h:%{url}} \
url_info=%{-u:%{-u*}}%{!-u:%{url}} \
shutdown_apps=%{-a:%{-a*}} \
start_batch_file=%{-c:1} \
executable=%{-e:%{-e*}} \
finish_run=%{-e:%{-e*}.exe} \
installed_icon_name=%{-e:bin/%{-e*}.exe} \
extensions=%{-f:%{-f*}} \
generator=%{-g:%{-g*}}%{!-g:"NSIS;7Z"} \
timeout=%{-t:%{-t*}}%{!-t:5} \
cp /etc/rpm/macros.mingw64-installer.CMakeLists.txt CMakeLists.txt \
local_install_dir=$PWD/tmp/ \
if test -n "$start_batch_file"; then \
mkdir -p $local_install_dir \
sed "s,@EXECUTABLE@,$executable,g" /etc/rpm/macros.mingw64-installer.start.bat.in > $local_install_dir/start.bat \
fi \
if test -n "$shutdown_apps"; then \
suffix=%{-5:5} \
watcher=kwinshutdown$suffix \
if test "$suffix" -eq "5"; then \
autostart_install_dir=$local_install_dir/etc/xdg/autostart \
else \
autostart_install_dir=$local_install_dir/share/autostart \
fi \
mkdir -p $autostart_install_dir \
apps=$(echo $shutdown_apps | sed 's#,# --watch #g') \
sed "s,@WATCH_APPLICATIONS@,--watch $apps,g;s,@TIMEOUT@,$timeout,g;s,@WATCHER@,$watcher,g" /etc/rpm/macros.mingw64-installer.kwinshutdown.desktop.in > $autostart_install_dir/${watcher}.desktop \
fi \
if test -d "$local_install_dir"; then \
local_install_opt="-DPACKAGE_LOCAL_INSTALL_DIR=$local_install_dir" \
fi \
suffix=mingw64 \
source_version=$(rpm -q $pkgname | sed "s,^$pkgname-,,g;s,.noarch,,g;s,\-.*,,g") \
binary_version=$(rpm -q $pkgname | sed "s,^$pkgname-,,g;s,.noarch,,g") \
license_file=%{-l:%{-l*}}%{!-l:/usr/share/doc/packages/$pkgname/COPYING} \
if test -f $license_file; then \
license_opt=-DPACKAGE_LICENSE_FILE=$license_file \
fi \
\
cmake \\\
-DCPACK_GENERATOR="$generator" \\\
-DPACKAGE_DISPLAY_NAME="$display_name $source_version" \\\
-DPACKAGE_FINISH_RUN=$finish_run \\\
-DPACKAGE_HELP_LINK=$help_link \\\
-DPACKAGE_INSTALLED_ICON_NAME=$installed_icon_name \\\
-DPACKAGE_INSTALL_DIR=%{_mingw64_prefix}/ \\\
-DPACKAGE_NAME=$name \\\
-DPACKAGE_REGISTER_EXTENSIONS="$extensions" \\\
-DPACKAGE_URL_INFO=$url_info \\\
-DPACKAGE_VERSION=$source_version \\\
$cmake_options \\\
$license_opt \\\
$local_install_opt \\\
. \
echo "show symlinks in installation root, which may lead to left over files after uninstalling" \
find -type l -ls \
cpack --verbose --debug \
case "$generator" in \
*NSIS*) \
mv *.exe $name-$suffix-$binary_version-setup.exe \
;; \
esac \
case "$generator" in \
*7Z*) \
mv *.7z $name-$suffix-$binary_version-portable.7z \
;; \
esac \
\
mkdir dbgtmp \
cd dbgtmp \
dirs=%{_mingw64_prefix}/src \
if test -d "%{_mingw64_prefix}/symbols"; then \
dirs+=" %{_mingw64_prefix}/symbols" \
fi \
cp -av $dirs . \
for i in $(cd %{_mingw64_prefix}; find -name '*.debug'); do \
d=$(dirname $i) \
install -d $d \
install %{_mingw64_prefix}/$i $d \
done \
7za a ../$name-$suffix-$binary_version-debug.7z . \
cd .. \
\
mkdir srctmp \
cd srctmp \
case $tarball in \
*.tar.xz) tar -xJf $tarball ;; \
*.tar.bz2) tar -xjf $tarball ;; \
*.tar.gz) tar -xzf $tarball ;; \
*) echo "unsupported tarball format";; \
esac \
if test -f $tarball; then \
7za a ../$name-$source_version-src.7z * \
fi
#
# %install macro for creating installer and portable packages
#
# This macro is intended to be called in the %install section.
#
%_mingw64_installer_install \
mkdir -p %{buildroot} \
executables=$(ls *.exe 2> /dev/null | wc -l) \
if test $executables -ne 0; then \
install -m 644 *.exe %{buildroot} \
fi \
install -m 644 *.7z %{buildroot}