palemoon.SlackBuild 9.0 KB

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