1 | #!/bin/sh |
---|
2 | |
---|
3 | # Copyright 2008, 2009, 2010, 2011, 2012, 2013, 2015, 2016 Patrick J. Volkerding, Sebeka, MN, USA |
---|
4 | # All rights reserved. |
---|
5 | # |
---|
6 | # Redistribution and use of this script, with or without modification, is |
---|
7 | # permitted provided that the following conditions are met: |
---|
8 | # |
---|
9 | # 1. Redistributions of this script must retain the above copyright |
---|
10 | # notice, this list of conditions and the following disclaimer. |
---|
11 | # |
---|
12 | # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED |
---|
13 | # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
---|
14 | # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO |
---|
15 | # EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
---|
16 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
---|
17 | # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; |
---|
18 | # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
---|
19 | # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
---|
20 | # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
---|
21 | # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
---|
22 | |
---|
23 | BUILD=${BUILD:-1} |
---|
24 | |
---|
25 | # NOTE: This is to cope with ImageMagick version numbers such as 5.4.7-4, |
---|
26 | # which occur fairly often (but not always). If these numbers are all the same, |
---|
27 | # then this is not one of those versions. |
---|
28 | |
---|
29 | # This is a bit messy, so we'll explain it well. :-) |
---|
30 | |
---|
31 | # This is the version number used in the source tarball filename |
---|
32 | FILEVER=6.9.4-9 |
---|
33 | |
---|
34 | # This is the base version number, which is needed to cd into the source tree. |
---|
35 | # Normally this is the same as $FILEVER, but allow setting it here if needed. |
---|
36 | BASEVER=$FILEVER |
---|
37 | |
---|
38 | # This is the version number used in the package, where a version number cannot |
---|
39 | # contain a '-'. We'll try to autogenerate this one. |
---|
40 | PKGVER=$(echo $FILEVER | tr - _) |
---|
41 | |
---|
42 | # Automatically determine the architecture we're building on: |
---|
43 | if [ -z "$ARCH" ]; then |
---|
44 | case "$( uname -m )" in |
---|
45 | i?86) export ARCH=i586 ;; |
---|
46 | arm*) export ARCH=arm ;; |
---|
47 | # Unless $ARCH is already set, use uname -m for all other archs: |
---|
48 | *) export ARCH=$( uname -m ) ;; |
---|
49 | esac |
---|
50 | fi |
---|
51 | |
---|
52 | NUMJOBS=${NUMJOBS:-" -j7 "} |
---|
53 | |
---|
54 | if [ "$ARCH" = "i586" ]; then |
---|
55 | SLKCFLAGS="-O2 -march=i586 -mtune=i686" |
---|
56 | LIBDIRSUFFIX="" |
---|
57 | elif [ "$ARCH" = "s390" ]; then |
---|
58 | SLKCFLAGS="-O2" |
---|
59 | LIBDIRSUFFIX="" |
---|
60 | elif [ "$ARCH" = "x86_64" ]; then |
---|
61 | SLKCFLAGS="-O2 -fPIC" |
---|
62 | LIBDIRSUFFIX="64" |
---|
63 | else |
---|
64 | SLKCFLAGS="-O2" |
---|
65 | LIBDIRSUFFIX="" |
---|
66 | fi |
---|
67 | |
---|
68 | CWD=$(pwd) |
---|
69 | TMP=${TMP:-/tmp} |
---|
70 | PKG=$TMP/package-imagemagick |
---|
71 | rm -rf $PKG |
---|
72 | mkdir -p $TMP $PKG |
---|
73 | |
---|
74 | # --with-x or not --with-x, that is the question. It seems many other |
---|
75 | # distributions don't compile with X support, but it's been traditional |
---|
76 | # here. I am moving the prefix to /usr (instead of /usr/X11R6) though, |
---|
77 | # because many X-linked things are put into /usr now (like GNOME), and |
---|
78 | # I've heard a few reports of compile failures when this isn't in /usr. |
---|
79 | # Everyone else does it -- time to follow the path of least resistance. |
---|
80 | |
---|
81 | cd $TMP |
---|
82 | rm -rf ImageMagick-$BASEVER |
---|
83 | tar xvf $CWD/ImageMagick-$FILEVER.tar.xz || exit 1 |
---|
84 | cd ImageMagick-$BASEVER || exit 1 |
---|
85 | |
---|
86 | # Harden the default settings in policy.xml to prevent security issues: |
---|
87 | zcat $CWD/policy.xml.diff.gz | patch -p1 --verbose || exit 1 |
---|
88 | |
---|
89 | chown -R root:root . |
---|
90 | find . \ |
---|
91 | \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \ |
---|
92 | -exec chmod 755 {} \; -o \ |
---|
93 | \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \ |
---|
94 | -exec chmod 644 {} \; |
---|
95 | |
---|
96 | # --without-modules seems to avoid a segfault when identifying |
---|
97 | # or converting ps or eps files... |
---|
98 | |
---|
99 | # --disable-openmp seems to keep the perl Image::Magick from |
---|
100 | # eating up all RAM, and may help other script bindings. |
---|
101 | |
---|
102 | CFLAGS="$SLKCFLAGS" \ |
---|
103 | CXXFLAGS="$SLKCFLAGS" \ |
---|
104 | ./configure \ |
---|
105 | --prefix=/usr \ |
---|
106 | --libdir=/usr/lib${LIBDIRSUFFIX} \ |
---|
107 | --mandir=/usr/man \ |
---|
108 | --sysconfdir=/etc \ |
---|
109 | --program-prefix= \ |
---|
110 | --with-x \ |
---|
111 | --with-frozenpaths=no \ |
---|
112 | --without-modules \ |
---|
113 | --disable-openmp \ |
---|
114 | --enable-static=no \ |
---|
115 | --enable-shared \ |
---|
116 | --with-gcc-arch=$ARCH \ |
---|
117 | --with-perl \ |
---|
118 | --with-rsvg \ |
---|
119 | --build=$ARCH-slackware-linux || exit 1 |
---|
120 | |
---|
121 | make $NUMJOBS INSTALLDIRS=site || make -j1 INSTALLDIRS=site || exit 1 |
---|
122 | # First, spam the running development system, as ImageMagick is unable to |
---|
123 | # properly link the utilities against a new shared library major version |
---|
124 | # otherwise which has led to several broken packages over the years: |
---|
125 | make -j1 install INSTALLDIRS=site || exit 1 |
---|
126 | /sbin/ldconfig |
---|
127 | |
---|
128 | # Now build again against the new libraries and headers: |
---|
129 | make clean |
---|
130 | make $NUMJOBS INSTALLDIRS=site || make -j1 INSTALLDIRS=site || exit 1 |
---|
131 | make -j1 install INSTALLDIRS=site DESTDIR=$PKG || exit 1 |
---|
132 | |
---|
133 | # This should certainly not be included. |
---|
134 | # It stomps on the libtool package. |
---|
135 | rm -f $PKG/usr/lib${LIBDIRSUFFIX}/libltdl.* |
---|
136 | |
---|
137 | # .la files in /usr/lib${LIBDIRSUFFIX}/ should be removed. |
---|
138 | # Other .la files should be left alone, as ImageMagick uses them internally |
---|
139 | # to locate modules. |
---|
140 | rm -f $PKG/usr/lib${LIBDIRSUFFIX}/*.la |
---|
141 | |
---|
142 | ( cd $PKG |
---|
143 | # Nothing but a perl upgrade should replace this (and maybe not even that) |
---|
144 | find . -name perllocal.pod | xargs rm -f |
---|
145 | ) |
---|
146 | |
---|
147 | # DESTDIR is still broken about this, but works well enough otherwise: |
---|
148 | #chmod 644 $PKG/usr/share/man/man3/* |
---|
149 | #mv $PKG/usr/share/man/man3 $PKG/usr/man |
---|
150 | #rmdir $PKG/usr/share/man |
---|
151 | |
---|
152 | ( cd $PKG/usr/lib${LIBDIRSUFFIX}/perl5 |
---|
153 | # Ditch empty dirs: |
---|
154 | rmdir */* 2> /dev/null |
---|
155 | rmdir * 2> /dev/null |
---|
156 | ) |
---|
157 | |
---|
158 | find $PKG | xargs file | grep -e "executable" -e "shared object" | grep ELF \ |
---|
159 | | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null |
---|
160 | |
---|
161 | # Compress and link manpages, if any: |
---|
162 | if [ -d $PKG/usr/man ]; then |
---|
163 | ( cd $PKG/usr/man |
---|
164 | for manpagedir in $(find . -type d -name "man*") ; do |
---|
165 | ( cd $manpagedir |
---|
166 | for eachpage in $( find . -type l -maxdepth 1 | grep -v '\.gz$') ; do |
---|
167 | ln -s $( readlink $eachpage ).gz $eachpage.gz |
---|
168 | rm $eachpage |
---|
169 | done |
---|
170 | gzip -9 *.? |
---|
171 | ) |
---|
172 | done |
---|
173 | ) |
---|
174 | fi |
---|
175 | |
---|
176 | # Move config files to .new: |
---|
177 | ( cd $PKG/etc/ImageMagick* |
---|
178 | for file in * ; do |
---|
179 | mv ${file} ${file}.new |
---|
180 | done |
---|
181 | ) |
---|
182 | |
---|
183 | mkdir -p $PKG/usr |
---|
184 | mv $PKG/usr/share/doc $PKG/usr |
---|
185 | cp -a \ |
---|
186 | AUTHORS LICENSE NEWS NOTICE Platforms.txt QuickStart.txt README.txt \ |
---|
187 | $PKG/usr/doc/Imag* |
---|
188 | |
---|
189 | # If there's a ChangeLog, installing at least part of the recent history |
---|
190 | # is useful, but don't let it get totally out of control: |
---|
191 | if [ -r ChangeLog ]; then |
---|
192 | DOCSDIR=$(echo $PKG/usr/doc/ImageMagick-*) |
---|
193 | cat ChangeLog | head -n 1000 > $DOCSDIR/ChangeLog |
---|
194 | touch -r ChangeLog $DOCSDIR/ChangeLog |
---|
195 | fi |
---|
196 | |
---|
197 | mkdir -p $PKG/install |
---|
198 | zcat $CWD/doinst.sh.gz > $PKG/install/doinst.sh |
---|
199 | cat $CWD/slack-desc > $PKG/install/slack-desc |
---|
200 | |
---|
201 | cd $PKG |
---|
202 | /sbin/makepkg -l y -c n $TMP/imagemagick-$PKGVER-$ARCH-$BUILD.txz |
---|
203 | |
---|