midori/win32/makedist/makedist.midori

220 lines
5.1 KiB
Text
Raw Normal View History

#! /bin/sh
# Copyright (C) 2010-2011 Peter de Ridder <peter@xfce.org>
# Copyright (C) 2012 Paweł Forysiuk <tuxator@o2.pl>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# See the file COPYING for the full license text.
# script: makedist.midori [version tag]
#
# This script creates an archive containing all required files for
# midori on windows. The midori version is inserted in the name of
# the archive and appended to the name of the root directory in the
# archive.
# The name of the archive is contructed as follows:
# midori<version tag>-<timestamp>.extension
# The archive contains a root directory named:
# midori<version tag>
# a bit of configuration
root_dir=$MINGW_PREFIX
if [ "$MINGW_PREFIX" == "" ]; then
echo "Warning! MINGW_PREFIX variable is empty!"
sleep 5s
fi
# create temporary working directory
temp_dir=`mktemp -d`
# check if we can use 7zip
have_7zip=`which 7za`
if [ "$1" != "" ]; then
if [ "$1" == "debug" ]; then
DEBUG_BUILD=1
else
version_tag=$1
fi
fi
# generate unique filename
if [ "$have_7zip" != "" ]; then
ARCHIVE=midori$version_tag-`date +%Y%m%d%H%M`.7z
else
ARCHIVE=midori$version_tag-`date +%Y%m%d%H%M`.zip
fi
# function: dll-recursive <list of exe and dll files ...>
#
# recursively search all dll dependencies of the input files.
# The resulting list of dll files including the input files is
# printed to stdout.
dll_recursive ()
{
temp_file_new=`mktemp`
temp_file_old=`mktemp`
while [ "$1" ]
do
echo $1 >> $temp_file_new
shift
done
while [ "x`sha1sum - < $temp_file_new`" != "x`sha1sum - < $temp_file_old`" ]
do
files=`cat $temp_file_new $temp_file_old | sort | uniq -u`
cp -L $temp_file_new $temp_file_old
strings $files 2> /dev/null | grep \\.dll | cat - $temp_file_old | sort | uniq > $temp_file_new
done
cat $temp_file_new
rm $temp_file_new $temp_file_old
}
grab_files ()
{
local dir="$1"
pushd $root_dir > /dev/null
shift
while [ "$1" ]; do
find $dir "(" -name "$1" ")" -prune -exec mkdir -p $workdir/{} ";" -exec rmdir --ignore-fail-on-non-empty $workdir/{} ";" -exec cp -Lr {} $workdir/{} ";"
shift
done
popd > /dev/null
}
echo -n "Creating $ARCHIVE ."
# create destination folder
workdir=$temp_dir/midori$version_tag
mkdir $workdir
echo -n .
# auto generate dll list, only of existing files
pushd $root_dir/bin > /dev/null
dll_recursive midori*.exe gspawn-*-helper*.exe libhunspell*.dll > $temp_dir/midori.exe.lst
dll_recursive ../lib/gio/modules/*.dll >> $temp_dir/midori.exe.lst
dll_recursive iconv.dll >> $temp_dir/midori.exe.lst
dll_recursive ../lib/gstreamer-0.10/*.dll >> $temp_dir/midori.exe.lst
if [ "$DEBUG_BUILD" != "" ]; then
dll_recursive gdb.exe GtkLauncher.exe >> $temp_dir/midori.exe.lst
fi
files=`ls | cat - $temp_dir/midori.exe.lst | sort | uniq -d`
rm $temp_dir/midori.exe.lst
popd > /dev/null
echo -n .
# copy auto generate dll list
pushd $root_dir/bin > /dev/null
mkdir $workdir/bin
cp -L $files $workdir/bin
popd > /dev/null
echo -n .
# copy etc
grab_files etc midori
grab_files etc gtkrc
# If modules are not compiled we need a list of them
grab_files etc pango
# Freetype is preferred font backend
# copy configuration, otherwise webkit will crash
grab_files etc fonts
echo -n .
# copy lib
grab_files lib midori
grab_files lib gtk-2.0
grab_files lib/engines "*"
grab_files lib gdk-pixbuf-2.0
grab_files lib enchant
grab_files lib gio
# Fedora ships on-demand pango modules, check just in case
grab_files lib pango
grab_files lib gstreamer-0.10
echo -n .
# copy share
grab_files share midori
grab_files share icons
grab_files share MS-Windows
grab_files share mime
grab_files share midori.mo
grab_files share webkitgtk-1.0
if [ "$DEBUG_BUILD" == "" ];then
pushd $workdir > /dev/null
find -iname *.debug -exec rm {} \;
popd > /dev/null
fi
# copy locales for gtk
# so we have translated stock items, file dialogs
pushd $root_dir > /dev/null
find share "(" -name "midori.mo" ")" > $temp_dir/locale.list
mkdir -p $workdir/share/locale/
for LOCALE in $(cat $temp_dir/locale.list); do
LOCALE=$(echo $LOCALE|awk -F/ '{print $3}')
cp /usr/share/locale/$LOCALE/LC_MESSAGES/gtk20.mo $workdir/share/locale/$LOCALE/LC_MESSAGES/
done
rm $temp_dir/locale.list
# Use small icons and tango icons
gtk_etc_dir="$workdir/etc/gtk-2.0/"
mkdir -p $gtk_etc_dir
cat > $gtk_etc_dir/gtkrc << _EOF
gtk-theme-name = "MS-Windows"
gtk-fallback-icon-theme = "Tango"
gtk-toolbar-style = GTK_TOOLBAR_ICONS
_EOF
popd > /dev/null
echo -n .
# copy doc files to root
cp -L $workdir/share/doc/midori/{COPYING,AUTHORS} $workdir
echo -n .
#drop a/la files, we don't do static builds anyway
find $workdir -iname *.*a -exec rm {} \;
ARCHIVE=`pwd`/$ARCHIVE
# store as zip/7z file
pushd $temp_dir > /dev/null
if [ "$have_7zip" != "" ]; then
7za a -m0=lzma $ARCHIVE midori$version_tag
else
zip -rq $ARCHIVE midori$version_tag
fi
popd > /dev/null
echo -n .
# remove working directory
rm -r $temp_dir
echo " ready"