3 # Fetch and extract Geany dependencies for Windows/MSYS2
4 # This script will download (or use Pacman's cache) to extract
5 # dependencies as defined below needed to run Geany.
6 # To be run within a MSYS2 shell. The extracted files will be
7 # placed into the current directory.
15 UNX_UTILS_URL
="http://unxutils.sourceforge.net/UnxUpdates.zip"
16 GREP_URL
="https://download.geany.org/contrib/grep-2.23.tar.xz"
19 gtk2_dependency_pkgs
=""
20 gtk3_dependency_pkgs
="
49 handle_command_line_options
() {
68 echo "gtk-bundle-from-msys2.sh [-c] [-h] [-n] [-z] [-2 | -3] [CACHEDIR]"
69 echo " -c Use pacman cache. Otherwise pacman will download"
71 echo " -h Show this help screen"
72 echo " -n Do not run post install scripts of the packages"
73 echo " -z Create a zip afterwards"
74 echo " -2 Prefer gtk2"
75 echo " -3 Prefer gtk3"
76 echo "CACHEDIR Directory where to look for cached packages (default: /var/cache/pacman/pkg)"
87 if [ -z "$cachedir" ]; then
88 cachedir
="/var/cache/pacman/pkg"
91 if [ "$use_cache" = "yes" ] && ! [ -d "$cachedir" ]; then
92 echo "Cache dir \"$cachedir\" not a directory"
97 eval "gtk_dependency_pkgs=\${${gtk}_dependency_pkgs}"
101 ${gtk_dependency_pkgs}
107 if [ "$use_cache" = "yes" ]; then
108 package_info
=`pacman -Qi mingw-w64-$ABI-$1`
109 package_version
=`echo "$package_info" | grep "^Version " | cut -d':' -f 2 | tr -d '[[:space:]]'`
110 ls $cachedir/mingw-w64-
${ABI}-${1}-${package_version}-* |
sort -V |
tail -n 1
112 pacman
-Sp mingw-w64-
${ABI}-${1}
116 _remember_package_source
() {
117 if [ "$use_cache" = "yes" ]; then
118 package_url
=`pacman -Sp mingw-w64-${ABI}-${2}`
122 package_urls
="${package_urls}\n${package_url}"
128 _remember_package_source
$pkg $i
129 if [ "$use_cache" = "yes" ]; then
130 if [ -e "$pkg" ]; then
131 echo "Extracting $pkg from cache"
134 echo "ERROR: File $pkg not found"
138 echo "Download $pkg using curl"
139 curl
-L "$pkg" |
tar -x --xz
141 if [ -n "$run_pi" ] && [ -f .INSTALL
]; then
142 echo "Running post_install script for \"$i\""
143 /bin
/bash
-c ". .INSTALL; post_install"
145 if [ "$make_zip" = "yes" -a "$i" = "$gtk" ]; then
146 VERSION
=$
(grep ^pkgver .PKGINFO |
sed -e 's,^pkgver = ,,' -e 's,-.*$,,')
148 rm -f .INSTALL .MTREE .PKGINFO .BUILDINFO
152 move_extracted_files
() {
153 echo "Move extracted data to destination directory"
154 if [ -d mingw32
]; then
155 for d
in bin etc home include lib locale share var
; do
156 if [ -d "mingw32/$d" ]; then
158 # prevent sporadic 'permission denied' errors on my system, not sure why they happen
167 cleanup_unnecessary_files
() {
168 echo "Cleanup unnecessary files"
169 # cleanup temporary files
170 rm -rf var
/cache
/fontconfig
173 # cleanup development and other unnecessary files
178 find lib
-name '*.a' -delete
179 find lib
-name '*.typelib' -delete
180 find lib
-name '*.def' -delete
181 find lib
-name '*.h' -delete
182 find lib
-name '*.sh' -delete
183 # cleanup other unnecessary files
185 rm -rf share
/applications
186 rm -rf share
/bash-completion
191 rm -rf share
/glib-2.0
198 # cleanup binaries and libs (delete anything except *.dll)
199 find bin
! -name '*.dll' -type f
-delete
200 # cleanup empty directories
201 find .
-type d
-empty -delete
204 download_and_compile_grep
() {
205 grep_archive
="grep_source.tar.xz"
206 grep_build_dir
="grep_build"
207 grep_build_log
="grep_build.log"
208 echo "Download and compile 'grep' (see ${grep_build_dir}/${grep_build_log} for details)"
209 mkdir
${grep_build_dir}
211 wget
--no-verbose -O ${grep_archive} ${GREP_URL}
212 tar xf
${grep_archive}
213 grep-2
*/configure
> ${grep_build_log} 2>&1 ||
exit 1
214 make >> ${grep_build_log} 2>&1 ||
exit 1
216 cp src
/grep.exe ..
/bin
/
218 rm -rf ${grep_build_dir}
221 download_and_extract_sort
() {
222 echo "Download and unpack 'sort'"
223 # add sort to the bin directory
224 unxutils_archive
="unxutilsupdates.zip"
225 wget
--no-verbose -O ${unxutils_archive} ${UNX_UTILS_URL}
226 unzip ${unxutils_archive} sort.exe
-d bin
/
227 rm ${unxutils_archive}
230 create_bundle_dependency_info_file
() {
231 filename
="ReadMe.Dependencies.Geany.txt"
232 cat << EOF > "${filename}"
233 This installation contains dependencies for Geany which are distributed
234 as binaries (usually .dll files) as well as additional files
235 necessary for these dependencies.
236 Following is a list of all included binary packages with their
237 full download URL as used to create this installation.
239 sort.exe is extracted from the ZIP archive at
242 grep.exe is self-compiled from the sources available at
244 Used command to compile: ./configure && make
246 Other dependencies are provided by the MSYS2 project
247 (https://msys2.github.io) and were downloaded from:
249 echo -e "${package_urls}" >> "${filename}"
250 unix2dos
"${filename}"
253 create_zip_archive
() {
254 if [ "$make_zip" = "yes" ]; then
255 if [ -z "$VERSION" ]; then
256 VERSION
="unknown-version"
258 echo "Packing the bundle"
259 zip -r gtk-
$VERSION.
zip bin etc include lib locale share var
265 handle_command_line_options $@
269 cleanup_unnecessary_files
270 download_and_compile_grep
271 download_and_extract_sort
272 create_bundle_dependency_info_file