Advertisement
olivares

kertex.Slackbuild, slac-desc, doinst.sh

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