olivares

kertex.Slackbuild

Mar 8th, 2012
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.85 KB | None | 0 0
  1. #!/bin/sh
  2. #$Id: kertex.SlackBuild,v 1.8 2012/03/10 18:30:33 tlaronde Exp $
  3. # Template generated by Alien's SlackBuild Toolkit: http://slackware.com/~alien/AST
  4. # Copyright 2009, 2010, 2011, 2012 Eric Hameleers, Eindhoven, Netherlands
  5. # Copyright 2012 [email protected]
  6. # Copyright 2012 tlaronde AT polynum.com
  7. # All rights reserved.
  8. #
  9. # Permission to use, copy, modify, and distribute this software for
  10. # any purpose with or without fee is hereby granted, provided that
  11. # the above copyright notice and this permission notice appear in all
  12. # copies.
  13. #
  14. # THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  15. # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  16. # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  17. # IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
  18. # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  19. # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  20. # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  21. # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  22. # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  23. # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  24. # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  25. # SUCH DAMAGE.
  26. # -----------------------------------------------------------------------------
  27. #
  28. # Slackware SlackBuild script
  29. # ===========================
  30. # For: kerTeX
  31. # Descr: kerTeX Tex Distribution
  32. # URL: http://www.kergis.com/en/kertex.html
  33. # Needs:
  34. # Changelog:
  35. # 0.9999.3.0-1: 08/Mar/2012 by [email protected]
  36. # * Sketching how R.I.S.K. has to be used by the package
  37. # framework.
  38. # 0.9995-1: 06/Mar/2012 by [email protected]
  39. # * Initial build.
  40. #
  41. # Run 'sh kerTeX.SlackBuild' to build a Slackware package.
  42. # The package (.tgz) and .txt file as well as build logs are created in /tmp .
  43. # Install it using 'installpkg'.
  44. #
  45. # -----------------------------------------------------------------------------
  46. # [TL] Note that the official name is: kerTeX with a small leading 'k'
  47. # to emphasize that TeX is the important part. There is no LaTeX is there
  48. # is no TeX...
  49. #
  50. # [TL] A supplementary tip: if KERTEX_PKG_DIR is set in the environment
  51. # at packaging time, the _kerTeX_ packages put in this dir will be
  52. # added to the package. These are _kerTeX_ packages built from a running
  53. # kerTeX. There are (if bin fmt, base etc.) binary dependent but hier
  54. # independent. This is the crux.
  55.  
  56. # [TL] Actually, packaging kerTeX for whatever packaging framework is a
  57. # simple 4 steps process:
  58. #
  59. # 1) Create a R.I.S.K. configuration file to take into account custom
  60. # values given by the packager when calling this script, and
  61. # configuring the kerTeX installed hierarchy conforming to the host
  62. # filesystem hierarchy.
  63. #
  64. # 2) Let R.I.S.K. build everything (removing all that is
  65. # automake/autoconf specific, since R.I.S.K. is a framework on is own).
  66. #
  67. # 3) Let R.I.S.K. install everything according to the filesystem
  68. # hierarchy configured in a subdirectory.
  69. #
  70. # 4) Let the host packaging system gather this result. But since
  71. # R.I.S.K. refuses to process if root, we will indeed install in a
  72. # subdir and package while R.I.S.K. has switched to root for its own
  73. # installation! So 4) is embedded in 3).
  74. #
  75. # As long as the version is concerned, this script could be always
  76. # cutting edge: if there is saved in SRCDIR a tarball with the
  77. # SlackBuild expected name, we use it. If not we download the latest
  78. # version and set the version accordingly. This means that updating
  79. # should be removing the saved tarball...
  80. #
  81. # For R.I.S.K. it refuses to process if being root, and switches only
  82. # when needed. Period.
  83. #
  84. if test $(id -u) -eq 0; then
  85. echo "Don't run me as root _now_!" >&2
  86. echo "I will switch to root only when needed." >&2
  87. exit 1
  88. fi
  89.  
  90. #========== STEP 1
  91. #
  92. # [TL] We respect the packaging framework protocol: the names, and will
  93. # be configuring R.I.S.K. after these.
  94.  
  95. # Set initial variables:
  96.  
  97. PRGNAM=kertex
  98. VERSION=0.9999.3.0 # to be set with the version of a _saved_ tarball
  99. BUILD=${BUILD:-1}
  100.  
  101. # The TAG is a unique identifier for all your Slackware packages.
  102. # Use your initials as the value for TAG for instance.
  103. TAG=${TAG:-_ast}
  104.  
  105. # Where do we look for sources?
  106. # [TL] The bundle can be already here (for packaging various flavors)
  107. # renamed with the Slackbuild convention. If not, we will download
  108. # from kergis.com, using the name of the bundle there.
  109. #
  110. SRCDIR=$(cd $(dirname $0); pwd)
  111. SOURCE="$SRCDIR/${PRGNAM}-${VERSION}.tar.gz"
  112. SRCURL=http://downloads.kergis.com/kertex_bundle.tar
  113.  
  114. # Place to build (TMP) package (PKG) and output (OUTPUT) the program:
  115. # We will remove this TMP. So create an unlikely name (if someone
  116. # defines TMP as '/'...), for concurrent builds, and don't fiddle with
  117. # it once set! The risk suffix will be verified.
  118. #
  119. TMP=${TMP:-/tmp/}/_$$-$PRGNAM-risk
  120. readonly TMP
  121.  
  122. # PKG will be installed "chrooted" here for packaging. Root created,
  123. # root deleted.
  124. #
  125. PKG=$TMP/package-$PRGNAM
  126.  
  127. # The result. So not deleted... and not created either: must exist!
  128. #
  129. OUTPUT=${OUTPUT:-/tmp}
  130.  
  131. # [TL] R.I.S.K. has its own way (does cross-compilation). And needs
  132. # explicit configuration. This script is a generic one. So we will
  133. # only build package for this matrix arch, except that for Intel based
  134. # we build for i486.
  135. #
  136. ARCH=$(uname -m)
  137. case $ARCH in
  138. i?86) ARCH=i486; XCFLAGS="-march=i486 -mtune=i686 -O2";
  139. ;;
  140. arm*) ARCH=arm;
  141. ;;
  142. esac
  143.  
  144. # Exit the script on errors:
  145. set -e
  146. trap 'echo "$0 FAILED at line ${LINENO}" | tee $OUTPUT/error-${PRGNAM}.log' ERR
  147.  
  148. # Catch unitialized variables:
  149. set -u
  150. P1=${1:-1}
  151.  
  152. # Save old umask and set to 0022:
  153. _UMASK_=$(umask)
  154. umask 0022
  155.  
  156. # Create working directories:
  157. OBJDIRPREFIX=$TMP/build # R.I.S.K.
  158. rm -fr $TMP
  159. mkdir -p $OBJDIRPREFIX
  160. TMPDIR=$OBJDIRPREFIX
  161. export OBJDIRPREFIX TMPDIR
  162.  
  163. #========== STEP 2
  164. #
  165. # [TL] R.I.S.K. processing. This is simply the get_mk_install.sh
  166. # customized.
  167. #
  168.  
  169. # We need a writable directory and not SRCDIR.
  170. #
  171. cd $TMP
  172.  
  173. if ! [ -f ${SOURCE} ]; then
  174. wget -nv -T 20 -O "kertex_bundle.tar" "${SRCURL}" || true
  175. if [ $? -ne 0 -o ! -s kertex_bundle.tar ]; then
  176. echo "Downloading 'kertex_bundle.tar' failed... aborting the build."
  177. exit 1
  178. fi
  179. tar xf kertex_bundle.tar
  180. else
  181. tar xzf $SOURCE
  182. fi
  183.  
  184. for src in knuth etex bibtex ams adobe kertex_M kertex_T risk_comp; do
  185. tar xzf ${src}_*.tar.gz
  186. rm ${src}_*.tar.gz
  187. done
  188.  
  189. # And then updating the version. If this is the saved bundle: it should
  190. # be unchanged. Downloaded: at least equal or newer.
  191. #
  192. VERSION=$(sed -n 's/^VERSION: *\([^ ][^ ]*\) *$/\1/p' kertex_T/CID)
  193.  
  194. # This is a fake configuration for kertex_M, just in order that the
  195. # name is the default one for the dir with the tools.
  196. # This is for illustration purpose. Since kertex_M is on matrix
  197. # (not installed) we do not set anything.
  198. #
  199. cat >$OBJDIRPREFIX/slackbuild <<EOT
  200. EOT
  201.  
  202. # Start compiling kertex_M.
  203. #
  204. (
  205. cd kertex_M;
  206. cd `../risk_comp/sys/posix/sh/rkconfig $OBJDIRPREFIX/slackbuild`;
  207. make SAVE_SPACE=YES;
  208. )
  209.  
  210. # Then compile kertex_T.
  211.  
  212. # Real configuration, with chrooting for the installation (the map).
  213. # And customization for url retrievers (kerTeX packaging system for
  214. # Slackware.
  215. #
  216. cat >$OBJDIRPREFIX/slackbuild <<EOT
  217. SYS_FTPC=lftp
  218. SYS_HTTPC=lftp
  219. CFLAGS="\$CFLAGS ${XCFLAGS:- }"
  220. TARGETCHROOT=$PKG
  221. TARGETBINDIR=/usr/bin
  222. TARGETLIBDIR=/usr/share
  223. EOT
  224.  
  225. cd kertex_T
  226. cd `../risk_comp/sys/posix/sh/rkconfig $OBJDIRPREFIX/slackbuild`
  227. make SAVE_SPACE=YES
  228.  
  229. #===== embedding 4) in 3)...
  230. #
  231. # [TL] R.I.S.K. switches to root only when strictly needed. We are hence
  232. # going to build the package during R.I.S.K. install procedure. So
  233. # we add the custom Slackbuild stuff.
  234. #
  235. # This is the real chunk of commands to build the package.
  236. # Replace the variables.
  237. #
  238. cat >.rkcomp/$$.slackbuild <<EOT
  239. PRGNAM=$PRGNAM
  240. VERSION=$VERSION
  241. BUILD=$BUILD
  242. TAG=$TAG
  243. PKG=$PKG
  244. SRCDIR=$SRCDIR
  245. TMP=$TMP
  246. OUTPUT=$OUTPUT
  247. THIS=$(basename $0)
  248. ARCH=$ARCH
  249. MANDIR=/usr/share/kertex/man
  250. KERTEX_PKG_DIR=${KERTEX_PKG_DIR:-}
  251. EOT
  252.  
  253. # Then add chunk verbatim.
  254. #
  255. cat >>.rkcomp/$$.slackbuild <<"EOT"
  256. set -u # we are root, don't write randomly...
  257.  
  258. # If there are kerTeX packages to apply do it now.
  259. if test "x$KERTEX_PKG_DIR" != x; then
  260. (
  261. cd $TMP
  262. mkdir _kxpkg
  263. cd _kxpkg
  264. for pkg in $KERTEX_PKG_DIR/*.tar.gz; do
  265. tar xzf $pkg
  266. done
  267. # Apply bin
  268. cd $PKG/usr/bin/kertex
  269. for pkg in $TMP/_kxpkg/*-bin.tar; do
  270. tar xf $pkg
  271. done
  272. # Apply lib
  273. cd $PKG/usr/share/kertex
  274. for pkg in $TMP/_kxpkg/*-lib.tar; do
  275. tar xf $pkg
  276. done
  277. )
  278. rm -fr $TMP/_kxpkg
  279. fi
  280.  
  281. # Put stuff where SlackBuilt expect them to be (and to be cleaned).
  282. #
  283. rm -rf $OUTPUT/{configure,make,install,error,makepkg}-$PRGNAM.log
  284. # remove old log files
  285. # Add documentation:
  286. mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
  287. cat $SRCDIR/$THIS > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
  288. chown -R root:root $PKG/usr/doc/$PRGNAM-$VERSION
  289. find $PKG/usr/doc -type f -exec chmod 644 {} \;
  290.  
  291. # Compress the man page(s):
  292. if [ -d $PKG$MANDIR ]; then
  293. find $PKG$MANDIR -type f -name "*.?" -exec gzip -9f {} \;
  294. for i in $(find $PKG$MANDIR -type l -name "*.?") ; do ln -s $(
  295. readlink $i ).gz $i.gz ; rm $i ; done
  296. fi
  297.  
  298. # Strip binaries (if any):
  299. find $PKG | xargs file | grep -e "executable" -e "shared object" | grep ELF \
  300. | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true
  301.  
  302. # Add a package description:
  303. mkdir -p $PKG/install
  304. cat $SRCDIR/slack-desc > $PKG/install/slack-desc
  305.  
  306. # Add a SlackBuild post-install if there is:
  307. if [ -f $SRCDIR/doinst.sh ]; then
  308. cat $SRCDIR/doinst.sh >> $PKG/install/doinst.sh
  309. fi
  310.  
  311. # Build the package:
  312. cd $PKG
  313. makepkg --linkadd y --chown n\
  314. $OUTPUT/${PRGNAM}-${VERSION}-${ARCH}-${BUILD}${TAG}.${PKGTYPE:-tgz} 2>&1\
  315. | tee $OUTPUT/makepkg-${PRGNAM}.log
  316. cd $OUTPUT
  317. md5sum ${PRGNAM}-${VERSION}-${ARCH}-${BUILD}${TAG}.${PKGTYPE:-tgz}\
  318. > ${PRGNAM}-${VERSION}-${ARCH}-${BUILD}${TAG}.${PKGTYPE:-tgz}.md5
  319. cd -
  320. cat $PKG/install/slack-desc | grep "^${PRGNAM}"\
  321. > $OUTPUT/${PRGNAM}-${VERSION}-${ARCH}-${BUILD}${TAG}.txt
  322.  
  323. # Done with the temporary install. Root created, root deleted.
  324. # Just for catching blunders, test name.
  325. #
  326. test "${PKG%$PRGNAM}" != "$PKG" && rm -fr $PKG
  327. EOT
  328.  
  329. # We simply add this to our own post-install.
  330. #
  331. ed -s .rkcomp/install_bin/post-install <<EOT
  332. ?exit 0?-r .rkcomp/$$.slackbuild
  333. w
  334. q
  335. EOT
  336.  
  337. # Creating a whole install in the $PKG subdir, and creating the package
  338. # by the way.
  339. #
  340. make local_install SAVE_SPACE=YES
  341.  
  342. # Cleaning our own risk stuff. Check name
  343. #
  344. test "${TMP%risk}" != "$TMP" && rm -fr $TMP
Advertisement
Add Comment
Please, Sign In to add comment