1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178
|
#!/usr/bin/env bash
_wixdir="/c/Program Files (x86)/WiX Toolset v3.8"
_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/python2*
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() {
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
# some packages are pulled by the deps but we do not need them like python2
pacman -Rdd mingw-w64-${_arch}-python2 --noconfirm --root "${_newgitg}"
pacman -Rdd mingw-w64-${_arch}-gtk2 --noconfirm --root "${_newgitg}"
}
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}"
|