This repository was archived by the owner on Oct 15, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathpackage.sh
executable file
·87 lines (69 loc) · 2.92 KB
/
package.sh
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
#!/bin/sh
# Clean working directories
rm -rf lib include
mkdir lib include
# Use pkg-config to automagically find and copy necessary header files
for path in $(pkg-config --cflags --static vips-cpp | tr ' ' '\n' | grep '^-I' | cut -c 3- | sort | uniq); do
cp -R ${path}/ include;
done;
rm include/gettext-po.h
# Manually copy header files for giflib
cp $(brew --prefix giflib)/include/*.h include
# Pack only the relevant shared libraries
# and modify all dylib file dependencies to use relative paths
function copydeps {
local file=$1
local dest_dir=$2
local base=$(basename $file)
for dep in $(otool -LX $file | awk '{print $1}' | grep '/usr/local'); do
base_dep=$(basename $dep)
echo "$base depends on $base_dep"
cp -Ln $dep $dest_dir/$base_dep
chmod 644 $dest_dir/$base_dep
install_name_tool -id @rpath/$base_dep $dest_dir/$base_dep
if [ $base != $base_dep ]; then
install_name_tool -change $dep @rpath/$base_dep $dest_dir/$base
# Call this function (recursive) on each dependency of this library
copydeps $dest_dir/$base_dep $dest_dir
fi
done;
}
copydeps $(brew --prefix vips)/lib/libvips-cpp.42.dylib lib
# Fix file permissions
chmod 644 include/*.h
chmod 644 lib/*.dylib
# Generate versions.json
printf "{\n\
\"cairo\": \"$(pkg-config --modversion cairo)\",\n\
\"exif\": \"$(pkg-config --modversion libexif)\",\n\
\"fontconfig\": \"$(pkg-config --modversion fontconfig)\",\n\
\"freetype\": \"$(pkg-config --modversion freetype2)\",\n\
\"fribidi\": \"$(pkg-config --modversion fribidi)\",\n\
\"gdkpixbuf\": \"$(pkg-config --modversion gdk-pixbuf-2.0)\",\n\
\"gif\": \"$(grep GIFLIB_ include/gif_lib.h | cut -d' ' -f3 | paste -s -d'.' -)\",\n\
\"glib\": \"$(pkg-config --modversion glib-2.0)\",\n\
\"gsf\": \"$(pkg-config --modversion libgsf-1)\",\n\
\"harfbuzz\": \"$(pkg-config --modversion harfbuzz)\",\n\
\"jpeg\": \"$(pkg-config --modversion libjpeg)\",\n\
\"lcms\": \"$(pkg-config --modversion lcms2)\",\n\
\"orc\": \"$(pkg-config --modversion orc-0.4)\",\n\
\"pango\": \"$(pkg-config --modversion pango)\",\n\
\"pixman\": \"$(pkg-config --modversion pixman-1)\",\n\
\"png\": \"$(pkg-config --modversion libpng)\",\n\
\"svg\": \"$(pkg-config --modversion librsvg-2.0)\",\n\
\"tiff\": \"$(pkg-config --modversion libtiff-4)\",\n\
\"vips\": \"$(pkg-config --modversion vips-cpp)\",\n\
\"webp\": \"$(pkg-config --modversion libwebp)\",\n\
\"xml\": \"$(pkg-config --modversion libxml-2.0)\"\n\
}" >versions.json
printf "\"darwin-x64\"" >platform.json
# Add third-party notices
curl -Os https://raw.githubusercontent.com/lovell/sharp-libvips/master/THIRD-PARTY-NOTICES.md
# Generate tarball
TARBALL=libvips-$(pkg-config --modversion vips-cpp)-darwin-x64.tar.gz
tar cfz "${TARBALL}" include lib *.json THIRD-PARTY-NOTICES.md
advdef --recompress --shrink-insane "${TARBALL}"
# Remove working directories
rm -rf lib include *.json *.md
# Display checksum
shasum *.tar.gz