aboutsummaryrefslogtreecommitdiff
path: root/network/palemoon/palemoon.SlackBuild
blob: c586143ae528379968845f56ebbee141a0edc78b (plain)
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
#!/bin/sh

# Slackware build script for palemoon

# Copyright 2018 Vasily Sora USA
# All rights reserved.
#
# Redistribution and use of this script, with or without modification, is
# permitted provided that the following conditions are met:
#
# 1. Redistributions of this script must retain the above copyright
#    notice, this list of conditions and the following disclaimer.
#
#  THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
#  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
#  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO
#  EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
#  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
#  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
#  OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
#  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
#  OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
#  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

# Modified by SlackBuilds.org
# Special thanks to Ponce

PRGNAM=palemoon
SRCNAM=${SRCNAM:-Pale-Moon}
VERSION=${VERSION:-27.9.2}
BUILD=${BUILD:-1}
TAG=${TAG:-_SBo}

if [ -z "$ARCH" ]; then
  case "$( uname -m )" in
    i?86) ARCH=i586 ;;
    arm*) ARCH=arm ;;
       *) ARCH=$( uname -m ) ;;
  esac
fi

CWD=$(pwd)
TMP=${TMP:-/tmp/SBo}
PKG=$TMP/package-$PRGNAM
OUTPUT=${OUTPUT:-/tmp}

# You can try changing the optimization level to simply "-O2" if your processor
# doesn't support sse2 instructions.
# "-Os" might help if you experience segfaults.
OPTIMIZE=${OPTIMIZE:-"-O2 -msse2 -mfpmath=sse"}
if [ "$ARCH" = "i586" ]; then
  SLKCFLAGS="-O2 -march=i586 -mtune=i686 -fopenmp"
  LIBDIRSUFFIX=""
elif [ "$ARCH" = "i686" ]; then
  SLKCFLAGS="-O2 -march=i686 -mtune=i686 -fopenmp"
  LIBDIRSUFFIX=""
elif [ "$ARCH" = "x86_64" ]; then
  SLKCFLAGS="-O2 -fPIC -fopenmp"
  LIBDIRSUFFIX="64"
else
  SLKCFLAGS="-O2"
  LIBDIRSUFFIX=""
fi

# The default is to build with official branding. This SlackBuild is used to
# produce officially approved third party "contributed builds" of Pale Moon.
# This SlackBuild can also be used to produce unapproved packages -- which
# requires the use of the "new moon", or if applicable, "unstable" branding.
# In general, the "unstable" branding is intended for those building from the
# master trunck of the Pale Moon github repository.
BRANDING=${BRANDING:---enable-official-branding}
if [ "$BRANDING" = "NewMoon" ]; then
	BRANDING="--disable-official-branding --with-branding=browser/branding/unofficial"
elif [ "$BRANDING" = "unstable" ]; then
	BRANDING="--disable-official-branding --with-branding=browser/branding/unstable"
fi

# Set the compiler that will be used. The ideal compiler for
# PaleMoon is most likely gcc-4.9.4.
#
# If the user has specified a compiler, use that. Other wise
# look to see if gcc-4.9.4 or gcc-4.8.2 and g++-4.9.4 or
# g++-4.8.2 can be found. If nothing else, default to using
# Slackware's stock compiler.
#
# Thank you to Orbea; for suggesting this method.
if command -v gcc-4.9.4 >/dev/null && command -v g++-gcc-4.9.4 >/dev/null; then
	CC="${CC:-gcc-4.9.4}" && CXX="${CXX:-g++-gcc-4.9.4}"
elif command -v gcc-4.8.2 >/dev/null && command -v g++-gcc-4.8.2 >/dev/null; then
	CC="${CC:-gcc-4.8.2}" && CXX="${CXX:-g++-gcc-4.8.2}"
else
	CC="${CC:-gcc}" && CXX="${CXX:-g++}"
fi

export CC="$CC"
export CXX="$CXX"

rm -rf $PKG $TMP/pmbuild $TMP/gold
mkdir -p $TMP $PKG $OUTPUT $TMP/pmbuild $TMP/gold

DEBUG=" --enable-strip --disable-debug --disable-debug-symbols --enable-release"
if [ "${ENABLE_DEBUG:-no}" = "yes" ]; then
  DEBUG=" --disable-strip --disable-install-strip --enable-debug-symbols "
  # On IA32, use gold since GNU ld runs out of memory linking libxul.so
  # when debug is turned on
  if [ "$ARCH" = "i586" -o "$ARCH" = "i686" ]; then
    echo "#!/bin/bash" >> $TMP/gold/gold
    echo "/usr/bin/ld.gold \"\$@\"" >> $TMP/gold/gold
    cp $TMP/gold/gold $TMP/gold/ld
    chmod +x $TMP/gold/*
    PATH="$TMP/gold:$PATH"
    export CC="$CC -B$TMP/gold"
    export CXX="$CXX -B$TMP/gold"
  fi
fi

set -e

# We need to use the incredibly ancient autoconf-2.13 for this  :/
# (Taken from Slackware's Firefox build Script)
cd $TMP
rm -rf autoconf-2.13
tar xvf $CWD/autoconf-2.13.tar.xz
cd autoconf-2.13
zcat $CWD/autoconf-2.13-consolidated_fixes-1.patch.gz | patch -p1 --verbose
chown -R root:root .
find -L . \
 \( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 \
  -o -perm 511 \) -exec chmod 755 {} \; -o \
 \( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \
  -o -perm 440 -o -perm 400 \) -exec chmod 644 {} \;

# Build a temporary copy of autoconf-2.13 only to be used to compile
# Pale Moon, since it somewhat inexplicably requires this ancient version:
rm -rf $TMP/autoconf-tmp
mkdir -p $TMP/autoconf-tmp
# This will be at the beginning of the $PATH, so protect against nonsense
# happening in $TMP:
chmod 700 $TMP/autoconf-tmp
rm -rf $TMP/autoconf-tmp/*
mkdir -p $TMP/autoconf-tmp/usr

./configure \
  --prefix=$TMP/autoconf-tmp/usr \
  --program-suffix=-2.13 \
  --infodir=$TMP/autoconf-tmp/usr/info \
  --mandir=$TMP/autoconf-tmp/usr/man \
  --build=$ARCH-slackware-linux

make || make -j1
make install
PATH=$TMP/autoconf-tmp/usr/bin:$PATH

# Build Pale Moon
cd $TMP
rm -rf $SRCNAM-${VERSION}_Release
tar xvf $CWD/$SRCNAM-${VERSION}_Release.tar.gz
cd $SRCNAM-${VERSION}_Release

if [ "${ADNAUSEAM:-block}" = "unblock" ]; then
	patch -p1 < $CWD/adNauseam-unblock.patch
fi

if [ ${NOSCRIPT:-block} = "unblock" ]; then
	patch -p1 < $CWD/noscript-unblock.patch
fi

chown -R root:root .
find -L . \
 \( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 \
  -o -perm 511 \) -exec chmod 755 {} \; -o \
 \( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \
  -o -perm 440 -o -perm 400 \) -exec chmod 644 {} \;

# Crude hack so that /usr/lib/mozilla/plugins points to
# /usr/lib64/mozilla/plugins on 64 bit systems
if [ "$LIBDIRSUFFIX" = "64" ]; then
  sed -i 's:/usr/lib/mozilla/plugins:/usr/lib64/mozilla/plugins:g' \
    xpcom/io/nsAppFileLocationProvider.cpp
fi


# Without LANG=C, building the Python environment may fail with:
# "UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 36: ordinal not in range(128)"
export LANG=C

export MOZBUILD_STATE_PATH="$TMP/$SRCNAM-${VERSION}_Release/moz.build"
export MOZCONFIG="$TMP/$SRCNAM-${VERSION}_Release/.mozconfig"
export MOZILLA_OFFICIAL=1
export MOZ_MAKE_FLAGS=$MAKEFLAGS
export CFLAGS="$SLKCFLAGS"
export CXXFLAGS="$SLKCFLAGS"
export PYTHON=/usr/bin/python2

# Dev tools are enabled by default in the official binaries, so we should do the same here;
# passing DEVTOOLS=no to the script, however, will disable them.
if [ "$DEVTOOLS" = "no" ]; then
  DEVTOOLS=""
else
  DEVTOOLS="--enable-devtools"
fi

# Please see https://www.palemoon.org/redist.shtml for restrictions when using the official branding.
# Our building options, in a configure-like display ;)
OPTIONS="\
  ${BRANDING} \
  --enable-application=browser \
  --enable-default-toolkit=cairo-gtk2 \
  --disable-installer \
  --disable-updater \
  --disable-tests \
  --disable-mochitests \
  --enable-jemalloc \
  --with-pthreads \
  --enable-shared-js \
  $DEVTOOLS \
  $DEBUG \
  --x-libraries=/usr/lib${LIBDIRSUFFIX} \
  --with-default-mozilla-five-home=/usr/lib${LIBDIRSUFFIX}/$PRGNAM-$VERSION \
  --prefix=/usr \
  --libdir=/usr/lib${LIBDIRSUFFIX} \
  --sysconfdir=/etc \
  --localstatedir=/var \
  --mandir=/usr/man"

echo "mk_add_options MOZ_CO_PROJECT=browser" >> .mozconfig
echo "mk_add_options MOZ_OBJDIR=$TMP/pmbuild" >> .mozconfig

# Write in the .mozconfig the options above
for option in $OPTIONS; do echo "ac_add_options $option" >> .mozconfig; done
echo "ac_add_options --enable-optimize=\"$OPTIMIZE\"" >> .mozconfig

if ! pkg-config --exists libpulse; then
echo "ac_add_options --disable-pulseaudio" >> .mozconfig; fi

python2 mach build

# Clean up; and package Pale Moon.
mkdir -p $PKG/usr/lib${LIBDIRSUFFIX}/mozilla/plugins
cd $TMP/pmbuild
make install DESTDIR=$PKG

cd $PKG

# We don't need these (just symlinks anyway):
rm -rf usr/lib${LIBDIRSUFFIX}/$PRGNAM-devel-$VERSION

# Avoid duplicate binaries; details: https://bugzilla.mozilla.org/show_bug.cgi?id=658850
# Pale Moon package scripts appear to attempt this, on other 'distros'; those scripts,
# however, appear to fail on Slackware.
rm -f usr/lib${LIBDIRSUFFIX}/$PRGNAM-$VERSION/$PRGNAM-bin

# Use system provided Hunspell, if desired.
if [ "${USE_SYSTEM_HUNSPELL}" = "yes" ]; then
  rm -rfv usr/lib${LIBDIRSUFFIX}/$PRGNAM-$VERSION/dictionaries
  cp -vsr /usr/share/hunspell usr/lib${LIBDIRSUFFIX}/$PRGNAM-$VERSION/dictionaries
fi

# Install icons:
for PX in 16 32 48 ; do
	mkdir -p $PKG/usr/share/icons/hicolor/${PX}x${PX}/apps
	ln -s /usr/lib${LIBDIRSUFFIX}/$PRGNAM-$VERSION/browser/chrome/icons/default/default${PX}.png \
	       $PKG/usr/share/icons/hicolor/${PX}x${PX}/apps/$PRGNAM.png
done
# ... and the 128px icon file too:
mkdir -p $PKG/usr/share/icons/hicolor/128x128/apps
ln -s /usr/lib${LIBDIRSUFFIX}/$PRGNAM-$VERSION/browser/icons/mozicon128.png \
	$PKG/usr/share/icons/hicolor/128x128/apps/$PRGNAM.png

mkdir -p $PKG/usr/share/applications
cat $CWD/palemoon.desktop > $PKG/usr/share/applications/$PRGNAM.desktop

mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
cp -a $TMP/$SRCNAM-${VERSION}_Release/LICENSE $TMP/$SRCNAM-${VERSION}_Release/README.md $PKG/usr/doc/$PRGNAM-$VERSION/
cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild

mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc
cat $CWD/doinst.sh > $PKG/install/doinst.sh

/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.${PKGTYPE:-tgz}