palemoon.SlackBuild 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  1. #!/bin/sh
  2. # Slackware build script for Pale Moon
  3. # Copyright 2018,2019 Vasily Sora 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. # Modified by SlackBuilds.org
  23. # Special thanks to Ponce
  24. PRGNAM=palemoon
  25. VERSION=${VERSION:-29.1.1}
  26. SRCNAM1=${SRCNAM1:-Pale-Moon-${VERSION}_Release}
  27. SRCNAM2=${SRCNAM2:-pale-moon}
  28. SRCNAM3=${SRCNAM3:-UXP-RELBASE_20210330}
  29. BUILD=${BUILD:-1}
  30. TAG=${TAG:-_SBo}
  31. if [ -z "$ARCH" ]; then
  32. case "$( uname -m )" in
  33. i?86) ARCH=i586 ;;
  34. arm*) ARCH=arm ;;
  35. *) ARCH=$( uname -m ) ;;
  36. esac
  37. fi
  38. CWD=$(pwd)
  39. TMP=${TMP:-/tmp/SBo}
  40. PKG=$TMP/package-$PRGNAM
  41. OUTPUT=${OUTPUT:-/tmp}
  42. OBJ=${OBJ:-obj-$PRGNAM}
  43. GTK=${GTK:-gtk2}
  44. # You can try changing the optimization level to simply "-O2" if your processor
  45. # doesn't support sse2 instructions.
  46. # "-Os" might help if you experience segfaults.
  47. OPTIMIZE=${OPTIMIZE:-"-O2 -msse2 -mfpmath=sse"}
  48. if [ "$ARCH" = "i586" ]; then
  49. SLKCFLAGS="-O2 -march=i586 -mtune=i686"
  50. LIBDIRSUFFIX=""
  51. elif [ "$ARCH" = "i686" ]; then
  52. SLKCFLAGS="-O2 -march=i686 -mtune=i686"
  53. LIBDIRSUFFIX=""
  54. elif [ "$ARCH" = "x86_64" ]; then
  55. SLKCFLAGS="-O2 -fPIC"
  56. LIBDIRSUFFIX="64"
  57. else
  58. SLKCFLAGS="-O2"
  59. LIBDIRSUFFIX=""
  60. fi
  61. # look into adding this as an option:
  62. # elif [ "$ARCH" = "x86_64" ]; then
  63. # SLKCFLAGS="-O2 -D_FORTIFY_SOURCE=2 -fstack-protector --param ssp-buffer-size=4 -fPIE -pie -Wl,-z,relro,-z,now -mindirect-branch=th
  64. # The default is to build with official branding. This SlackBuild is used to
  65. # produce officially approved third party "contributed builds" of Pale Moon.
  66. # This SlackBuild can also be used to produce unapproved packages -- which
  67. # requires the use of the "new moon", or if applicable, "unstable" branding.
  68. # In general, the "unstable" branding is intended for those building from the
  69. # master trunck of the Pale Moon github repository.
  70. BRANDING=${BRANDING:---enable-official-branding}
  71. if [ "$BRANDING" = "NewMoon" ]; then
  72. BRANDING="--disable-official-branding --with-branding=palemoon/branding/unofficial"
  73. elif [ "$BRANDING" = "unstable" ]; then
  74. BRANDING="--disable-official-branding --with-branding=palemoon/branding/unstable"
  75. fi
  76. rm -rf $PKG $TMP/gold $TMP/$OBJ
  77. mkdir -p $TMP $PKG $OUTPUT $TMP/gold $TMP/$OBJ
  78. DEBUG=" --enable-strip --disable-debug --disable-debug-symbols --enable-release"
  79. if [ "${ENABLE_DEBUG:-no}" = "yes" ]; then
  80. DEBUG=" --disable-strip --disable-install-strip --enable-debug --enable-debug-symbols "
  81. # On IA32, use gold since GNU ld runs out of memory linking libxul.so
  82. # when debug is turned on
  83. if [ "$ARCH" = "i586" -o "$ARCH" = "i686" ]; then
  84. echo "#!/bin/bash" >> $TMP/gold/gold
  85. echo "/usr/bin/ld.gold \"\$@\"" >> $TMP/gold/gold
  86. cp $TMP/gold/gold $TMP/gold/ld
  87. chmod +x $TMP/gold/*
  88. PATH="$TMP/gold:$PATH"
  89. export CC="$CC -B$TMP/gold"
  90. export CXX="$CXX -B$TMP/gold"
  91. fi
  92. fi
  93. set -e
  94. # We need to use the incredibly ancient autoconf-2.13 for this :/
  95. # (Taken from Slackware's Firefox build Script)
  96. cd $TMP
  97. rm -rf autoconf-2.13
  98. tar xvf $CWD/autoconf-2.13.tar.xz
  99. cd autoconf-2.13
  100. zcat $CWD/autoconf-2.13-consolidated_fixes-1.patch.gz | patch -p1 --verbose
  101. chown -R root:root .
  102. find -L . \
  103. \( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 \
  104. -o -perm 511 \) -exec chmod 755 {} \; -o \
  105. \( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \
  106. -o -perm 440 -o -perm 400 \) -exec chmod 644 {} \;
  107. # Build a temporary copy of autoconf-2.13 only to be used to compile
  108. # Pale Moon, since it somewhat inexplicably requires this ancient version:
  109. rm -rf $TMP/autoconf-tmp
  110. mkdir -p $TMP/autoconf-tmp
  111. # This will be at the beginning of the $PATH, so protect against nonsense
  112. # happening in $TMP:
  113. chmod 700 $TMP/autoconf-tmp
  114. rm -rf $TMP/autoconf-tmp/*
  115. mkdir -p $TMP/autoconf-tmp/usr
  116. ./configure \
  117. --prefix=$TMP/autoconf-tmp/usr \
  118. --program-suffix=-2.13 \
  119. --infodir=$TMP/autoconf-tmp/usr/info \
  120. --mandir=$TMP/autoconf-tmp/usr/man \
  121. --build=$ARCH-slackware-linux
  122. make || make -j1
  123. make install
  124. PATH=$TMP/autoconf-tmp/usr/bin:$PATH
  125. # Build Pale Moon
  126. cd $TMP
  127. rm -rf $SRCNAM2
  128. tar -xvf $CWD/$SRCNAM1.tar.gz
  129. cd $SRCNAM2
  130. tar -xvf $CWD/$SRCNAM3.tar.gz -C platform --strip-components 1
  131. if [ "${ADNAUSEAM:-block}" = "unblock" ]; then
  132. patch -p1 < $CWD/adNauseam-unblock.patch
  133. fi
  134. # Selectively APPLY patch for glibc 2.30+
  135. if [ "${PATCH_GLIBC:-no}" = "yes" ]; then
  136. patch -p0 < $CWD/glibc-2.30+.patch
  137. fi
  138. chown -R root:root .
  139. find -L . \
  140. \( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 \
  141. -o -perm 511 \) -exec chmod 755 {} \; -o \
  142. \( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \
  143. -o -perm 440 -o -perm 400 \) -exec chmod 644 {} \;
  144. # Without LANG=C, building the Python environment may fail with:
  145. # "UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 36: ordinal not in range(128)"
  146. export LANG=C
  147. export MOZCONFIG="$TMP/$SRCNAM2/.mozconfig"
  148. export MOZILLA_OFFICIAL=1
  149. export MOZ_MAKE_FLAGS=$MAKEFLAGS
  150. export CFLAGS="$SLKCFLAGS"
  151. export CXXFLAGS="$SLKCFLAGS"
  152. export BUILDING_RELEASE=1
  153. export MOZ_ADDON_SIGNING=
  154. export MOZ_REQUIRE_SIGNING=
  155. export MOZ_TELEMETRY_REPORTING=
  156. export PYTHON=/usr/bin/python2
  157. # Dev tools are enabled by default in the official binaries, so we should do the same here;
  158. # passing DEVTOOLS=no to the script, however, will disable them.
  159. if [ "$DEVTOOLS" = "no" ]; then
  160. DEVTOOLS="--disable-devtools"
  161. else
  162. DEVTOOLS="--enable-devtools"
  163. fi
  164. # Please see https://www.palemoon.org/redist.shtml for restrictions when using the official branding.
  165. # Our building options, in a configure-like display ;)
  166. OPTIONS="\
  167. ${BRANDING} \
  168. --prefix=/usr \
  169. --libdir=/usr/lib${LIBDIRSUFFIX} \
  170. --with-default-mozilla-five-home=/usr/lib${LIBDIRSUFFIX}/$PRGNAM-$VERSION \
  171. --x-libraries=/usr/lib${LIBDIRSUFFIX} \
  172. --enable-default-toolkit=cairo-$GTK \
  173. --disable-accessibility \
  174. $DEBUG \
  175. $DEVTOOLS \
  176. --enable-application=$PRGNAM \
  177. --disable-crashreporter \
  178. --disable-updater \
  179. --disable-tests \
  180. --enable-jemalloc \
  181. --with-pthreads"
  182. echo "mk_add_options MOZ_OBJDIR=$TMP/$OBJ" > .mozconfig
  183. # Write in the .mozconfig the options above
  184. for option in $OPTIONS; do echo "ac_add_options $option" >> .mozconfig; done
  185. echo "ac_add_options --enable-optimize=\"$OPTIMIZE\"" >> .mozconfig
  186. if ! pkg-config --exists libpulse; then
  187. echo "ac_add_options --disable-pulseaudio" >> .mozconfig; fi
  188. if pkg-config --exists jack && [ "${BLACKLIST_JACK:-no}" != "yes" ]; then
  189. echo "ac_add_options --enable-jack" >> .mozconfig; fi
  190. sed -i 's/.\/platform\/mach/"python2\ .\/platform\/mach"/g' mach
  191. ./mach build
  192. ## Clean up; and package Pale Moon.
  193. mkdir -p $PKG/usr/lib${LIBDIRSUFFIX}/mozilla/plugins
  194. cd $TMP/$OBJ
  195. make install DESTDIR=$PKG
  196. cd $PKG
  197. # We don't need these (just symlinks anyway):
  198. rm -rf usr/lib${LIBDIRSUFFIX}/$PRGNAM-devel-$VERSION
  199. # Avoid duplicate binaries; details: https://bugzilla.mozilla.org/show_bug.cgi?id=658850
  200. # Pale Moon package scripts appear to attempt this, on other 'distros'; those scripts,
  201. # however, appear to fail on Slackware.
  202. rm -f usr/lib${LIBDIRSUFFIX}/$PRGNAM-$VERSION/$PRGNAM-bin
  203. # Use system provided Hunspell, if desired.
  204. if [ "${USE_SYSTEM_HUNSPELL}" = "yes" ]; then
  205. rm -rfv usr/lib${LIBDIRSUFFIX}/$PRGNAM-$VERSION/dictionaries
  206. cp -vsr /usr/share/hunspell usr/lib${LIBDIRSUFFIX}/$PRGNAM-$VERSION/dictionaries
  207. fi
  208. # Install icons:
  209. for PX in 16 32 48 ; do
  210. mkdir -p $PKG/usr/share/icons/hicolor/${PX}x${PX}/apps
  211. ln -s /usr/lib${LIBDIRSUFFIX}/$PRGNAM-$VERSION/browser/chrome/icons/default/default${PX}.png \
  212. $PKG/usr/share/icons/hicolor/${PX}x${PX}/apps/$PRGNAM.png
  213. done
  214. # ... and the 128px icon file too:
  215. mkdir -p $PKG/usr/share/icons/hicolor/128x128/apps
  216. ln -s /usr/lib${LIBDIRSUFFIX}/$PRGNAM-$VERSION/browser/icons/mozicon128.png \
  217. $PKG/usr/share/icons/hicolor/128x128/apps/$PRGNAM.png
  218. mkdir -p $PKG/usr/share/applications
  219. cat $CWD/palemoon.desktop > $PKG/usr/share/applications/$PRGNAM.desktop
  220. mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
  221. cp -a \
  222. $TMP/$SRCNAM2/platform/LEGAL $TMP/$SRCNAM2/LICENSE $TMP/$SRCNAM2/README.md $TMP/$SRCNAM2/AUTHORS \
  223. $PKG/usr/doc/$PRGNAM-$VERSION/
  224. cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
  225. mkdir -p $PKG/install
  226. cat $CWD/slack-desc > $PKG/install/slack-desc
  227. cat $CWD/doinst.sh > $PKG/install/doinst.sh
  228. /sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.${PKGTYPE:-tgz}