diff --git a/.github/workflows/ccpp.yml b/.github/workflows/ccpp.yml new file mode 100644 index 00000000..2f59bba5 --- /dev/null +++ b/.github/workflows/ccpp.yml @@ -0,0 +1,195 @@ +name: Automatic build + +on: + push: + branches: + - '**' + release: + types: [ created ] + +jobs: + Linux: + if: github.event_name == 'push' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + with: + fetch-depth: 1 + - name: Install dependencies + run: | + sudo apt update + sudo apt install libxss1 libgstreamer-plugins-base1.0-0 libgstreamer1.0-0 qt5-default libqt5gui5 libqt5webengine5 libqt5webenginecore5 libqt5webenginewidgets5 libqt5printsupport5 libqt5quickwidgets5 qml-module-qtquick-controls libqt5x11extras5 binutils cmake pkg-config qtbase5-dev qtwebengine5-dev libqt5x11extras5-dev qtbase5-private-dev libssl-dev libxss-dev libxmu-dev + - name: Configure + run: qmake . + - name: Build + run: make -j2 + + Flatpak: + if: github.event_name == 'release' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + with: + fetch-depth: 1 + - name: Install dependencies + run: | + sudo apt update + sudo apt install flatpak flatpak-builder + - name: Install Flatpak KDE SDK + run: | + sudo flatpak remote-add --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo + sudo flatpak install --system -y flathub org.kde.Platform//5.14 + sudo flatpak install --system -y flathub org.kde.Sdk//5.14 + - name: Build the Flatpak package + run: | + TAG_NAME=$(bash ./dist/get-tag-name.sh) + pushd dist/flatpak + sudo flatpak-builder --repo=flatpak-repo --force-clean flatpak-build org.fedoraproject.MediaWriter.json + flatpak build-bundle flatpak-repo org.fedoraproject.MediaWriter.flatpak org.fedoraproject.MediaWriter + mv org.fedoraproject.MediaWriter.flatpak ../../org.fedoraproject.MediaWriter-$TAG_NAME.flatpak + popd + - name: Upload to GitHub + if: github.event_name == 'release' + shell: bash + run: | + TAG_NAME=$(bash ./dist/get-tag-name.sh) + bash ./dist/upload-to-github.sh github_api_token=${{ secrets.GITHUB_TOKEN }} tag="$TAG_NAME" filename="org.fedoraproject.MediaWriter-$TAG_NAME.flatpak" + + macOS: + runs-on: macos-latest + steps: + - uses: actions/checkout@v1 + with: + fetch-depth: 1 + - name: Install dependencies + run: | + brew install qt + echo 'export PATH="/usr/local/opt/qt/bin:$PATH"' >> ~/.bash_profile + brew install xz + brew install git + npm install -g create-dmg + - name: Configure + run: | + TAG_NAME=$(bash ./dist/get-tag-name.sh) + bash dist/mac/build.sh configure + - name: Build + run: | + TAG_NAME=$(bash ./dist/get-tag-name.sh) + bash dist/mac/build.sh build + - name: Insert dependencies + if: github.event_name == 'release' + run: | + TAG_NAME=$(bash ./dist/get-tag-name.sh) + bash dist/mac/build.sh deps + - name: Sign (TBD) + if: github.event_name == 'release' + run: | + TAG_NAME=$(bash ./dist/get-tag-name.sh) + true # bash dist/mac/build.sh sign + - name: Package + if: github.event_name == 'release' + run: | + TAG_NAME=$(bash ./dist/get-tag-name.sh) + cd build/app + create-dmg "Fedora Media Writer.app" || true # without signing, create-dmg returns an error code + mv Fedora*.dmg ../../FedoraMediaWriter-osx-$TAG_NAME.unnotarized.dmg + - name: Notarize (TBD) + if: github.event_name == 'release' + run: | + TAG_NAME=$(bash ./dist/get-tag-name.sh) + true # bash dist/mac/build.sh notarize + - name: Upload to GitHub + if: github.event_name == 'release' + shell: bash + run: | + TAG_NAME=$(bash ./dist/get-tag-name.sh) + bash ./dist/upload-to-github.sh github_api_token=${{ secrets.GITHUB_TOKEN }} tag="$TAG_NAME" filename="FedoraMediaWriter-osx-$TAG_NAME.unnotarized.dmg" + + Windows: + runs-on: windows-latest + steps: + - uses: actions/checkout@v1 + with: + fetch-depth: 1 + - name: Cache Qt + id: cache-qt + uses: actions/cache@v1 + with: + path: d:/a/MediaWriter/Qt + key: QtCache + - name: Install dependencies + shell: bash + run: | + choco install nsis + choco install dos2unix + - name: Install Qt + uses: jurplel/install-qt-action@v2 + with: + cached: ${{ steps.cache-qt.outputs.cache-hit }} + arch: win64_mingw73 + - name: Build xz-utils + shell: bash + if: ${{ !steps.cache-qt.outputs.cache-hit }} + run: | + git clone https://git.tukaani.org/xz.git + sed -i 's/#include "config.h"//' xz/src/common/common_w32res.rc + sed -i 's/PACKAGE_NAME/"liblzma"/' xz/src/common/common_w32res.rc + sed -i 's/PACKAGE_URL/"https:\/\/tukaani.org\/xz\/"/' xz/src/common/common_w32res.rc + mkdir xz/build + cd xz/build + cmake -DCMAKE_SH="CMAKE_SH-NOTFOUND" -G "MinGW Makefiles" -DCMAKE_INSTALL_PREFIX="$Qt5_Dir" -DBUILD_SHARED_LIBS=ON .. + mingw32-make -j2 VERBOSE=1 + mingw32-make install + # ugh + cp "$Qt5_Dir/bin/liblzma.dll" "$Qt5_Dir/bin/libliblzma.dll" + - name: Build MediaWriter + shell: bash + run: | + #export PATH=$(echo "$PATH" | sed -e 's/:\/c\/ProgramData\/Chocolatey\/bin//' | sed -e 's/:\/c\/Strawberry\/c\/bin//') + #export PATH="$Qt5_Dir/../../Tools/mingw730_32/bin:$PATH" + mkdir build + cd build + "$Qt5_Dir/bin/qmake" .. + mingw32-make -j2 VERBOSE=1 + - name: Windeployqt + if: github.event_name == 'release' + shell: bash + run: | + cd build/app/release + mv ../helper.exe . + $Qt5_Dir/bin/windeployqt -qmldir ../../.. mediawriter.exe + cp $Qt5_Dir/bin/libstdc*.dll . + cp $Qt5_Dir/bin/libwinpthread*.dll . + cp $Qt5_Dir/bin/libgcc*.dll . + cp /c/Program\ Files/OpenSSL/bin/*.dll . + - name: Installer + if: github.event_name == 'release' + shell: bash + run: | + TAG_NAME=$(bash ./dist/get-tag-name.sh) + + VERSION_STRIPPED=$(sed "s/-.*//" <<< "${TAG_NAME}") + if [[ "$VERSION_STRIPPED" == "" ]]; then + VERSION_STRIPPED=0.0.0 + fi + VERSION_MAJOR=$(cut -d. -f1 <<< "${VERSION_STRIPPED}") + VERSION_MINOR=$(cut -d. -f2 <<< "${VERSION_STRIPPED}") + VERSION_BUILD=$(cut -d. -f3 <<< "${VERSION_STRIPPED}") + INSTALLED_SIZE=$(du -k -d0 "build/app/release" | cut -f1) + + cp "dist/win/mediawriter_native.nsi" "dist/win/mediawriter_native.tmp.nsi" + + sed -i "s/#!define VERSIONMAJOR/!define VERSIONMAJOR ${VERSION_MAJOR}/" "dist/win/mediawriter_native.tmp.nsi" + sed -i "s/#!define VERSIONMINOR/!define VERSIONMINOR ${VERSION_MINOR}/" "dist/win/mediawriter_native.tmp.nsi" + sed -i "s/#!define VERSIONBUILD/!define VERSIONBUILD ${VERSION_BUILD}/" "dist/win/mediawriter_native.tmp.nsi" + sed -i "s/#!define INSTALLSIZE/!define INSTALLSIZE ${INSTALLED_SIZE}/" "dist/win/mediawriter_native.tmp.nsi" + + unix2dos < "LICENSE" > "build/app/release/LICENSE.txt" + makensis -DCERTPATH="" -DCERTPASS="" dist/win/mediawriter_native.tmp.nsi + mv dist/win/FMW-setup.exe ./"FedoraMediaWriter-win64-$TAG_NAME.exe" + - name: Upload to GitHub + if: github.event_name == 'release' + shell: bash + run: | + TAG_NAME=$(bash ./dist/get-tag-name.sh) + bash ./dist/upload-to-github.sh github_api_token=${{ secrets.GITHUB_TOKEN }} tag="$TAG_NAME" filename="FedoraMediaWriter-win64-$TAG_NAME.exe" diff --git a/app/Info.plist b/app/Info.plist index e7d90067..b7209252 100644 --- a/app/Info.plist +++ b/app/Info.plist @@ -4,6 +4,8 @@ NSPrincipalClass NSApplication + CFBundleDisplayName + Fedora Media Writer CFBundleIconFile @ICON@ CFBundlePackageType diff --git a/deployment.pri b/deployment.pri index 01164e72..b43adcda 100644 --- a/deployment.pri +++ b/deployment.pri @@ -16,7 +16,7 @@ linux { QMAKE_LIBDIR += $$top_builddir/lib INCLUDEPATH += $$top_srcdir/lib/ isEmpty(MEDIAWRITER_VERSION) { - MEDIAWRITER_VERSION=$$quote($$system(git -C \""$$_PRO_FILE_PWD_"\" describe --tags || echo N/A)) + MEDIAWRITER_VERSION=$$quote($$system(git -C \""$$_PRO_FILE_PWD_"\" describe --tags || echo "Not-Available")) } MEDIAWRITER_VERSION_SHORT=$$section(MEDIAWRITER_VERSION,-,0,0) DEFINES += MEDIAWRITER_VERSION="\\\"$$MEDIAWRITER_VERSION\\\"" diff --git a/dist/flatpak/org.fedoraproject.MediaWriter.json b/dist/flatpak/org.fedoraproject.MediaWriter.json index 954fe6b5..27c6f50c 100644 --- a/dist/flatpak/org.fedoraproject.MediaWriter.json +++ b/dist/flatpak/org.fedoraproject.MediaWriter.json @@ -1,7 +1,7 @@ { "id": "org.fedoraproject.MediaWriter", "runtime": "org.kde.Platform", - "runtime-version": "5.12", + "runtime-version": "5.14", "sdk": "org.kde.Sdk", "command": "mediawriter", "rename-appdata-file": "mediawriter.appdata.xml", diff --git a/dist/get-tag-name.sh b/dist/get-tag-name.sh new file mode 100644 index 00000000..4b4db2ee --- /dev/null +++ b/dist/get-tag-name.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +PROBABLY_TAG=${GITHUB_REF/refs\/tags\//} + +grep "^[0-9][0-9]*[.][0-9][0-9]*[.][0-9][0-9]*$" <<< "$PROBABLY_TAG" + +exit 0 diff --git a/dist/mac/build.sh b/dist/mac/build.sh index e5e81dab..f9e4cc48 100644 --- a/dist/mac/build.sh +++ b/dist/mac/build.sh @@ -1,7 +1,12 @@ #!/bin/bash +set -x +set -e + +PATH="/usr/local/opt/qt/bin:/usr/local/opt/git/bin:$PATH" + DEVELOPER_ID="Mac Developer: Martin Briza (N952V7G2F5)" -QT_ROOT="${HOME}/Qt/5.12.1/clang_64" +QT_ROOT="/usr/local/opt/qt" QMAKE="${QT_ROOT}/bin/qmake" MACDEPLOYQT="${QT_ROOT}/bin/macdeployqt" NOTARIZATION_EMAIL="" @@ -14,53 +19,90 @@ popd >/dev/null cd "${SCRIPTDIR}/../.." -INSTALLER="$SCRIPTDIR/FedoraMediaWriter-osx-$(git describe --tags).dmg" - -rm -fr "build" -mkdir -p "build" -pushd build >/dev/null - -echo "=== Building ===" -${QMAKE} .. >/dev/null -make -j9 >/dev/null - -echo "=== Inserting Qt deps ===" -cp "helper/mac/helper.app/Contents/MacOS/helper" "app/Fedora Media Writer.app/Contents/MacOS" -${MACDEPLOYQT} "app/Fedora Media Writer.app" -qmldir="../app" -executable="app/Fedora Media Writer.app/Contents/MacOS/helper" - -echo "=== Checking unresolved library deps ===" -# Look at the binaries and search for dynamic library dependencies that are not included on every system -# So far, this finds only liblzma but in the future it may be necessary for more libs -for binary in "helper" "Fedora Media Writer"; do - otool -L "app/Fedora Media Writer.app/Contents/MacOS/$binary" |\ - grep -E "^\s" | grep -Ev "Foundation|OpenGL|AGL|DiskArbitration|IOKit|libc\+\+|libobjc|libSystem|@rpath" |\ - sed -e 's/[[:space:]]\([^[:space:]]*\).*/\1/' |\ - while read library; do - if [[ ! $library == @loader_path/* ]]; then - echo "Copying $(basename $library)" - cp $library "app/Fedora Media Writer.app/Contents/Frameworks" - install_name_tool -change "$library" "@executable_path/../Frameworks/$(basename ${library})" "app/Fedora Media Writer.app/Contents/MacOS/$binary" - fi +if [[ "$TAG_NAME" == "" ]]; then + VERSION=$(git describe --tags --always) +else + VERSION="$TAG_NAME" +fi + +INSTALLER="$SCRIPTDIR/FedoraMediaWriter-osx-$VERSION.dmg" + +function configure() { + rm -fr "build" + mkdir -p "build" + pushd build >/dev/null + + echo "=== Building ===" + ${QMAKE} .. + popd >/dev/null +} + +function build() { + pushd build >/dev/null + make -j9 + popd >/dev/null +} + +function deps() { + pushd build >/dev/null + echo "=== Inserting Qt deps ===" + cp "helper/mac/helper.app/Contents/MacOS/helper" "app/Fedora Media Writer.app/Contents/MacOS" + ${MACDEPLOYQT} "app/Fedora Media Writer.app" -qmldir="../app" -executable="app/Fedora Media Writer.app/Contents/MacOS/helper" + + echo "=== Checking unresolved library deps ===" + # Look at the binaries and search for dynamic library dependencies that are not included on every system + # So far, this finds only liblzma but in the future it may be necessary for more libs + for binary in "helper" "Fedora Media Writer"; do + otool -L "app/Fedora Media Writer.app/Contents/MacOS/$binary" |\ + grep -E "^\s" | grep -Ev "Foundation|OpenGL|AGL|DiskArbitration|IOKit|libc\+\+|libobjc|libSystem|@rpath" |\ + sed -e 's/[[:space:]]\([^[:space:]]*\).*/\1/' |\ + while read library; do + if [[ ! $library == @loader_path/* ]]; then + echo "Copying $(basename $library)" + cp $library "app/Fedora Media Writer.app/Contents/Frameworks" + install_name_tool -change "$library" "@executable_path/../Frameworks/$(basename ${library})" "app/Fedora Media Writer.app/Contents/MacOS/$binary" + fi + done done -done + popd >/dev/null +} -echo "=== Signing the package ===" -# sign all frameworks and then the package -find app/Fedora\ Media\ Writer.app -name "*framework" | while read framework; do - codesign -s "$DEVELOPER_ID" --deep -v -f "$framework/Versions/Current/" -o runtime -done -codesign -s "$DEVELOPER_ID" --deep -v -f app/Fedora\ Media\ Writer.app/ -o runtime +function sign() { + pushd build >/dev/null + echo "=== Signing the package ===" + # sign all frameworks and then the package + find app/Fedora\ Media\ Writer.app -name "*framework" | while read framework; do + codesign -s "$DEVELOPER_ID" --deep -v -f "$framework/Versions/Current/" -o runtime + done + codesign -s "$DEVELOPER_ID" --deep -v -f app/Fedora\ Media\ Writer.app/ -o runtime + popd >/dev/null +} -echo "=== Creating a disk image ===" -# create the .dmg package - beware, it won't work while FMW is running (blocks partition mounting) -rm -f ../FedoraMediaWriter-osx-$(git describe --tags).dmg -hdiutil create -srcfolder app/Fedora\ Media\ Writer.app -format UDCO -imagekey zlib-level=9 -scrub -volname FedoraMediaWriter-osx ../FedoraMediaWriter-osx-$(git describe --tags).unnotarized.dmg +function dmg() { + pushd build >/dev/null + echo "=== Creating a disk image ===" + # create the .dmg package - beware, it won't work while FMW is running (blocks partition mounting) + rm -f "../FedoraMediaWriter-osx-$VERSION.dmg" + hdiutil create -srcfolder app/Fedora\ Media\ Writer.app -format UDCO -imagekey zlib-level=9 -scrub -volname FedoraMediaWriter-osx ../FedoraMediaWriter-osx-$VERSION.unnotarized.dmg + popd >/dev/null +} -echo "=== Submitting for notarization ===" -xcrun altool --notarize-app --primary-bundle-id "org.fedoraproject.mediawriter" --username "${NOTARIZATION_EMAIL}" --password "@keychain:${NOTARIZATION_KEYCHAIN_ITEM}" --asc-provider "${NOTARIZATION_ITUNES_ORGID}" --file "../FedoraMediaWriter-osx-$(git describe --tags).unnotarized.dmg" +function notarize() { + echo "=== Submitting for notarization ===" + xcrun altool --notarize-app --primary-bundle-id "org.fedoraproject.mediawriter" --username "${NOTARIZATION_EMAIL}" --password "@keychain:${NOTARIZATION_KEYCHAIN_ITEM}" --asc-provider "${NOTARIZATION_ITUNES_ORGID}" --file "../FedoraMediaWriter-osx-$VERSION.unnotarized.dmg" -echo "DONE. After notarization finished (you'll get an email), run:" -echo "$ xcrun stabler stable app/Fedora\ Media\ Writer.app" -echo "$ hdiutil create -srcfolder app/Fedora\ Media\ Writer.app -format UDCO -imagekey zlib-level=9 -scrub -volname FedoraMediaWriter-osx ../FedoraMediaWriter-osx-$(git describe --tags).dmg" + echo "DONE. After notarization finished (you'll get an email), run:" + echo "$ xcrun stabler stable app/Fedora\ Media\ Writer.app" + echo "$ hdiutil create -srcfolder app/Fedora\ Media\ Writer.app -format UDCO -imagekey zlib-level=9 -scrub -volname FedoraMediaWriter-osx ../FedoraMediaWriter-osx-$VERSION.dmg" +} -popd >/dev/null +if [[ $# -eq 0 ]]; then + configure + build + deps + sign + dmg + notarize +else + $1 +fi diff --git a/dist/upload-to-github.sh b/dist/upload-to-github.sh new file mode 100644 index 00000000..58cfffb2 --- /dev/null +++ b/dist/upload-to-github.sh @@ -0,0 +1,75 @@ +#!/usr/bin/env bash +# +# Author: Stefan Buck +# License: MIT +# https://gist.github.com/stefanbuck/ce788fee19ab6eb0b4447a85fc99f447 +# +# +# This script accepts the following parameters: +# +# * tag +# * filename +# * github_api_token +# +# Script to upload a release asset using the GitHub API v3. +# +# Expects $GITHUB_REPOSITORY in the environment (set by GitHub Actions) +# +# Example: +# +# upload-github-release-asset.sh github_api_token=TOKEN tag=v0.1.0 filename=./build.zip +# + +# Check dependencies. +set -e +set -x + +# Validate settings. +[ "$TRACE" ] && set -x + +CONFIG=$@ + +for line in $CONFIG; do + eval "$line" +done + +# Define variables. +OWNER=${GITHUB_REPOSITORY/\/*/} +REPO=${GITHUB_REPOSITORY/*\//} +GH_API="https://api.github.com" +GH_REPO="$GH_API/repos/$OWNER/$REPO" +GH_RELEASES="$GH_REPO/releases" +GH_TAGS="$GH_RELEASES/tags/$tag" +AUTH="Authorization: token $github_api_token" +WGET_ARGS="--content-disposition --auth-no-challenge --no-cookie" +CURL_ARGS="-LJO#" + +if [[ "$tag" == 'LATEST' ]]; then + GH_TAGS="$GH_REPO/releases/latest" +fi + +if [[ "$renameto" != "" ]]; then + mv "$filename" "$renameto" + filename="$renameto" +fi + +# Validate token. +curl -o /dev/null -sH "$AUTH" $GH_REPO || { echo "Error: Invalid repo, token or network issue!"; exit 1; } + +curl -d '{ "tag_name": "'$tag'", "target_commitish": "", "name": "'$tag'", "body": "'$tag'", "draft": false, "prerelease": true }' -H "Content-Type: application/json" -X POST -o /dev/null -sH "$AUTH" $GH_RELEASES + +# Read asset tags. +response=$(curl -sH "$AUTH" $GH_TAGS) + +# Get ID of the asset based on given filename. +eval $(echo "$response" | grep -m 1 "id.:" | grep -w id | tr : = | tr -cd '[[:alnum:]]=') +[ "$id" ] || { echo "Error: Failed to get release id for tag: $tag"; echo "$response" | awk 'length($0)<100' >&2; exit 1; } + +# Upload asset +echo "Uploading asset... " + +# Construct url +GH_ASSET="https://uploads.github.com/repos/$OWNER/$REPO/releases/$id/assets?name=$(basename $filename)" + +curl "$GITHUB_OAUTH_BASIC" --data-binary @"$filename" -H "Authorization: token $github_api_token" -H "Content-Type: application/octet-stream" $GH_ASSET + diff --git a/dist/win/mediawriter.nsi b/dist/win/mediawriter.nsi index 5cd36602..bdeb9754 100644 --- a/dist/win/mediawriter.nsi +++ b/dist/win/mediawriter.nsi @@ -23,7 +23,7 @@ XPStyle on !ifdef INNER !echo "Inner invocation" ; just to see what's going on - OutFile "../../build/tempinstaller.exe" ; not really important where this is + OutFile "tempinstaller.exe" ; not really important where this is SetCompress off ; for speed !else !echo "Outer invocation" @@ -34,8 +34,8 @@ XPStyle on !makensis '-DINNER "${__FILE__}"' = 0 ; Run the temporary installer and then sign the unsigned binary that has been created - !system "chmod +x ../../build/tempinstaller.exe" = 0 - !system "../../build/tempinstaller.exe" = 512 + !system "chmod +x tempinstaller.exe" = 0 + !system "tempinstaller.exe" = 512 !if "${CERTPASS}" != "" !system 'osslsigncode sign -pkcs12 "${CERTPATH}/authenticode.pfx" -readpass "${CERTPASS}" -h sha256 -n "Fedora Media Writer" -i https://getfedora.org -t http://timestamp.verisign.com/scripts/timstamp.dll -in "../../build/wineprefix/drive_c/uninstall.unsigned.exe" -out "../../build/wineprefix/drive_c/uninstall.exe" ' = 0 !else diff --git a/dist/win/mediawriter_native.nsi b/dist/win/mediawriter_native.nsi new file mode 100644 index 00000000..b28e462b --- /dev/null +++ b/dist/win/mediawriter_native.nsi @@ -0,0 +1,220 @@ +!include "MUI2.nsh" +XPStyle on + +# If you change the names "app.exe", "logo.ico", or "license.rtf" you should do a search and replace - they +# show up in a few places. +# All the other settings can be tweaked by editing the !defines at the top of this script +!define APPNAME "Fedora Media Writer" +!define COMPANYNAME "Fedora Project" +!define DESCRIPTION "Tool to write Fedora images to flash drives" +# These three must be defined from command line +#!define VERSIONMAJOR +#!define VERSIONMINOR +#!define VERSIONBUILD +# These will be displayed by the "Click here for support information" link in "Add/Remove Programs" +# It is possible to use "mailto:" links in here to open the email client +!define HELPURL "https://github.com/MartinBriza/MediaWriter" # "Support Information" link +!define UPDATEURL "https://getfedora.org" # "Product Updates" link +!define ABOUTURL "https://getfedora.org" # "Publisher" link +# This is the size (in kB) of all the files copied into "Program Files" +#!define INSTALLSIZE + + + +!ifdef INNER + !echo "Inner invocation" ; just to see what's going on + OutFile "tempinstaller.exe" ; not really important where this is + SetCompress off ; for speed +!else + !echo "Outer invocation" + + ; Call makensis again against current file, defining INNER. This writes an installer for us which, when + ; it is invoked, will just write the uninstaller to some location, and then exit. + + !makensis '-DINNER "${__FILE__}"' = 0 + + ; Run the temporary installer and then sign the unsigned binary that has been created + !system "chmod +x tempinstaller.exe" = 0 + !system "tempinstaller.exe" = 2 + !if "${CERTPASS}" != "" + !system 'osslsigncode sign -pkcs12 "${CERTPATH}/authenticode.pfx" -readpass "${CERTPASS}" -h sha256 -n "Fedora Media Writer" -i https://getfedora.org -t http://timestamp.verisign.com/scripts/timstamp.dll -in "/c/uninstall.unsigned.exe" -out "/c/uninstall.exe" ' = 0 + !else + !system 'mv "/c/uninstall.unsigned.exe" "/c/uninstall.exe"' = 0 + !endif + + outFile "FMW-setup.exe" + SetCompressor /SOLID lzma +!endif + + +RequestExecutionLevel admin ;Require admin rights on NT6+ (When UAC is turned on) + +InstallDir "$PROGRAMFILES\${APPNAME}" + +# rtf or txt file - remember if it is txt, it must be in the DOS text format (\r\n) +LicenseData "../../build/app/release/LICENSE.txt" +# This will be in the installer/uninstaller's title bar +Name "${APPNAME}" +Icon "../../app/assets/icon/mediawriter.ico" + +!include LogicLib.nsh + +!define MUI_ICON ../../app/assets/icon/mediawriter.ico + +!insertmacro MUI_PAGE_LICENSE "../../build/app/release/LICENSE.txt" +!insertmacro MUI_PAGE_DIRECTORY +!insertmacro MUI_PAGE_INSTFILES +!define MUI_FINISHPAGE_NOAUTOCLOSE +!define MUI_FINISHPAGE_RUN $INSTDIR\mediawriter.exe +!insertmacro MUI_PAGE_FINISH + +!insertmacro MUI_UNPAGE_CONFIRM +!insertmacro MUI_UNPAGE_INSTFILES + +!insertmacro MUI_LANGUAGE "English" ;first language is the default language +!insertmacro MUI_LANGUAGE "French" +!insertmacro MUI_LANGUAGE "German" +!insertmacro MUI_LANGUAGE "Spanish" +!insertmacro MUI_LANGUAGE "SpanishInternational" +!insertmacro MUI_LANGUAGE "SimpChinese" +!insertmacro MUI_LANGUAGE "TradChinese" +!insertmacro MUI_LANGUAGE "Japanese" +!insertmacro MUI_LANGUAGE "Korean" +!insertmacro MUI_LANGUAGE "Italian" +!insertmacro MUI_LANGUAGE "Dutch" +!insertmacro MUI_LANGUAGE "Danish" +!insertmacro MUI_LANGUAGE "Swedish" +!insertmacro MUI_LANGUAGE "Norwegian" +!insertmacro MUI_LANGUAGE "NorwegianNynorsk" +!insertmacro MUI_LANGUAGE "Finnish" +!insertmacro MUI_LANGUAGE "Greek" +!insertmacro MUI_LANGUAGE "Russian" +!insertmacro MUI_LANGUAGE "Portuguese" +!insertmacro MUI_LANGUAGE "PortugueseBR" +!insertmacro MUI_LANGUAGE "Polish" +!insertmacro MUI_LANGUAGE "Ukrainian" +!insertmacro MUI_LANGUAGE "Czech" +!insertmacro MUI_LANGUAGE "Slovak" +!insertmacro MUI_LANGUAGE "Croatian" +!insertmacro MUI_LANGUAGE "Bulgarian" +!insertmacro MUI_LANGUAGE "Hungarian" +!insertmacro MUI_LANGUAGE "Thai" +!insertmacro MUI_LANGUAGE "Romanian" +!insertmacro MUI_LANGUAGE "Latvian" +!insertmacro MUI_LANGUAGE "Macedonian" +!insertmacro MUI_LANGUAGE "Estonian" +!insertmacro MUI_LANGUAGE "Turkish" +!insertmacro MUI_LANGUAGE "Lithuanian" +!insertmacro MUI_LANGUAGE "Slovenian" +!insertmacro MUI_LANGUAGE "Serbian" +!insertmacro MUI_LANGUAGE "SerbianLatin" +!insertmacro MUI_LANGUAGE "Arabic" +!insertmacro MUI_LANGUAGE "Farsi" +!insertmacro MUI_LANGUAGE "Hebrew" +!insertmacro MUI_LANGUAGE "Indonesian" +!insertmacro MUI_LANGUAGE "Mongolian" +!insertmacro MUI_LANGUAGE "Luxembourgish" +!insertmacro MUI_LANGUAGE "Albanian" +!insertmacro MUI_LANGUAGE "Breton" +!insertmacro MUI_LANGUAGE "Belarusian" +!insertmacro MUI_LANGUAGE "Icelandic" +!insertmacro MUI_LANGUAGE "Malay" +!insertmacro MUI_LANGUAGE "Bosnian" +!insertmacro MUI_LANGUAGE "Kurdish" +!insertmacro MUI_LANGUAGE "Irish" +!insertmacro MUI_LANGUAGE "Uzbek" +!insertmacro MUI_LANGUAGE "Galician" +!insertmacro MUI_LANGUAGE "Afrikaans" +!insertmacro MUI_LANGUAGE "Catalan" +!insertmacro MUI_LANGUAGE "Esperanto" + +!macro VerifyUserIsAdmin +UserInfo::GetAccountType +pop $0 +${If} $0 != "admin" ;Require admin rights on NT4+ + messageBox mb_iconstop "Administrator rights required!" + setErrorLevel 740 ;ERROR_ELEVATION_REQUIRED + quit +${EndIf} +!macroend + +function .onInit + !ifdef INNER + + ; If INNER is defined, then we aren't supposed to do anything except write out + ; the installer. This is better than processing a command line option as it means + ; this entire code path is not present in the final (real) installer. + + WriteUninstaller "C:\uninstall.unsigned.exe" + Quit ; just bail out quickly when running the "inner" installer + !endif + + setShellVarContext all + !insertmacro VerifyUserIsAdmin +functionEnd + +section "install" + # Files for the install directory - to build the installer, these should be in the same directory as the install script (this file) + SetOutPath $INSTDIR + SetOverwrite on + + !ifndef INNER + SetOutPath $INSTDIR + + # Files added here should be removed by the uninstaller (see section "uninstall") + File /r "..\..\build\app\release\*.*" + File "..\..\app\assets\icon\mediawriter.ico" + + ; this packages the signed uninstaller + File c:\uninstall.exe + !endif + + # Start Menu + createShortCut "$SMPROGRAMS\${APPNAME}.lnk" "$INSTDIR\mediawriter.exe" "" "$INSTDIR\mediawriter.ico" + + # Registry information for add/remove programs + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" "DisplayName" "${APPNAME}" + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" "UninstallString" "$\"$INSTDIR\uninstall.exe$\"" + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" "QuietUninstallString" "$\"$INSTDIR\uninstall.exe$\" /S" + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" "InstallLocation" "$\"$INSTDIR$\"" + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" "DisplayIcon" "$\"$INSTDIR\mediawriter.ico$\"" + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" "Publisher" "${COMPANYNAME}" + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" "HelpLink" "${HELPURL}" + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" "URLUpdateInfo" "${UPDATEURL}" + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" "URLInfoAbout" "${ABOUTURL}" + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" "DisplayVersion" "${VERSIONMAJOR}.${VERSIONMINOR}.${VERSIONBUILD}" + WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" "VersionMajor" ${VERSIONMAJOR} + WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" "VersionMinor" ${VERSIONMINOR} + # There is no option for modifying or repairing the install + WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" "NoModify" 1 + WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" "NoRepair" 1 + # Set the INSTALLSIZE constant (!defined at the top of this script) so Add/Remove Programs can accurately report the size + WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" "EstimatedSize" ${INSTALLSIZE} +sectionEnd + +# Uninstaller +!ifdef INNER + function un.onInit + SetShellVarContext all + + #Verify the uninstaller - last chance to back out + MessageBox MB_OKCANCEL "Permanently remove ${APPNAME}?" IDOK next + Abort + next: + !insertmacro VerifyUserIsAdmin + functionEnd + + section "uninstall" + # Remove Start Menu launcher + delete "$SMPROGRAMS\${APPNAME}.lnk" + + # Remove files + delete $INSTDIR\* + + # Try to remove the install directory - this will only happen if it is empty + rmDir /r $INSTDIR + + # Remove uninstaller information from the registry + DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" + sectionEnd +!endif