[gedit/wip/wininstaller] win32: add scripts to create the new QT based installer



commit 9bd2a5147a47815df2ecc24ae59b0b90a2eb409e
Author: Ignacio Casal Quinteiro <icq gnome org>
Date:   Mon Jul 28 15:38:44 2014 +0200

    win32: add scripts to create the new QT based installer

 configure.ac                                       |    1 -
 win32/build-installer.sh                           |  260 --------------------
 win32/gedit.iss.in                                 |   60 -----
 win32/make-gedit-installer                         |  139 +++++++++++
 win32/make-gedit-installer.bat                     |    9 +
 win32/qt-ifw/config/config.xml                     |   12 +
 .../meta/installscript.js                          |   31 +++
 .../org.gnome.gedit.root.package/meta/package.xml  |    9 +
 .../org.gnome.gedit.root/meta/installscript.js     |   13 +
 .../packages/org.gnome.gedit.root/meta/package.xml |    8 +
 win32/querymodules.bat                             |    3 -
 11 files changed, 221 insertions(+), 324 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 07230f6..2bd8bd0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -442,7 +442,6 @@ plugins/filebrowser/org.gnome.gedit.plugins.filebrowser.gschema.xml.in
 plugins/pythonconsole/org.gnome.gedit.plugins.pythonconsole.gschema.xml.in
 plugins/time/org.gnome.gedit.plugins.time.gschema.xml.in
 po/Makefile.in
-win32/gedit.iss
 osx/Info.plist])
 
 AC_OUTPUT
diff --git a/win32/make-gedit-installer b/win32/make-gedit-installer
new file mode 100644
index 0000000..42de15e
--- /dev/null
+++ b/win32/make-gedit-installer
@@ -0,0 +1,139 @@
+#!/usr/bin/env bash
+
+_thisdir="$(dirname $0)"
+test "${_thisdir}" = "." && _thisdir=${PWD}
+_ifwroot="${_thisdir}"/qt-ifw
+_arch=$(uname -m)
+_date=$(date +'%Y%m%d')
+_dateqif=$(date +'%Y-%m-%d')
+_version= VERSION@
+_filename=gedit-${_arch}-${_version}.exe
+_log=/tmp/installer.log
+if [ "${_arch}" = "x86_64" ]; then
+  _bitness=64
+else
+  _bitness=32
+fi
+
+declare -a undo_commands
+
+_exitcode=5
+
+if [ "$#" != "2" ]; then
+  usage
+fi
+
+_stage="$1"
+case "${_stage}" in
+  stage1 | stage2)
+    ;;
+  *)
+    usage
+    ;;
+esac
+
+usage() {
+  echo "Usage: $0 stage#"
+  exit 1
+}
+
+exit_with_undo() {
+  for _cmd in ${undo_commands[ ]}; do
+    eval "$_cmd"
+  done
+  exit ${_exitcode}
+}
+
+exit_cleanly() {
+  _exitcode=$1; shift;
+  local _message=$1; shift;
+  echo "${_message}"
+  exit_with_undo
+}
+
+do_seds() {
+  find "${_ifwroot}" \( -name "package.xml" -or -name "config.xml" \) -exec sed -i "s|@DATE@|${_dateqif}|g" 
"{}" \;
+  find "${_ifwroot}" \( -name "package.xml" -or -name "config.xml" \) -exec sed -i 
"s|@VERSION@|${_version}|g" "{}" \;
+  undo_commands+=("undo_seds")
+}
+
+undo_seds() {
+  find "${_ifwroot}" \( -name "package.xml" -or -name "config.xml" \) -exec sed -i 
"s|<ReleaseDate>${_dateqif}<|<ReleaseDate>@DATE@<|g" "{}" \;
+  find "${_ifwroot}" \( -name "package.xml" -or -name "config.xml" \) -exec sed -i 
"s|<Version>${_version}<|<Version>@VERSION@<|g" "{}" \;
+}
+
+# Add -v to get more information.
+make_installer() {
+  "${_binarycreator}" \
+    -t "${_installerbase}" \
+    -p "${_ifwroot}/packages" \
+    -c "${_ifwroot}/config/config.xml" \
+    --offline-only \
+    "${_filename}" \
+    -v
+}
+
+trap exit_with_undo 1 2 15
+
+_archivegen=/mingw${_bitness}/bin/archivegen.exe
+_binarycreator=/mingw${_bitness}/bin/binarycreator.exe
+_installerbase=/mingw${_bitness}/bin/installerbase.exe
+_newgeditbase=/tmp/newgedit
+_newgedit=${_newgeditbase}/msys"${_bitness}"
+
+create_chroot_system() {
+  [ -d ${_newgeditbase} ] && rm -rf ${_newgeditbase}
+  mkdir -p "${_newgedit}"
+  pushd "${_newgedit}" > /dev/null
+
+  mkdir -p var/lib/pacman
+  mkdir -p var/log
+  mkdir -p tmp
+
+  pacman -Syu --root "${_newgedit}"
+  pacman -S filesystem bash pacman --noconfirm --root "${_newgedit}"
+  _result=$?
+  if [ "$_result" -ne "0" ]; then
+    exit_cleanly "1" "failed to create base data via command 'pacman -S filesystem bash pacman --noconfirm 
--root ${_newgedit}'"
+  fi
+  popd > /dev/null
+}
+
+install_gedit_packages() {
+  if [ ! -d ${_newgeditbase} ]; then
+    echo "Run first the script with stage1 to create the base installation"
+    exit 1
+  fi
+
+  pushd "${_newgedit}" > /dev/null
+  pacman -S mingw-w64-${_arch}-librsvg mingw-w64-${_arch}-gedit mingw-w64-${_arch}-gedit-plugins 
mingw-w64-${_arch}-adwaita-icon-theme --noconfirm --root "${_newgedit}"
+  _result=$?
+  if [ "$_result" -ne "0" ]; then
+    exit_cleanly "1" "failed to create newgedit via command 'pacman -S gedit --noconfirm --root 
${_newgedit}'"
+  fi
+  popd > /dev/null
+}
+
+if [ ! -f "${_archivegen}" ]; then
+  eval "pacman -S --noconfirm mingw${_bitness}/mingw-w64-${_arch}-qt-installer-framework-git" | tee $_log 
2>&1
+fi
+
+if [ ! -f "${_archivegen}" ]; then
+  exit_cleanly "2" "installation of qt installer framework failed. See $_log"
+fi
+
+if [ "${_stage}" = "stage1" ]; then
+  echo "Creating gedit chroot system ${_newgedit}"
+  create_chroot_system
+  exit 0
+fi
+
+echo "Installing gedit packages into ${_newgedit}"
+install_gedit_packages
+
+echo "Creating gedit installer /tmp/$_filename"
+[ -f /tmp/$_filename ] && rm -f /tmp/$_filename
+
+do_seds
+make_installer
+exit_cleanly "0" "All done, see ${_filename}"
diff --git a/win32/make-gedit-installer.bat b/win32/make-gedit-installer.bat
new file mode 100644
index 0000000..98adca2
--- /dev/null
+++ b/win32/make-gedit-installer.bat
@@ -0,0 +1,9 @@
+C:/msys64/usr/bin/bash.exe -c "make-gedit-installer stage1"
+if errorlevel 1 (
+exit /b %errorlevel%
+)
+
+C:/msys64/tmp/gedit/usr/bin/bash.exe -c "make-gedit-installer stage2"
+if errorlevel 1 (
+exit /b %errorlevel%
+)
diff --git a/win32/qt-ifw/config/config.xml b/win32/qt-ifw/config/config.xml
new file mode 100644
index 0000000..ef4631a
--- /dev/null
+++ b/win32/qt-ifw/config/config.xml
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Installer>
+    <Name>gedit Text Editor</Name>
+    <Version>@VERSION@</Version>
+    <Title>gedit Text Editor</Title>
+    <Publisher>The gedit Developers</Publisher>
+    <StartMenuDir>gedit Text Editor</StartMenuDir>
+    <RunProgram>@TargetDir@/bin/gedit.exe</RunProgram>
+    <RunProgramArguments></RunProgramArguments>
+    <InstallerApplicationIcon>../../pixmaps</InstallerApplicationIcon>
+    <InstallerWindowIcon>../../pixmaps</InstallerWindowIcon>
+</Installer>
diff --git a/win32/qt-ifw/packages/org.gnome.gedit.root.package/meta/installscript.js 
b/win32/qt-ifw/packages/org.gnome.gedit.root.package/meta/installscript.js
new file mode 100644
index 0000000..4fe04bd
--- /dev/null
+++ b/win32/qt-ifw/packages/org.gnome.gedit.root.package/meta/installscript.js
@@ -0,0 +1,31 @@
+function Component()
+{
+    // constructor
+}
+
+Component.prototype.isDefault = function()
+{
+    // select the component by default
+    return true;
+}
+
+function createShortcuts()
+{
+    var windir = installer.environmentVariable("WINDIR");
+    if (windir === "") {
+        QMessageBox["warning"]( "Error" , "Error", "Could not find windows installation directory");
+        return;
+    }
+
+    var cmdLocation = windir + "\\system32\\cmd.exe";
+    component.addOperation( "CreateShortcut",
+                            cmdLocation,
+                            "@StartMenuDir@/gedit Text Editor",
+                            "/A /Q /K " + installer.value("TargetDir") + "\\bin\\gedit.exe");
+}
+
+Component.prototype.createOperations = function()
+{
+    component.createOperations();
+    createShortcuts();
+}
diff --git a/win32/qt-ifw/packages/org.gnome.gedit.root.package/meta/package.xml 
b/win32/qt-ifw/packages/org.gnome.gedit.root.package/meta/package.xml
new file mode 100644
index 0000000..7c68e4e
--- /dev/null
+++ b/win32/qt-ifw/packages/org.gnome.gedit.root.package/meta/package.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0"?>
+<Package>
+  <DisplayName>gedit Text Editor package</DisplayName>
+  <Description>gedit is the official text editor of the GNOME desktop environment</Description>
+  <Version>@VERSION@</Version>
+  <ReleaseDate>@DATE@</ReleaseDate>
+  <Default>true</Default>
+  <Script>installscript.js</Script>
+</Package>
diff --git a/win32/qt-ifw/packages/org.gnome.gedit.root/meta/installscript.js 
b/win32/qt-ifw/packages/org.gnome.gedit.root/meta/installscript.js
new file mode 100644
index 0000000..e26bb5d
--- /dev/null
+++ b/win32/qt-ifw/packages/org.gnome.gedit.root/meta/installscript.js
@@ -0,0 +1,13 @@
+function Component() {
+    var systemDrive = installer.environmentVariable("SystemDrive");
+    // Use C: as a default for messed up systems.
+    if (systemDrive === "") {
+        systemDrive = "C:";
+    }
+    installer.setDefaultPageVisible(QInstaller.Introduction, false);
+    installer.setDefaultPageVisible(QInstaller.TargetDirectory, true);
+    installer.setDefaultPageVisible(QInstaller.ComponentSelection, false);
+    installer.setDefaultPageVisible(QInstaller.ReadyForInstallation, false);
+    installer.setDefaultPageVisible(QInstaller.StartMenuSelection, true);
+    installer.setDefaultPageVisible(QInstaller.LicenseCheck, false);
+}
diff --git a/win32/qt-ifw/packages/org.gnome.gedit.root/meta/package.xml 
b/win32/qt-ifw/packages/org.gnome.gedit.root/meta/package.xml
new file mode 100644
index 0000000..7a90be9
--- /dev/null
+++ b/win32/qt-ifw/packages/org.gnome.gedit.root/meta/package.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0"?>
+<Package>
+  <DisplayName>gedit Text Editor</DisplayName>
+  <Description>gedit is the official text editor of the GNOME desktop environment</Description>
+  <Version>@VERSION@</Version>
+  <ReleaseDate>@DATE@</ReleaseDate>
+  <Script>installscript.js</Script>
+</Package>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]