commit efaefb1b4b79d9f4e2281ea7062c0a43630a3d29 Author: Alexpux Date: Tue Jul 1 15:44:59 2014 +0400 Create msys2-installer folder for installer scripts. diff --git a/compress-msys2 b/compress-msys2 new file mode 100644 index 0000000..e43ac26 --- /dev/null +++ b/compress-msys2 @@ -0,0 +1,32 @@ +#!/usr/bin/env bash + +_arch=$(uname -m) +_date=$(date +'%Y%m%d') +_filename=${_arch}-msys2-${_date}.tar.xz +_log=/tmp/compress.log + +echo "Creating MSYS2 archive /tmp/$_filename" +if [ -f /tmp/$_filename ]; then + rm -f /tmp/$_filename +fi + +_dirs= +for curr_dir in /etc /include /lib /libexec /sbin /share /ssl /tmp /usr /var /mingw32_shell.bat /mingw64_shell.bat /msys2.ico /msys2_shell.bat ; do + if [[ -d $curr_dir || -f $curr_dir ]]; then + _dirs="$_dirs $curr_dir" + fi +done + +if [ -n "$_dirs" ]; then + _compress_cmd="/usr/bin/tar --transform='s/:/_/g' --dereference --hard-dereference -cvJf /tmp/${_filename} $_dirs -X /etc/compress_exclude" + cd / + eval ${_compress_cmd} | tee $_log 2>&1 + _result=$? + if [ "$_result" -eq "0" ]; then + echo " done" + else + die "MSYS2 compressing fail. See $_log" + fi +fi + +exit 0 diff --git a/compress_exclude b/compress_exclude new file mode 100644 index 0000000..9d88e8c --- /dev/null +++ b/compress_exclude @@ -0,0 +1,13 @@ +/etc/postinstall/postinstall.marker +/etc/group +/etc/passwd +/etc/mtab +/etc/fstab +/etc/hosts +/etc/networks +/etc/protocols +/etc/services +/home/* +/dev/* +/tmp/* +/var/tmp/* diff --git a/make-msys2-installer b/make-msys2-installer new file mode 100644 index 0000000..0a29da3 --- /dev/null +++ b/make-msys2-installer @@ -0,0 +1,140 @@ +#!/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=${_date} +_filename=msys2-${_arch}-${_date}.exe +_filename2=msys2-base-${_arch}-${_date}.tar.xz +_log=/tmp/installer.log +if [ "${_arch}" = "x86_64" ]; then + _bitness=64 +else + _bitness=32 +fi + +declare -a undo_commands + +_exitcode=5 + +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" "{}" \; + find "${_ifwroot}" \( -name "package.xml" -or -name "config.xml" -or -name "installscript.js" \) -exec sed -i "s|@BITNESS@|${_bitness}|g" "{}" \; + undo_commands+=("undo_seds") +} + +undo_seds() { + find "${_ifwroot}" \( -name "package.xml" -or -name "config.xml" \) -exec sed -i "s|${_dateqif}<|@DATE@<|g" "{}" \; + find "${_ifwroot}" \( -name "package.xml" -or -name "config.xml" \) -exec sed -i "s|${_version}<|@VERSION@<|g" "{}" \; + find "${_ifwroot}" \( -name "package.xml" -or -name "config.xml" -or -name "installscript.js" \) -exec sed -i "s|msys${_bitness}|msys@BITNESS@|g" "{}" \; + find "${_ifwroot}" \( -name "package.xml" -or -name "config.xml" -or -name "installscript.js" \) -exec sed -i "s|${_bitness}bit|@BITNESS@bit|g" "{}" \; +} + +create_archives() { + local _data="${_ifwroot}"/packages/com.msys2.root.base/data + [ -d "${_data}" ] && rm -rf "${_data}" + mkdir -p "${_data}" + _dirs= + for curr_dir in /etc /var /tmp /usr /mingw32_shell.bat /mingw64_shell.bat /msys2_shell.bat /msys2.ico /autorebase.bat autorebasebase1st.bat; do + if [[ -d ${_newmsys}$curr_dir || -f ${_newmsys}$curr_dir ]]; then + _dirs="${_dirs} ${_newmsys}$curr_dir" + fi + done + if [ -n "$_dirs" ]; then + _compress_cmd="${_archivegen} ${_data}/msys${_bitness}.7z ${_dirs}" + pushd / > /dev/null + eval ${_compress_cmd} | tee $_log 2>&1 + _result=$? + if [ "$_result" -eq "0" ]; then + echo " archivegen succeeded. Created ${_data}/msys${_bitness}.7z" + else + exit_cleanly "3" "archivegen failed. See $_log" + fi + popd > /dev/null + + pushd ${_newmsysbase} + _compress_cmd2="/usr/bin/tar --transform='s/:/_/g' --dereference --hard-dereference -cJf ${_thisdir}/${_filename2} msys${_bitness}" + eval ${_compress_cmd2} | tee $_log 2>&1 + _result=$? + if [ "$_result" -eq "0" ]; then + echo " tar succeeded. Created " + else + die "MSYS2 compressing fail. See $_log" + fi + popd > /dev/null + fi +} + +# 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 +_newmsysbase=/tmp/newmsys +_newmsys=${_newmsysbase}/msys"${_bitness}" + +create_chroot_system() { + [ -d ${_newmsysbase} ] && rm -rf ${_newmsysbase} + mkdir -p "${_newmsys}" + pushd "${_newmsys}" > /dev/null + + mkdir -p var/lib/pacman + mkdir -p var/log + mkdir -p tmp + + pacman -Syu --rootrebase "${_newmsys}" + pacman -S base --noconfirm --rootrebase "${_newmsys}" + _result=$? + if [ "$_result" -ne "0" ]; then + exit_cleanly "1" "failed to create newmsys2 via command 'pacman -S base --noconfirm --root ${_newmsys}'" + 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 + +echo "Creating MSYS2 chroot system ${_newmsys}" +create_chroot_system + +echo "Creating MSYS2 installer /tmp/$_filename" +[ -f /tmp/$_filename ] && rm -f /tmp/$_filename + +do_seds +create_archives +make_installer +exit_cleanly "0" "All done, see ${_filename}" diff --git a/make-msys2-installer.bat b/make-msys2-installer.bat new file mode 100644 index 0000000..66b00c5 --- /dev/null +++ b/make-msys2-installer.bat @@ -0,0 +1,52 @@ +@echo off + +REM Copyright (c) 2014, Ray Donnelly + +if "%1"=="" ( + echo Please re-run, passing the the location of an existing MSYS2 installation + exit /b 1 +) + +if not exist %1\msys2_shell.bat ( + echo '%1' does not seem to be the root folder of an existing MSYS2 installation?! + exit /b 2 +) + +set "NEWMSYS=%CD:\=/%/newmsys/msys64" +set "NEWMSYSW=%CD%\newmsys\msys64" + +echo. +echo *********** +echo * Warning * +echo *********** +echo. +echo This batch file will sync (forcibly) the 'base' group of the MSYS2 installation in '%1' + NUL +popd + +echo Creating new MSYS2 installation containing only 'base' +timeout 1 > NUL +pushd %1 + mkdir %NEWMSYSW%\var\lib\pacman + echo bin\bash -l -c "pacman -Syu --root %NEWMSYS%" + bin\bash -l -c "pacman -Syu --root %NEWMSYS%" + exit /b 999 + %1\bin\bash -l -c "pacman -S pacman --rootrebase %NEWMSYS%" + %1\bin\bash -l -c "pacman -S base --force --rootrebase %NEWMSYS%" | more /E /P + timeout 1 > NUL +popd + +exit /b 0 diff --git a/qt-ifw/config/config.xml b/qt-ifw/config/config.xml new file mode 100644 index 0000000..6de953a --- /dev/null +++ b/qt-ifw/config/config.xml @@ -0,0 +1,12 @@ + + + MSYS2 @BITNESS@bit + @VERSION@ + MSYS2 @BITNESS@bit + The MSYS2 Developers + MSYS2 @BITNESS@bit + @TargetDir@/msys2_shell.bat + + ../../msys2 + ../../msys2 + diff --git a/qt-ifw/packages/com.msys2.root.base/meta/installscript.js b/qt-ifw/packages/com.msys2.root.base/meta/installscript.js new file mode 100644 index 0000000..40542a7 --- /dev/null +++ b/qt-ifw/packages/com.msys2.root.base/meta/installscript.js @@ -0,0 +1,44 @@ +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@/MSYS2 Shell.lnk", + "/A /Q /K " + installer.value("TargetDir") + "\\msys2_shell.bat"); + + component.addOperation( "CreateShortcut", + cmdLocation, + "@StartMenuDir@/MinGW-w64 Win32 Shell.lnk", + "/A /Q /K " + installer.value("TargetDir") + "\\mingw32_shell.bat"); + + component.addOperation( "CreateShortcut", + cmdLocation, + "@StartMenuDir@/MinGW-w64 Win64 Shell.lnk", + "/A /Q /K " + installer.value("TargetDir") + "\\mingw64_shell.bat"); + + component.addOperation( "Execute", + ["@TargetDir@\\usr\\bin\\bash.exe", "--login", "-c", "exit"]); +} + +Component.prototype.createOperations = function() +{ + component.createOperations(); + createShortcuts(); +} diff --git a/qt-ifw/packages/com.msys2.root.base/meta/package.xml b/qt-ifw/packages/com.msys2.root.base/meta/package.xml new file mode 100644 index 0000000..4295da8 --- /dev/null +++ b/qt-ifw/packages/com.msys2.root.base/meta/package.xml @@ -0,0 +1,9 @@ + + + MSYS2 @BITNESS@bit base + Cygwin-derived Posix-like env. for Windows with Arch Linux's Pacman + @VERSION@ + @DATE@ + true + + diff --git a/qt-ifw/packages/com.msys2.root/meta/installscript.js b/qt-ifw/packages/com.msys2.root/meta/installscript.js new file mode 100644 index 0000000..a0c1968 --- /dev/null +++ b/qt-ifw/packages/com.msys2.root/meta/installscript.js @@ -0,0 +1,14 @@ +function Component() { + var systemDrive = installer.environmentVariable("SystemDrive"); + // Use C: as a default for messed up systems. + if (systemDrive === "") { + systemDrive = "C:"; + } + installer.setValue("TargetDir", systemDrive+"\\msys@BITNESS@"); + 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/qt-ifw/packages/com.msys2.root/meta/package.xml b/qt-ifw/packages/com.msys2.root/meta/package.xml new file mode 100644 index 0000000..942691f --- /dev/null +++ b/qt-ifw/packages/com.msys2.root/meta/package.xml @@ -0,0 +1,8 @@ + + + MSYS2 @BITNESS@bit + Cygwin-derived Posix-like env. for Windows with Arch Linux's Pacman + @VERSION@ + @DATE@ + +