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
="
50 handle_command_line_options
() {
69 echo "gtk-bundle-from-msys2.sh [-c] [-h] [-n] [-z] [-2 | -3] [CACHEDIR]"
70 echo " -c Use pacman cache. Otherwise pacman will download"
72 echo " -h Show this help screen"
73 echo " -n Do not run post install scripts of the packages"
74 echo " -z Create a zip afterwards"
75 echo " -2 Prefer gtk2"
76 echo " -3 Prefer gtk3"
77 echo "CACHEDIR Directory where to look for cached packages (default: /var/cache/pacman/pkg)"
88 if [ -z "$cachedir" ]; then
89 cachedir
="/var/cache/pacman/pkg"
92 if [ "$use_cache" = "yes" ] && ! [ -d "$cachedir" ]; then
93 echo "Cache dir \"$cachedir\" not a directory"
98 eval "gtk_dependency_pkgs=\${${gtk}_dependency_pkgs}"
102 ${gtk_dependency_pkgs}
108 if [ "$use_cache" = "yes" ]; then
109 package_info
=`pacman -Qi mingw-w64-$ABI-$1`
110 package_version
=`echo "$package_info" | grep "^Version " | cut -d':' -f 2 | tr -d '[[:space:]]'`
111 ls $cachedir/mingw-w64-
${ABI}-${1}-${package_version}-* |
sort -V |
tail -n 1
113 pacman
-Sp mingw-w64-
${ABI}-${1}
117 _remember_package_source
() {
118 if [ "$use_cache" = "yes" ]; then
119 package_url
=`pacman -Sp mingw-w64-${ABI}-${2}`
123 package_urls
="${package_urls}\n${package_url}"
129 _remember_package_source
$pkg $i
130 if [ "$use_cache" = "yes" ]; then
131 if [ -e "$pkg" ]; then
132 echo "Extracting $pkg from cache"
135 echo "ERROR: File $pkg not found"
139 echo "Download $pkg using curl"
140 curl
-L "$pkg" |
tar -x --xz
142 if [ -n "$run_pi" ] && [ -f .INSTALL
]; then
143 echo "Running post_install script for \"$i\""
144 /bin
/bash
-c ". .INSTALL; post_install"
146 if [ "$make_zip" = "yes" -a "$i" = "$gtk" ]; then
147 VERSION
=$
(grep ^pkgver .PKGINFO |
sed -e 's,^pkgver = ,,' -e 's,-.*$,,')
149 rm -f .INSTALL .MTREE .PKGINFO .BUILDINFO
153 move_extracted_files
() {
154 echo "Move extracted data to destination directory"
155 if [ -d mingw32
]; then
156 for d
in bin etc home include lib locale share var
; do
157 if [ -d "mingw32/$d" ]; then
159 # prevent sporadic 'permission denied' errors on my system, not sure why they happen
168 cleanup_unnecessary_files
() {
169 echo "Cleanup unnecessary files"
170 # cleanup temporary files
171 rm -rf var
/cache
/fontconfig
174 # cleanup development and other unnecessary files
179 find lib
-name '*.a' -delete
180 find lib
-name '*.typelib' -delete
181 find lib
-name '*.def' -delete
182 find lib
-name '*.h' -delete
183 find lib
-name '*.sh' -delete
184 # cleanup other unnecessary files
186 rm -rf share
/applications
187 rm -rf share
/bash-completion
192 rm -rf share
/glib-2.0
/codegen
193 rm -rf share
/glib-2.0
/gdb
194 rm -rf share
/glib-2.0
/gettext
195 rm -rf share
/graphite2
202 # cleanup binaries and libs (delete anything except *.dll)
203 find bin
! -name '*.dll' -type f
-delete
204 # cleanup empty directories
205 find .
-type d
-empty -delete
208 download_and_compile_grep
() {
209 grep_archive
="grep_source.tar.xz"
210 grep_build_dir
="grep_build"
211 grep_build_log
="grep_build.log"
212 echo "Download and compile 'grep' (see ${grep_build_dir}/${grep_build_log} for details)"
213 mkdir
${grep_build_dir}
215 wget
--no-verbose -O ${grep_archive} ${GREP_URL}
216 tar xf
${grep_archive}
217 grep-2
*/configure
> ${grep_build_log} 2>&1 ||
exit 1
218 make >> ${grep_build_log} 2>&1 ||
exit 1
220 cp src
/grep.exe ..
/bin
/
222 rm -rf ${grep_build_dir}
225 download_and_extract_sort
() {
226 echo "Download and unpack 'sort'"
227 # add sort to the bin directory
228 unxutils_archive
="unxutilsupdates.zip"
229 wget
--no-verbose -O ${unxutils_archive} ${UNX_UTILS_URL}
230 unzip ${unxutils_archive} sort.exe
-d bin
/
231 rm ${unxutils_archive}
234 create_bundle_dependency_info_file
() {
235 filename
="ReadMe.Dependencies.Geany.txt"
236 cat << EOF > "${filename}"
237 This installation contains dependencies for Geany which are distributed
238 as binaries (usually .dll files) as well as additional files
239 necessary for these dependencies.
240 Following is a list of all included binary packages with their
241 full download URL as used to create this installation.
243 sort.exe is extracted from the ZIP archive at
246 grep.exe is self-compiled from the sources available at
248 Used command to compile: ./configure && make
250 Other dependencies are provided by the MSYS2 project
251 (https://msys2.github.io) and were downloaded from:
253 echo -e "${package_urls}" >> "${filename}"
254 unix2dos
"${filename}"
257 create_zip_archive
() {
258 if [ "$make_zip" = "yes" ]; then
259 if [ -z "$VERSION" ]; then
260 VERSION
="unknown-version"
262 echo "Packing the bundle"
263 zip -r gtk-
$VERSION.
zip bin etc include lib locale share var
269 handle_command_line_options $@
273 cleanup_unnecessary_files
274 download_and_compile_grep
275 download_and_extract_sort
276 create_bundle_dependency_info_file