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



commit cbde6afce8687d91b2832d2c8ae2b619fa56079c
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                         |  158 ++++++++++++
 win32/make-gedit-installer.bat                     |    9 +
 win32/qt-ifw/config/config.xml                     |   14 +
 .../meta/installscript.js                          |   31 +++
 .../org.gnome.gedit.root.package/meta/package.xml  |    9 +
 .../org.gnome.gedit.root/meta/installscript.js     |    9 +
 .../packages/org.gnome.gedit.root/meta/package.xml |    8 +
 win32/querymodules.bat                             |    3 -
 11 files changed, 238 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..398fbb2
--- /dev/null
+++ b/win32/make-gedit-installer
@@ -0,0 +1,158 @@
+#!/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
+
+usage() {
+  echo "Usage: $0 stage#"
+  exit 1
+}
+
+if [ "$#" != "1" ]; then
+  usage
+fi
+
+_stage="$1"
+case "${_stage}" in
+  stage1 | stage2)
+    ;;
+  *)
+    usage
+    ;;
+esac
+
+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
+_newgedit=/tmp/gedit
+
+create_archive() {
+  local _data="${_ifwroot}"/packages/org.gnome.gedit.root.package/data
+  [ -d "${_data}" ] && rm -rf "${_data}"
+
+  mkdir -p "${_data}"
+  _dirs=
+  for curr_dir in /bin /etc /share; do
+    if [[ -d ${_newgedit}/mingw${_bitness}/$curr_dir || -f ${_newgedit}/mingw${_bitness}/$curr_dir ]]; then
+      _dirs="${_dirs} ${_newgedit}/mingw${_bitness}/$curr_dir"
+    fi
+  done
+
+  if [ -n "$_dirs" ]; then
+    _compress_cmd="${_archivegen} ${_data}/gedit.7z ${_dirs}"
+    pushd / > /dev/null
+    eval ${_compress_cmd} | tee $_log 2>&1
+    _result=$?
+    if [ "$_result" -eq "0" ]; then
+          echo " archivegen succeeded. Created ${_data}/gedit.7z"
+    else
+          exit_cleanly "3" "archivegen failed. See $_log"
+    fi
+    popd > /dev/null
+  fi
+}
+
+create_chroot_system() {
+  [ -d ${_newgedit} ] && rm -rf ${_newgedit}
+  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() {
+  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
+}
+
+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
+create_archive
+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..8638058
--- /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/newgedit/msys64/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..4de4cf4
--- /dev/null
+++ b/win32/qt-ifw/config/config.xml
@@ -0,0 +1,14 @@
+<?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>
+    <ProductUrl>http://www.gedit.org</ProductUrl>
+    <Logo>../../../pixmaps/gedit-logo.png</Logo>
+    <StartMenuDir>gedit Text Editor</StartMenuDir>
+    <RunProgram>@TargetDir@/bin/gedit.exe</RunProgram>
+    <RunProgramArguments></RunProgramArguments>
+    <InstallerApplicationIcon>../../../pixmaps/gedit.ico</InstallerApplicationIcon>
+    <InstallerWindowIcon>../../../pixmaps/gedit.ico</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..d7d59ba
--- /dev/null
+++ b/win32/qt-ifw/packages/org.gnome.gedit.root/meta/installscript.js
@@ -0,0 +1,9 @@
+function Component() {
+    installer.setValue("TargetDir", installer.value("ApplicationsDir") + "\\gedit");
+    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]