mirror of
https://gitlab.gnome.org/GNOME/gitg
synced 2024-11-04 23:34:39 +00:00
175 lines
5.1 KiB
Bash
175 lines
5.1 KiB
Bash
#!/usr/bin/env bash
|
|
|
|
_wixdir="/c/Program Files (x86)/WiX Toolset v3.11"
|
|
_thisdir="$(dirname $0)"
|
|
test "${_thisdir}" = "." && _thisdir=${PWD}
|
|
_installer_root="${_thisdir}"/installer
|
|
_arch=$(uname -m)
|
|
_date=$(date +'%Y%m%d')
|
|
_dateqif=$(date +'%Y-%m-%d')
|
|
_version=@VERSION@
|
|
_filename=gitg-${_arch}-${_version}.msi
|
|
_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 "${_installer_root}" \( -name "defines.wxi" \) -exec sed -i "s|@VERSION@|${_version}|g" "{}" \;
|
|
undo_commands+=("undo_seds")
|
|
}
|
|
|
|
undo_seds() {
|
|
find "${_installer_root}" \( -name "defines.wxi" \) -exec sed -i "s|ProductVersion = \"${_version}\"|ProductVersion = \"@VERSION@\"|g" "{}" \;
|
|
}
|
|
|
|
_newgitg=/tmp/gitg
|
|
|
|
remove_useless_stuff() {
|
|
# remove .a files not needed for the installer
|
|
find installer/SourceDir -name "*.a" -exec rm -f {} \;
|
|
# remove unneeded binaries
|
|
find installer/SourceDir -not -name "g*.exe" -name "*.exe" -exec rm -f {} \;
|
|
rm -rf installer/SourceDir/bin/gtk3-demo*.exe
|
|
rm -rf installer/SourceDir/bin/gdbm*.exe
|
|
rm -rf installer/SourceDir/bin/py*
|
|
rm -rf installer/SourceDir/bin/*-config
|
|
# remove other useless folders
|
|
rm -rf installer/SourceDir/var
|
|
rm -rf installer/SourceDir/ssl
|
|
rm -rf installer/SourceDir/include
|
|
rm -rf installer/SourceDir/share/man
|
|
rm -rf installer/SourceDir/share/readline
|
|
rm -rf installer/SourceDir/share/info
|
|
rm -rf installer/SourceDir/share/aclocal
|
|
rm -rf installer/SourceDir/share/gnome-common
|
|
rm -rf installer/SourceDir/share/glade
|
|
rm -rf installer/SourceDir/share/gettext
|
|
rm -rf installer/SourceDir/share/terminfo
|
|
rm -rf installer/SourceDir/share/tabset
|
|
rm -rf installer/SourceDir/share/pkgconfig
|
|
rm -rf installer/SourceDir/share/bash-completion
|
|
rm -rf installer/SourceDir/share/appdata
|
|
rm -rf installer/SourceDir/share/gdb
|
|
# on windows we show the online help
|
|
rm -rf installer/SourceDir/share/help
|
|
rm -rf installer/SourceDir/share/gtk-doc
|
|
rm -rf installer/SourceDir/share/doc
|
|
# remove on the lib folder
|
|
rm -rf installer/SourceDir/lib/terminfo
|
|
rm -rf installer/SourceDir/lib/python*
|
|
rm -rf installer/SourceDir/lib/pkgconfig
|
|
rm -rf installer/SourceDir/lib/peas-demo
|
|
|
|
# strip the binaries to reduce the size
|
|
find installer/SourceDir -name *.dll | xargs strip
|
|
find installer/SourceDir -name *.exe | xargs strip
|
|
|
|
# remove some translation which seem to add a lot of size
|
|
find installer/SourceDir/share/locale/ -type f | grep -v atk10.mo | grep -v libpeas.mo | grep -v gsettings-desktop-schemas.mo | grep -v json-glib-1.0.mo | grep -v glib20.mo | grep -v gitg.mo | grep -v gdk-pixbuf.mo | grep -v gtk30.mo | grep -v gtk30-properties.mo | grep -v gtksourceview-3.0.mo | grep -v iso_*.mo | xargs rm
|
|
find installer/SourceDir/share/locale -type d | xargs rmdir -p --ignore-fail-on-non-empty
|
|
}
|
|
|
|
setup_source_dir() {
|
|
[ -d "installer/SourceDir" ] && rm -rf "installer/SourceDir"
|
|
cp -R "${_newgitg}/mingw${_bitness}" "installer/SourceDir"
|
|
remove_useless_stuff
|
|
}
|
|
|
|
# Add -v to get more information.
|
|
make_installer() {
|
|
setup_source_dir
|
|
|
|
_platform="x86"
|
|
if [ "${_arch}" = "x86_64" ]; then
|
|
_platform="x64"
|
|
fi
|
|
|
|
pushd "installer" > /dev/null
|
|
"${_wixdir}/bin/heat.exe" dir SourceDir -gg -dr INSTALLDIR -cg binaries -sfrag -sreg -srd -suid -template fragment -out binaries.wxs
|
|
"${_wixdir}/bin/candle.exe" -arch ${_platform} gitg.wxs binaries.wxs
|
|
"${_wixdir}/bin/light.exe" -ext WixUtilExtension -ext WixUIExtension gitg.wixobj binaries.wixobj -o "/tmp/${_filename}"
|
|
popd
|
|
}
|
|
|
|
trap exit_with_undo 1 2 15
|
|
|
|
create_chroot_system() {
|
|
[ -d ${_newgitg} ] && rm -rf ${_newgitg}
|
|
mkdir -p "${_newgitg}"
|
|
pushd "${_newgitg}" > /dev/null
|
|
|
|
mkdir -p var/lib/pacman
|
|
mkdir -p var/log
|
|
mkdir -p tmp
|
|
|
|
pacman -Syu --root "${_newgitg}"
|
|
pacman -S filesystem bash pacman --noconfirm --root "${_newgitg}"
|
|
_result=$?
|
|
if [ "$_result" -ne "0" ]; then
|
|
exit_cleanly "1" "failed to create base data via command 'pacman -S filesystem bash pacman --noconfirm --root ${_newgitg}'"
|
|
fi
|
|
popd > /dev/null
|
|
}
|
|
|
|
install_gitg_packages() {
|
|
pacman -S mingw-w64-${_arch}-librsvg mingw-w64-${_arch}-gitg mingw-w64-${_arch}-libgee mingw-w64-${_arch}-adwaita-icon-theme --noconfirm --root "${_newgitg}"
|
|
_result=$?
|
|
if [ "$_result" -ne "0" ]; then
|
|
exit_cleanly "1" "failed to create ${_newgitg} via command 'pacman -S gitg --noconfirm --root ${_newgitg}'"
|
|
fi
|
|
}
|
|
|
|
if [ "${_stage}" = "stage1" ]; then
|
|
echo "Creating gitg chroot system ${_newgitg}"
|
|
create_chroot_system
|
|
exit 0
|
|
fi
|
|
|
|
echo "Installing gitg packages into ${_newgitg}"
|
|
install_gitg_packages
|
|
|
|
echo "Creating gitg installer /tmp/$_filename"
|
|
[ -f /tmp/$_filename ] && rm -f /tmp/$_filename
|
|
|
|
do_seds
|
|
make_installer
|
|
exit_cleanly "0" "All done, see ${_filename}"
|