olivares

kertex.Slackbuild, slack-desc, doinst.sh, kertex.sh

Mar 16th, 2012
363
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Needed ed, bison, flex, lftp which are present in Slackware :)
  2.  
  3. kertex.Slackbuild
  4. ==================
  5. #!/bin/sh
  6. #$Id: kertex.SlackBuild,v 1.8 2012/03/10 18:30:33 tlaronde Exp $
  7. # Template generated by Alien's SlackBuild Toolkit: http://slackware.com/~alien/AST
  8. # Copyright 2009, 2010, 2011, 2012 Eric Hameleers, Eindhoven, Netherlands
  9. # Copyright 2012 [email protected]
  10. # Copyright 2012 tlaronde AT polynum.com
  11. # All rights reserved.
  12. #
  13. # Permission to use, copy, modify, and distribute this software for
  14. # any purpose with or without fee is hereby granted, provided that
  15. # the above copyright notice and this permission notice appear in all
  16. # copies.
  17. #
  18. # THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  19. # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  20. # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  21. # IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
  22. # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  23. # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  24. # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  25. # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  26. # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  27. # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  28. # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  29. # SUCH DAMAGE.
  30. # -----------------------------------------------------------------------------
  31. #
  32. # Slackware SlackBuild script
  33. # ===========================
  34. # For: kerTeX
  35. # Descr: kerTeX Tex Distribution
  36. # URL: http://www.kergis.com/en/kertex.html
  37. # Needs:
  38. # Changelog:
  39. # 0.9999.3.0-1: 08/Mar/2012 by [email protected]
  40. # * Sketching how R.I.S.K. has to be used by the package
  41. # framework.
  42. # 0.9995-1: 06/Mar/2012 by [email protected]
  43. # * Initial build.
  44. #
  45. # Run 'sh kerTeX.SlackBuild' to build a Slackware package.
  46. # The package (.tgz) and .txt file as well as build logs are created in /tmp .
  47. # Install it using 'installpkg'.
  48. #
  49. # -----------------------------------------------------------------------------
  50. # [TL] Note that the official name is: kerTeX with a small leading 'k'
  51. # to emphasize that TeX is the important part. There is no LaTeX is there
  52. # is no TeX...
  53. #
  54. # [TL] A supplementary tip: if KERTEX_PKG_DIR is set in the environment
  55. # at packaging time, the _kerTeX_ packages put in this dir will be
  56. # added to the package. These are _kerTeX_ packages built from a running
  57. # kerTeX. There are (if bin fmt, base etc.) binary dependent but hier
  58. # independent. This is the crux.
  59.  
  60. # [TL] Actually, packaging kerTeX for whatever packaging framework is a
  61. # simple 4 steps process:
  62. #
  63. # 1) Create a R.I.S.K. configuration file to take into account custom
  64. # values given by the packager when calling this script, and
  65. # configuring the kerTeX installed hierarchy conforming to the host
  66. # filesystem hierarchy.
  67. #
  68. # 2) Let R.I.S.K. build everything (removing all that is
  69. # automake/autoconf specific, since R.I.S.K. is a framework on is own).
  70. #
  71. # 3) Let R.I.S.K. install everything according to the filesystem
  72. # hierarchy configured in a subdirectory.
  73. #
  74. # 4) Let the host packaging system gather this result. But since
  75. # R.I.S.K. refuses to process if root, we will indeed install in a
  76. # subdir and package while R.I.S.K. has switched to root for its own
  77. # installation! So 4) is embedded in 3).
  78. #
  79. # As long as the version is concerned, this script could be always
  80. # cutting edge: if there is saved in SRCDIR a tarball with the
  81. # SlackBuild expected name, we use it. If not we download the latest
  82. # version and set the version accordingly. This means that updating
  83. # should be removing the saved tarball...
  84. #
  85. # For R.I.S.K. it refuses to process if being root, and switches only
  86. # when needed. Period.
  87. #
  88. if test $(id -u) -eq 0; then
  89. echo "Don't run me as root _now_!" >&2
  90. echo "I will switch to root only when needed." >&2
  91. exit 1
  92. fi
  93.  
  94. #========== STEP 1
  95. #
  96. # [TL] We respect the packaging framework protocol: the names, and will
  97. # be configuring R.I.S.K. after these.
  98.  
  99. # Set initial variables:
  100.  
  101. PRGNAM=kertex
  102. VERSION=0.9999.3.0 # to be set with the version of a _saved_ tarball
  103. BUILD=${BUILD:-1}
  104.  
  105. # The TAG is a unique identifier for all your Slackware packages.
  106. # Use your initials as the value for TAG for instance.
  107. TAG=${TAG:-_ast}
  108.  
  109. # Where do we look for sources?
  110. # [TL] The bundle can be already here (for packaging various flavors)
  111. # renamed with the Slackbuild convention. If not, we will download
  112. # from kergis.com, using the name of the bundle there.
  113. #
  114. SRCDIR=$(cd $(dirname $0); pwd)
  115. SOURCE="$SRCDIR/${PRGNAM}-${VERSION}.tar.gz"
  116. SRCURL=http://downloads.kergis.com/kertex_bundle.tar
  117.  
  118. # Place to build (TMP) package (PKG) and output (OUTPUT) the program:
  119. # We will remove this TMP. So create an unlikely name (if someone
  120. # defines TMP as '/'...), for concurrent builds, and don't fiddle with
  121. # it once set! The risk suffix will be verified.
  122. #
  123. TMP=${TMP:-/tmp/}/_$$-$PRGNAM-risk
  124. readonly TMP
  125.  
  126. # PKG will be installed "chrooted" here for packaging. Root created,
  127. # root deleted.
  128. #
  129. PKG=$TMP/package-$PRGNAM
  130.  
  131. # The result. So not deleted... and not created either: must exist!
  132. #
  133. OUTPUT=${OUTPUT:-/tmp}
  134.  
  135. # [TL] R.I.S.K. has its own way (does cross-compilation). And needs
  136. # explicit configuration. This script is a generic one. So we will
  137. # only build package for this matrix arch, except that for Intel based
  138. # we build for i486.
  139. #
  140. ARCH=$(uname -m)
  141. case $ARCH in
  142. i?86) ARCH=i486; XCFLAGS="-march=i486 -mtune=i686 -O2";
  143. ;;
  144. arm*) ARCH=arm;
  145. ;;
  146. esac
  147.  
  148. # Exit the script on errors:
  149. set -e
  150. trap 'echo "$0 FAILED at line ${LINENO}" | tee $OUTPUT/error-${PRGNAM}.log' ERR
  151.  
  152. # Catch unitialized variables:
  153. set -u
  154. P1=${1:-1}
  155.  
  156. # Save old umask and set to 0022:
  157. _UMASK_=$(umask)
  158. umask 0022
  159.  
  160. # Create working directories:
  161. OBJDIRPREFIX=$TMP/build # R.I.S.K.
  162. rm -fr $TMP
  163. mkdir -p $OBJDIRPREFIX
  164. TMPDIR=$OBJDIRPREFIX
  165. export OBJDIRPREFIX TMPDIR
  166.  
  167. #========== STEP 2
  168. #
  169. # [TL] R.I.S.K. processing. This is simply the get_mk_install.sh
  170. # customized.
  171. #
  172.  
  173. # We need a writable directory and not SRCDIR.
  174. #
  175. cd $TMP
  176.  
  177. if ! [ -f ${SOURCE} ]; then
  178. wget -nv -T 20 -O "kertex_bundle.tar" "${SRCURL}" || true
  179. if [ $? -ne 0 -o ! -s kertex_bundle.tar ]; then
  180. echo "Downloading 'kertex_bundle.tar' failed... aborting the build."
  181. exit 1
  182. fi
  183. tar xf kertex_bundle.tar
  184. else
  185. tar xzf $SOURCE
  186. fi
  187.  
  188. for src in knuth etex bibtex ams adobe kertex_M kertex_T risk_comp; do
  189. tar xzf ${src}_*.tar.gz
  190. rm ${src}_*.tar.gz
  191. done
  192.  
  193. # And then updating the version. If this is the saved bundle: it should
  194. # be unchanged. Downloaded: at least equal or newer.
  195. #
  196. VERSION=$(sed -n 's/^VERSION: *\([^ ][^ ]*\) *$/\1/p' kertex_T/CID)
  197.  
  198. # This is a fake configuration for kertex_M, just in order that the
  199. # name is the default one for the dir with the tools.
  200. # This is for illustration purpose. Since kertex_M is on matrix
  201. # (not installed) we do not set anything.
  202. #
  203. cat >$OBJDIRPREFIX/slackbuild <<EOT
  204. EOT
  205.  
  206. # Start compiling kertex_M.
  207. #
  208. (
  209. cd kertex_M;
  210. cd `../risk_comp/sys/posix/sh/rkconfig $OBJDIRPREFIX/slackbuild`;
  211. make SAVE_SPACE=YES;
  212. )
  213.  
  214. # Then compile kertex_T.
  215.  
  216. # Real configuration, with chrooting for the installation (the map).
  217. # And customization for url retrievers (kerTeX packaging system for
  218. # Slackware.
  219. #
  220. cat >$OBJDIRPREFIX/slackbuild <<EOT
  221. SYS_FTPC=lftp
  222. SYS_HTTPC=lftp
  223. CFLAGS="\$CFLAGS ${XCFLAGS:- }"
  224. TARGETCHROOT=$PKG
  225. TARGETBINDIR=/usr/bin
  226. TARGETLIBDIR=/usr/share
  227. EOT
  228.  
  229. cd kertex_T
  230. cd `../risk_comp/sys/posix/sh/rkconfig $OBJDIRPREFIX/slackbuild`
  231. make SAVE_SPACE=YES
  232.  
  233. #===== embedding 4) in 3)...
  234. #
  235. # [TL] R.I.S.K. switches to root only when strictly needed. We are hence
  236. # going to build the package during R.I.S.K. install procedure. So
  237. # we add the custom Slackbuild stuff.
  238. #
  239. # This is the real chunk of commands to build the package.
  240. # Replace the variables.
  241. #
  242. cat >.rkcomp/$$.slackbuild <<EOT
  243. PRGNAM=$PRGNAM
  244. VERSION=$VERSION
  245. BUILD=$BUILD
  246. TAG=$TAG
  247. PKG=$PKG
  248. SRCDIR=$SRCDIR
  249. TMP=$TMP
  250. OUTPUT=$OUTPUT
  251. THIS=$(basename $0)
  252. ARCH=$ARCH
  253. MANDIR=/usr/share/kertex/man
  254. KERTEX_PKG_DIR=${KERTEX_PKG_DIR:-}
  255. EOT
  256.  
  257. # Then add chunk verbatim.
  258. #
  259. cat >>.rkcomp/$$.slackbuild <<"EOT"
  260. set -u # we are root, don't write randomly...
  261.  
  262. # If there are kerTeX packages to apply do it now.
  263. if test "x$KERTEX_PKG_DIR" != x; then
  264. (
  265. cd $TMP
  266. mkdir _kxpkg
  267. cd _kxpkg
  268. for pkg in $KERTEX_PKG_DIR/*.tar.gz; do
  269. tar xzf $pkg
  270. done
  271. # Apply bin
  272. cd $PKG/usr/bin/kertex
  273. for pkg in $TMP/_kxpkg/*-bin.tar; do
  274. tar xf $pkg
  275. done
  276. # Apply lib
  277. cd $PKG/usr/share/kertex
  278. for pkg in $TMP/_kxpkg/*-lib.tar; do
  279. tar xf $pkg
  280. done
  281. )
  282. rm -fr $TMP/_kxpkg
  283. fi
  284.  
  285. # Put stuff where SlackBuilt expect them to be (and to be cleaned).
  286. #
  287. rm -rf $OUTPUT/{configure,make,install,error,makepkg}-$PRGNAM.log
  288. # remove old log files
  289. # Add documentation:
  290. mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
  291. cat $SRCDIR/$THIS > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
  292. chown -R root:root $PKG/usr/doc/$PRGNAM-$VERSION
  293. find $PKG/usr/doc -type f -exec chmod 644 {} \;
  294.  
  295. # Compress the man page(s):
  296. if [ -d $PKG$MANDIR ]; then
  297. find $PKG$MANDIR -type f -name "*.?" -exec gzip -9f {} \;
  298. for i in $(find $PKG$MANDIR -type l -name "*.?") ; do ln -s $(
  299. readlink $i ).gz $i.gz ; rm $i ; done
  300. fi
  301.  
  302. # Strip binaries (if any):
  303. find $PKG | xargs file | grep -e "executable" -e "shared object" | grep ELF \
  304. | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true
  305.  
  306. # Add a package description:
  307. mkdir -p $PKG/install
  308. cat $SRCDIR/slack-desc > $PKG/install/slack-desc
  309.  
  310. # Add a SlackBuild post-install if there is:
  311. if [ -f $SRCDIR/doinst.sh ]; then
  312. cat $SRCDIR/doinst.sh >> $PKG/install/doinst.sh
  313. fi
  314. # Add kertex.sh to /etc/profile.d/ so tex, latex, dvips executables are found
  315. # not fully tested so there might be some bugs. I added the kertex.sh manually and
  316. # repackaged xzm in both porteus versions
  317. echo '#!/bin/sh ' >> /etc/profile.d/kertex.sh
  318. echo " " >> /etc/profile.d/kertex.sh
  319. echo "PATH=\$PATH:/usr/bin/kertex" >> /etc/profile.d/kertex.sh
  320. echo "MANPATH=\$MANPATH:/usr/share/kertex/man" >> /etc/profile.d/kertex.sh
  321. echo
  322. chmod +x /etc/profile.d/kertex.sh
  323.  
  324. # Build the package:
  325. cd $PKG
  326. makepkg --linkadd y --chown n\
  327. $OUTPUT/${PRGNAM}-${VERSION}-${ARCH}-${BUILD}${TAG}.${PKGTYPE:-tgz} 2>&1\
  328. | tee $OUTPUT/makepkg-${PRGNAM}.log
  329. cd $OUTPUT
  330. md5sum ${PRGNAM}-${VERSION}-${ARCH}-${BUILD}${TAG}.${PKGTYPE:-tgz}\
  331. > ${PRGNAM}-${VERSION}-${ARCH}-${BUILD}${TAG}.${PKGTYPE:-tgz}.md5
  332. cd -
  333. cat $PKG/install/slack-desc | grep "^${PRGNAM}"\
  334. > $OUTPUT/${PRGNAM}-${VERSION}-${ARCH}-${BUILD}${TAG}.txt
  335.  
  336. # Done with the temporary install. Root created, root deleted.
  337. # Just for catching blunders, test name.
  338. #
  339. test "${PKG%$PRGNAM}" != "$PKG" && rm -fr $PKG
  340. EOT
  341.  
  342. # We simply add this to our own post-install.
  343. #
  344. ed -s .rkcomp/install_bin/post-install <<EOT
  345. ?exit 0?-r .rkcomp/$$.slackbuild
  346. w
  347. q
  348. EOT
  349.  
  350. # Creating a whole install in the $PKG subdir, and creating the package
  351. # by the way.
  352. #
  353. make local_install SAVE_SPACE=YES
  354.  
  355. # Cleaning our own risk stuff. Check name
  356. #
  357. test "${TMP%risk}" != "$TMP" && rm -fr $TMP
  358.  
  359. =============
  360. slack-desc
  361. =============
  362. # HOW TO EDIT THIS FILE:
  363. # The "handy ruler" below makes it easier to edit a package description. Line
  364. # up the first '|' above the ':' following the base package name, and the '|'
  365. # on the right side marks the last column you can put a character in. You must
  366. # make exactly 11 lines for the formatting to be correct. It's also
  367. # customary to leave one space after the ':'.
  368.  
  369. |-----handy-ruler------------------------------------------------------|
  370. kerTeX: kerTeX (kerTeX Tex Distribution)
  371. kerTeX:
  372. kerTeX: This is a TeX kernel system providing what everything is based
  373. kerTeX: upon: Donald E. Knuth's Digital Typography system; with some
  374. kerTeX: useful additions. This system includes, of course, METAFONT
  375. kerTeX: and TeX; but auxiliaries are also included. All the programs
  376. kerTeX: (latest published version) are included here. In addition, other
  377. kerTeX: programs linked to Tomas Rokicki's dvi to PostScript driver
  378. kerTeX: (dvips(1)) are added. Oren Patashnik's BibTeX (0.99d) is here
  379. kerTeX: too! John Hobby's MetaPost is included! The NTS team e-TeX
  380. kerTeX: is here! And D.E. Knuth and Silvio Levy' CWEB are here too!
  381.  
  382. */
  383.  
  384. This is a TeX kernel system providing what everything is based upon:
  385. Donald E. Knuth's Digital Typography system; with some useful
  386. additions.
  387.  
  388. This system includes, of course, METAFONT and TeX; but other utilities
  389. as well.
  390.  
  391. All the programs (latest published version) are included here.
  392.  
  393. In addition, other programs linked to Tomas Rokicki's dvi to
  394. PostScript driver (dvips(1)) are added. Oren Patashnik's BibTeX
  395. (0.99d) is here too! John Hobby's MetaPost is included! The NTS team
  396. e-TeX is here! And D.E. Knuth and Silvio Levy' CWEB are here too!
  397.  
  398. And since kerTeX aims to be a TeX system, a packaging framework has
  399. been developed for it too!
  400.  
  401. =================
  402. doinst.sh
  403. =================
  404. #!/bin/sh
  405. #$Id: doinst.sh,v 1.1 2012/03/09 19:15:09 tlaronde Exp $
  406. # C) 2012 Thierry Laronde <tlaronde AT polynum.com>
  407. #
  408. # A SlackBuild post-install script just to advertise what has to be
  409. # done.
  410. #
  411.  
  412. # For the moment, we just display the basic "what's next".
  413. #
  414. cat <<"EOT" >&2
  415.  
  416. ==================================================================
  417.  
  418. You're done!
  419. Thank you for using KerTeX
  420.  
  421. You must now, as an _unprivileged_ user build the fonts and compile
  422. the dump.
  423.  
  424. Just run:
  425.  
  426. which_kertex
  427.  
  428. to see where stuff is installed. And then run:
  429.  
  430. $KERTEX_BINDIR/adm/pkg_core install
  431.  
  432. Note that the man pages are put in kerTeX realm. So you will have to
  433. add the paths (man.config(5)). This is so in order for you to test
  434. different TeX distribution without one stepping on the others toes.
  435.  
  436. The path is displayed by which_kertex(1).
  437.  
  438. You should probably also edit dvips config to be found here:
  439.  
  440. $KERTEX_LIBDIR/dvips/dvips.cnf
  441.  
  442. to match the resolution and memory of your printer device, and to use
  443. or not T1 version of Donald E. Knuth's Computer Modern Fonts.
  444.  
  445. ==================================================================
  446.  
  447. EOT
  448.  
  449. exit 0
  450.  
  451. ===============
  452.  
  453. NOTES:
  454. in ~/.xinitrc or in ~/.bashrc, manually set the path, add the lines
  455. ==============================
  456. PATH="$PATH:/usr/bin/kertex";
  457. export $PATH
  458.  
  459. Thanks to the author of KerTeX for a job well done!
  460. Antonio A. Olivares
  461. Slackware-current x86_64 user
Advertisement
Add Comment
Please, Sign In to add comment