mirror of the now-defunct rocklinux.org
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

743 lines
19 KiB

  1. # --- ROCK-COPYRIGHT-NOTE-BEGIN ---
  2. #
  3. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  4. # Please add additional copyright information _after_ the line containing
  5. # the ROCK-COPYRIGHT-NOTE-END tag. Otherwise it might get removed by
  6. # the ./scripts/Create-CopyPatch script. Do not edit this copyright text!
  7. #
  8. # ROCK Linux: rock-src/scripts/functions
  9. # ROCK Linux is Copyright (C) 1998 - 2003 Clifford Wolf
  10. #
  11. # This program is free software; you can redistribute it and/or modify
  12. # it under the terms of the GNU General Public License as published by
  13. # the Free Software Foundation; either version 2 of the License, or
  14. # (at your option) any later version. A copy of the GNU General Public
  15. # License can be found at Documentation/COPYING.
  16. #
  17. # Many people helped and are helping developing ROCK Linux. Please
  18. # have a look at http://www.rocklinux.org/ and the Documentation/TEAM
  19. # file for details.
  20. #
  21. # --- ROCK-COPYRIGHT-NOTE-END ---
  22. # This function returns a "uniqe id" as output
  23. #
  24. get_unique() {
  25. date "+%s.$$.`/sbin/ifconfig -a | cksum | cut -f1 -d' '`"
  26. }
  27. # Hook variables
  28. #
  29. unset hook_functions hook_fcounter
  30. declare -a hook_functions='()'
  31. hook_fcounter=0
  32. # This function adds a code fragment to a named hook with the named priority
  33. #
  34. # hook_add hook_name priority code
  35. #
  36. hook_add() {
  37. hook_functions[hook_fcounter]="$3" # declare -a hookidx_$1
  38. eval "hookidx_$1[\${#hookidx_$1[@]}]=\"$2 $hook_fcounter\""
  39. eval "(( hookdirty_$1++ ))"; (( hook_fcounter++ ))
  40. }
  41. # This function executes all code fragments from the named hook
  42. #
  43. # hook_eval hook_name
  44. #
  45. hook_eval() {
  46. while read pri fnr ; do
  47. eval "${hook_functions[fnr]}"
  48. done < <( IFS=$'\n' ; eval "echo \"\${hookidx_$1[*]}\"" | sort )
  49. eval "unset hookdirty_$1"
  50. }
  51. # This function prints all hooks and their current contents
  52. #
  53. # hook_dump
  54. #
  55. hook_dump() {
  56. for hook in ${!hookidx_*} ; do
  57. hook=${hook#hookidx_}
  58. echo ; echo "Contents of hook $hook:"
  59. while read pri fnr ; do
  60. echo ; echo " $pri ($fnr)"
  61. echo "${hook_functions[fnr]}" | sed 's,^, ,'
  62. done < <( IFS=$'\n'
  63. eval "echo \"\${hookidx_$hook[*]}\"" | sort )
  64. if eval "[ -n \"\$hookdirty_\$hook\" ]"; then
  65. echo ; echo -n " Hook is marked as dirty: "
  66. eval "echo \"\${hookdirty_$hook}\""
  67. fi
  68. done
  69. echo
  70. }
  71. # This functions append, insert or remove values in variables:
  72. #
  73. # var_append PATH ":" "$HOME/bin"
  74. # var_insert CC_WRAPPER_INSERT " " "-O3"
  75. # var_remove CC_WRAPPER_INSERT " " "-O3"
  76. #
  77. # var_remove_regex CC_WRAPPER_INSERT " " "-O.*"
  78. #
  79. # var_insert_before_regex patchfiles " " "mypatch.diff" ".*\/foo.diff"
  80. #
  81. # 1st Parameter: Variable Name
  82. # 2nd Parameter: Delimiter Text
  83. # 3rd Parameter: Value (or regex)
  84. # 4th Parameter: regex for insert_before
  85. #
  86. var_append() {
  87. eval "[ \"\$$1\" ] && $1=\"\${$1}$2\"" || true
  88. eval "$1=\"\${$1}\$3\""
  89. }
  90. var_insert() {
  91. eval "[ \"\$$1\" ] && $1=\"$2\$$1\"" || true
  92. eval "$1=\"\$3\$$1\""
  93. }
  94. var_remove() {
  95. local a=${2//\/\\/}
  96. local b=${3//\/\\/}
  97. eval '[ "$'$1'" = "$3" ] && '$1'="" || true'
  98. eval $1'="${'$1'//$a$b$a/$2}"'
  99. eval $1'="${'$1'%$a$b}"'
  100. eval $1'="${'$1'#$b$a}"'
  101. }
  102. var_remove_regex() {
  103. eval "$1=\"\`echo \"\$$1\" | awk -- ' { split(\$0, a, \"$2\"); for (c1=c2=1; c1 in a; c1++) if ( a[c1] !~ /^$3\\\$/ ) b[c2++]=a[c1]; for (c1=1; c1 in b; c1++) printf \"%s%s\", (c1 > 0 ? \"$2\" : \"\"), b[c1]; }'\`\""
  104. }
  105. var_insert_before_regex() {
  106. eval "$1=\"\`echo \"\$$1\" | awk -- '{ split(\$0, a, \"$2\"); for (d=c1=c2=1; c1 in a; c1++) { if ( d && a[c1] ~ /^$4\\\$/ ) { b[c2++]=\"$3\"; d=0; } b[c2++]=a[c1]; } if (d) b[c2++]=\"$3\"; for (c1=1; c1 in b; c1++) printf \"%s%s\", (c1 > 0 ? \"$2\" : \"\"), b[c1]; }'\`\""
  107. }
  108. # This function can be used to duplicate a shell-function. E.g. when
  109. # overwriting a shell-function but the old one should stay available under
  110. # a new name:
  111. #
  112. # copy_function set_confopt set_confopt_foobar_old
  113. #
  114. # set_confopt() {
  115. # ....
  116. # set_confopt_foobar_old "$@"
  117. # ....
  118. # }
  119. #
  120. copy_function() {
  121. eval "$( declare -f $1 | sed "1 s,$1,$2," )"
  122. }
  123. # | column_clean |
  124. #
  125. # convert tabs to spaces, transform multiple consecutive spaces to one,
  126. # remove leading and trailing spaces
  127. column_clean() {
  128. tr '\t' ' ' | tr -s ' ' | sed -e 's,^[ ]*,,; s,[ ]*$,,;'
  129. }
  130. # | column_clean_tab |
  131. #
  132. # see column_clean, but with tabs
  133. column_clean_tab() {
  134. tr ' ' '\t' | tr -s '\t' | sed -e 's,^[\t]*,,; s,[\t]*$,,;'
  135. }
  136. # This function sets the 'confopt' and some other variables.
  137. # Re-run it in the package .conf file if you modify $prefix
  138. #
  139. set_confopt() {
  140. confopt="--prefix=$root/$prefix"
  141. bindir="$root/$prefix/bin"
  142. confopt="$confopt --bindir=\$bindir"
  143. sbindir="$root/$prefix/sbin"
  144. confopt="$confopt --sbindir=\$sbindir"
  145. libdir="$root/$prefix/lib"
  146. confopt="$confopt --libdir=\$libdir"
  147. if [ -z "$prefix" ]; then
  148. datadir="$root/usr/share"
  149. includedir="$root/usr/include"
  150. docdir="$root/usr/doc/$pkg"
  151. infodir="$root/usr/info"
  152. mandir="$root/usr/man"
  153. else
  154. datadir="$root/$prefix/share"
  155. includedir="$root/$prefix/include"
  156. docdir="$root/$prefix/doc/$pkg"
  157. infodir="$root/$prefix/info"
  158. mandir="$root/$prefix/man"
  159. fi
  160. confopt="$confopt --datadir=\$datadir"
  161. confopt="$confopt --includedir=\$includedir"
  162. confopt="$confopt --infodir=\$infodir"
  163. confopt="$confopt --mandir=\$mandir"
  164. if [ "${prefix#opt/}" != "$prefix" ] ; then
  165. sysconfdir="$root/etc/$prefix"
  166. localstatedir="$root/var/$prefix"
  167. elif [ "${prefix#usr}" != "$prefix" ] ; then
  168. sysconfdir="$root/etc"
  169. localstatedir="$root/var"
  170. else
  171. sysconfdir="$root/$prefix/etc"
  172. localstatedir="$root/$prefix/var"
  173. fi
  174. confopt="$confopt --sysconfdir=\$sysconfdir"
  175. confopt="$confopt --localstatedir=\$localstatedir"
  176. if [ "$ROCKCFG_CONFIGURE_OPTS" ] ; then
  177. confopt="$confopt $ROCKCFG_CONFIGURE_OPTS"
  178. fi
  179. if [ "$ROCKCFG_DEBUG" = 0 ] ; then
  180. confopt="$confopt --disable-debug"
  181. fi
  182. if [ "$stagelevel" -le 1 -o "$ROCKCFG_DISABLE_NLS" = 1 ] ; then
  183. confopt="${confopt//--enable-nls/} --disable-nls"
  184. fi
  185. confopt="$confopt \$extraconfopt"
  186. if [ "$stagelevel" -eq 0 ]; then
  187. confopt="$confopt --target=\$arch_target --host=\$arch_build"
  188. else
  189. confopt="$confopt --build=\$arch_build --host=\$arch_target"
  190. fi
  191. }
  192. #
  193. # eval_config_command $( eval echo $confopt )
  194. #
  195. function eval_config_command() {
  196. local config_command
  197. for x in /usr/share/automake/*
  198. do
  199. [ -x "$x" -a -f "$x" ] || continue
  200. x="$( basename "$x" )"
  201. if [ -L $x -a ! -e $x ] ; then
  202. echo "Fixing dead symlink $x."
  203. ln -sf /usr/share/automake/$x .
  204. fi
  205. done
  206. if [ $autogen -eq 1 -a \( -f configure.in -o -f configure.ac \) ] ; then
  207. if [ -f configure.orig ] ; then
  208. echo "Found configure.orig. Not" \
  209. "running autogen script."
  210. elif [ -f autogen.sh ] ; then
  211. echo "Running package autogen script."
  212. sh autogen.sh
  213. else
  214. echo "Running builtin autogen script."
  215. libtoolize --force --automake ; aclocal
  216. if grep AM_INIT_AUTOMAKE configure.[ia][nc]
  217. then automake ; fi
  218. autoconf
  219. fi
  220. fi
  221. if [ $stagelevel -le 1 ] ; then
  222. create_config_cache >> config.cache
  223. grep -q '.--cache-file=' $configscript &&
  224. set -- "$@" "--cache-file=config.cache"
  225. export cache_file=config.cache
  226. fi
  227. config_command="$configprefix $configscript"
  228. sub_scripts="$( find $( dirname $configscript ) -name configure )"
  229. # remove unsupported config script options
  230. for x ; do
  231. if grep -q "[[ ]${x%%=*}[]= ):]" $configscript $sub_scripts ; then
  232. config_command="$config_command $x"
  233. elif [[ $x = --*able-* ]] && egrep -q "\-\-(en|dis)able-\*" $configscript ; then
  234. echo "Autodetection for option impossible: " \
  235. "$x passed thru."
  236. config_command="$config_command $x"
  237. else
  238. echo "Removing unsupported '$x' from" \
  239. "configure option string."
  240. fi
  241. done
  242. echo Running "$config_command"
  243. eval "$config_command"
  244. }
  245. # run 'make check' if Makefile supports it.
  246. #
  247. function run_check() {
  248. if grep -q -e "^check:" ./Makefile; then
  249. echo "Running make check ..."
  250. $MAKE check
  251. fi
  252. if grep -q -e "^test:" ./Makefile; then
  253. echo "Running make test ..."
  254. $MAKE test
  255. fi
  256. }
  257. # move the static libs from lib to usr/lib and correct the libdir used
  258. # inside the .la file
  259. #
  260. postflist_static_lib() {
  261. echo "processing static lib corrections ..."
  262. egrep '^lib/.*\.(a|la)$' $builddir/flist.txt |
  263. while read fn ; do
  264. [ -e $root/$fn -o -L $root/$fn ] || continue
  265. if [[ $fn = *.a ]] ; then
  266. mv -fv $root/$fn $root/usr/$fn
  267. else
  268. sed "s,\([ =']\)/lib\(.*\),\1/usr/lib\2,g" \
  269. $root/$fn > $root/usr/$fn
  270. rm $root/$fn
  271. fi
  272. add_flist $root/usr/$fn
  273. done
  274. }
  275. # Parse the *.desc file. Use the description from PKG-DESC-FORMAT and
  276. # save the tag data in $desc_*.
  277. #
  278. parse_desc() {
  279. tag="`grep '^\[' $base/Documentation/Developers/PKG-DESC-FORMAT | \
  280. sed 's, (\*),,; s,\] \[,|,g; s,\[,,; s,\],,;'`"
  281. descfile="$( pkg="$pkg" xpkg="$xpkg" descparser < $confdir/$1.desc )"
  282. for tag in $tag ; do
  283. tagdata="`echo "$descfile" | egrep "^\[($tag)\]" | \
  284. cut -f2- -d']' | sed 's,^ ,,'`"
  285. tag="`echo $tag | cut -f1 -d'|' | tr - _`"
  286. eval "desc_$tag=\"\$tagdata\""
  287. done
  288. }
  289. # This function is used for forcing a file to be in the flist
  290. #
  291. add_flist() {
  292. for addfile ; do
  293. echo "$addfile" | fl_wrparse -D -r "$xroot/" \
  294. >> $builddir/flist.txt
  295. done
  296. }
  297. # This function is used for forcing a package to be in the dependency list
  298. #
  299. add_dependency() {
  300. for addpackage ; do
  301. echo "$addpackage: add_dependency()" \
  302. >> $builddir/dependencies.debug
  303. done
  304. }
  305. # This function is used to subsitute some important variables
  306. # using a D_ prefix thru m4 ...
  307. rock_substitute() {
  308. sed -e s,D_prefix,$prefix,g -e s,D_sysconfdir,$sysconfdir,g \
  309. -e s,D_docdir,$docdir,g -e s,D_localstatedir,$localstatedir,g \
  310. -e s,D_datadir,$datadir,g -e s,D_infodir,$infodir,g \
  311. -e s,D_bindir,$bindir,g -e s,D_sbindir,$sbindir,g \
  312. -e s,D_libdir,$libdir,g -e s,D_mandir,$mandir,g $1
  313. }
  314. # This outputs a predefined config.cache file as it needed by some
  315. # packages to cross-build correctly in stages 0 and 1.
  316. #
  317. create_config_cache() {
  318. cat $base/scripts/config.cache
  319. echo -e "\n# Architecture specific stuff\n"
  320. echo "ac_cv_sizeof_short=$arch_sizeof_short"
  321. echo "ac_cv_sizeof_int=$arch_sizeof_int"
  322. echo "ac_cv_sizeof_long=$arch_sizeof_long"
  323. echo "ac_cv_sizeof_long_long=$arch_sizeof_long_long"
  324. echo "ac_cv_sizeof_char_p=$arch_sizeof_char_p"
  325. echo "ac_cv_c_bigendian=$arch_bigendian"
  326. echo "ac_cv_prog_CC=$CC"
  327. }
  328. # Abort build before actual build starts
  329. # (is overwritten in Build-Pkg)
  330. #
  331. abort() {
  332. echo -e "The package build aborted with the following config" \
  333. "error:\n$*" > $root/var/adm/logs/$stagelevel-$pkg.err
  334. echo_errorquote "`cat $root/var/adm/logs/$stagelevel-$pkg.err`"
  335. echo_pkg_abort $stagelevel $repository $pkg
  336. exit 1
  337. }
  338. # Dump Environment
  339. #
  340. dump_env() {
  341. # Dump $base - only set if there is not already an older value.
  342. #
  343. echo "base=\"\${base:-$base}\""
  344. # Dump all variables including their flags, but skip read-only
  345. # variables and $base.
  346. #
  347. # Substitute base directory with ${base}.
  348. #
  349. for name in ${!a*} ${!b*} ${!c*} ${!d*} ${!e*} ${!f*} ${!g*} ${!h*} \
  350. ${!i*} ${!j*} ${!k*} ${!l*} ${!m*} ${!n*} ${!o*} ${!p*} \
  351. ${!q*} ${!r*} ${!s*} ${!t*} ${!u*} ${!v*} ${!w*} ${!x*} \
  352. ${!y*} ${!z*} \
  353. ${!A*} ${!B*} ${!C*} ${!D*} ${!E*} ${!F*} ${!G*} ${!H*} \
  354. ${!I*} ${!J*} ${!K*} ${!L*} ${!M*} ${!N*} ${!O*} ${!P*} \
  355. ${!Q*} ${!R*} ${!S*} ${!T*} ${!U*} ${!V*} ${!W*} ${!X*} \
  356. ${!Y*} ${!Z*} ${!_*}
  357. do
  358. [ $name = base ] && continue
  359. if declare -p $name | head -n 1 | grep -qv '^declare -[a-z]*r'
  360. then
  361. declare -p $name | sed "s,\\(^\\|[\"=:]\\)$base\\([\"=:/]\\|\$\\),\\1\${base}\\2,g"
  362. fi
  363. done
  364. # Dump functions
  365. #
  366. declare -f | sed 's/^declare -f //; s/<<(/< <(/;'
  367. # Dump aliases
  368. #
  369. alias
  370. }
  371. # Check if a package is already installed
  372. #
  373. # It does check the build-list if not in the rebuild stage - and
  374. # the really installed package data for rebuilds (and so manual builds).
  375. #
  376. pkginstalled() {
  377. if [ "$stagelevel" -le 8 ] ; then
  378. local pattern="$1"; pattern="${pattern//+/\\+}"
  379. egrep -q "^X.* ($pattern) " $base/config/$config/packages
  380. else
  381. [ -f $root/var/adm/packages/$1 ]
  382. fi
  383. }
  384. # Register a window-manager
  385. #
  386. register_wm() {
  387. [ -e /usr/share/rock-registry/wm ] || mkdir -p $root/usr/share/rock-registry/wm
  388. echo -e "name=\"$2\"\nexec=\"$3\"\n" > $root/usr/share/rock-registry/wm/$1
  389. }
  390. # Register an application
  391. #
  392. register_application() {
  393. [ -e /usr/share/rock-registry/app ] \
  394. || mkdir -p /usr/share/rock-registry/app
  395. echo -e "name=\"$2\"\nexec=\"$3\"\n" > /usr/share/rock-registry/app/$1
  396. }
  397. # Register a xdm - display manager
  398. #
  399. register_xdm() {
  400. [ -e /usr/share/rock-registry/xdm ] \
  401. || mkdir -p /usr/share/rock-registry/xdm
  402. echo -e "name=\"$2\"\nexec=\"$3\"\n" > /usr/share/rock-registry/xdm/$1
  403. }
  404. # Create Package Database for gasgui install tool
  405. #
  406. create_package_db() {
  407. rm -f $3.tmp
  408. for file in $( ls -dr $1/descs/?* ) ; do
  409. pkg="${file##*/}"
  410. # only include the package if a binary file is available
  411. if [ "$ROCKCFG_PKGFILE_VER" = 1 ] ; then
  412. v=-$(grep '^Package Name and Version' \
  413. $1/packages/$pkg | cut -f6 -d' ')
  414. else
  415. v=""
  416. fi
  417. if [ "$ROCKCFG_CREATE_GEM" = 1 ] ; then
  418. bfile=${pkg}${v}.gem
  419. else
  420. bfile=${pkg}${v}.tar.bz2
  421. fi
  422. if [ -e $2/$bfile ] ; then
  423. [ "$pkg" = TRANS.TBL ] && continue
  424. ( echo -e "$pkg"
  425. echo -e "\027"
  426. cat $1/descs/$pkg
  427. echo -e "\027"
  428. cat $1/dependencies/$pkg
  429. echo -e "\027"
  430. cat $1/cksums/$pkg
  431. echo -e "\027"
  432. echo -e "\004"
  433. ) >> $3.tmp
  434. else
  435. echo_error "Binary file for $bfile not present." \
  436. "Skipped in package database."
  437. fi
  438. done
  439. gzip -c $3.tmp > $3 ; rm -f $3.tmp
  440. }
  441. # Add files to the 'badfiles' list
  442. #
  443. register_badfiles() {
  444. local x desc="$1"
  445. shift
  446. for x in "$@"; do
  447. var_append badfiles $'\n' " $x\$"
  448. badfiles_desc[$badfiles_nr]=" $x\$"$'\n'"$desc"
  449. (( badfiles_nr++ ))
  450. done
  451. }
  452. # Apply the given $patchfiles
  453. #
  454. apply_patchfiles() {
  455. for x in $patchfiles; do
  456. echo "Apply patch $x ..."
  457. if [[ $x = *.bz2 ]] ; then
  458. bzcat $x | patch $patchopt
  459. else
  460. patch $patchopt < $x
  461. fi
  462. eval "$@"
  463. done
  464. }
  465. # Main program for building a package
  466. #
  467. build_this_package() {
  468. if [ ".$desc_SRC" == "." ] ; then
  469. # Autodetect source tar and extract it
  470. #
  471. if [ $srctar = auto ] ; then
  472. xsourceballs=$( echo "$desc_D" | head -n 1 | tr ' ' '\t' | tr -s '\t' | \
  473. cut -f2 | sed 's,.\(t\?\)\(gz\|Z\)$,.\1bz2,' )
  474. if [ -z "$xsourceballs" ] ; then
  475. echo "Can't auto-detect srctar for package '$pkg'!"
  476. false
  477. fi
  478. else
  479. xsourceballs="$srctar"
  480. fi
  481. else
  482. sourceballs=$( echo "$desc_D" | tr ' ' '\t' | tr -s '\t' | \
  483. cut -f2 | sed 's,.\(t\?\)\(gz\|Z\)$,.\1bz2,' )
  484. xsrcpattern=$( echo "$desc_SRC" | tr ' ' '\t' | tr -s '\t' | tr '\t' '\n' )
  485. xsourceballs=$( echo "$sourceballs" | grep -F "$xsrcpattern" )
  486. fi
  487. for xsrctar in $xsourceballs; do
  488. saved_patchfiles="$patchfiles"
  489. var_append patchfiles " " \
  490. "`ls $confdir/*.patch.${xsrctar/-[0-9]*/} 2> /dev/null`"
  491. if [ $autoextract = 1 ]; then
  492. echo "Extracting $xsrctar ($taropt) ... "
  493. cd $builddir
  494. tar -v $taropt $archdir/$xsrctar | tee untar.txt |
  495. cut -f1 -d/ | sort -u > xsrcdir.txt
  496. #
  497. if [ $srcdir = auto ]; then
  498. xsrcdir=${xsrctar%.tar.bz2}
  499. xsrcdir=${xsrcdir%.tbz2}
  500. if [ ! -d $xsrcdir ] ; then
  501. for x in $pkg-$ver $pkg_$ver $pkg \
  502. "`cat xsrcdir.txt`" ; do
  503. [ -d "$x" ] && xsrcdir="$x"
  504. done
  505. fi
  506. else
  507. xsrcdir="$srcdir"
  508. fi
  509. #
  510. if [ "$chownsrcdir" = 1 ]; then
  511. echo "Fixing ownership and permissions ..."
  512. chown -R 0:0 $builddir/$xsrcdir
  513. fi
  514. #
  515. if [ "$nocvsinsrcdir" = 1 ]; then
  516. echo "Removing CVS and .svn directories ..."
  517. egrep '(^|/)(CVS|\.svn)(/|$)' untar.txt |
  518. while read x; do
  519. echo "Removing $x ..."
  520. rm -rf "$x"
  521. done
  522. fi
  523. #
  524. echo "Changeing into $builddir/$xsrcdir ..."
  525. cd $builddir/$xsrcdir
  526. # Apply patches
  527. #
  528. if [ $autopatch = 1 ]; then
  529. hook_eval prepatch
  530. apply_patchfiles
  531. hook_eval postpatch
  532. fi
  533. else
  534. cd $builddir
  535. fi
  536. if [ "$createprefix" = 1 ]; then
  537. echo "Creating $root/$prefix/<..> if required ..."
  538. for x in $docdir $root/$prefix/bin $root/$prefix/lib \
  539. $root/$prefix/share $sysconfdir $localstatedir
  540. do
  541. if [ ! -e $x ]; then
  542. mkdir -p $x
  543. rmemptydir="$rmemptydir $x"
  544. fi
  545. done
  546. fi
  547. if [ ".$custmain" = "." ]
  548. then
  549. # Run configure scripts etc.
  550. #
  551. hook_eval preconf
  552. #
  553. if [ $runconf = 1 ]; then
  554. if [ -n "$( type -p $configscript )" -o $autogen = 1 ]
  555. then
  556. eval_config_command $( eval echo $confopt )
  557. fi
  558. fi
  559. # automated package build
  560. # styles without make run first:
  561. if [ -f setup.py -a $runpysetup = 1 ] ; then
  562. pyconfopt="${pyconfopt:=--prefix $root/$prefix}"
  563. eval python setup.py build install $pyconfopt
  564. else # styles that include a make run
  565. if [ ! -f Makefile -a ! -f makefile -a \
  566. -f Makefile.PL -a $runmkpl = 1 ]; then
  567. perl Makefile.PL INSTALLDIRS=perl
  568. fi
  569. #
  570. if [ ! -f Makefile -a ! -f makefile -a \
  571. -f Imakefile -a $runxmkmf = 1 ]; then
  572. xmkmf -a
  573. fi
  574. #
  575. # Build it
  576. #
  577. hook_eval premake
  578. if [ "$makeopt" ]
  579. then eval "$MAKE $makeopt"; fi
  580. hook_eval inmake
  581. if [ "$makeinstopt" ]
  582. then eval "$MAKE $makeinstopt"; fi
  583. hook_eval postmake
  584. fi
  585. else
  586. eval "$custmain"
  587. for x in preconf premake inmake postmake; do
  588. if eval "[ -n \"\$hookdirty_$x\" ]"; then
  589. echo "Hook $x is still marked as dirty ..."
  590. hook_eval $x
  591. fi
  592. done
  593. fi
  594. if [ "$createdocs" != 0 ]; then
  595. if [ ! -e $docdir ]; then
  596. mkdir -p $docdir
  597. rmemptydir="$rmemptydir $docdir"
  598. fi
  599. [ -z "$createdocs" ] && createdocs="$ROCKCFG_CREATE_DOCS"
  600. fi
  601. for file in $confdir/*.desktop ; do
  602. [ -f $file ] || continue
  603. echo -n "Install desktop file '$file': "
  604. mkdir -p $root/usr/share/rock-registry/app
  605. rock_substitute $file > \
  606. $root/usr/share/rock-registry/app/`basename $file`
  607. done
  608. if [ "$createdocs" = 1 ]; then
  609. echo "Trying to copy the default documentation ..."
  610. [ -d $builddir/$xsrcdir ] && cd $builddir/$xsrcdir
  611. for x in `find -type d \( -name 'doc' -o -name 'docs' -o \
  612. -name '[Dd]ocumentation' \) ! -empty`
  613. do
  614. if [ -d "$x" -a "`echo $x/*`" != "$x/*" ]
  615. then cp -rLv $x/* $docdir || true ; fi
  616. done
  617. for x in [A-Z][A-Z]* *.lsm ChangeLog*; do
  618. [ "${x#*.[cho0-9]}" ] || continue
  619. [ "${x#*.info*}" ] || continue
  620. if [ -f $x ] ; then cp -v $x $docdir/$x ; fi
  621. done
  622. for x in $confdir/*.doc; do
  623. if [ -f $x ]; then cp -v $x $docdir/${x%.doc}; fi
  624. done
  625. find $docdir/ -name '*.[0-9]' -o -name '*.info*' \
  626. -o -name '[Mm]akefile*' | \
  627. xargs -r rm -f 2> /dev/null || true
  628. find $docdir/* -type d -empty 2> /dev/null | \
  629. xargs -r rmdir 2> /dev/null || true
  630. fi
  631. hook_eval postdoc
  632. patchfiles="$saved_patchfiles"
  633. done
  634. if [ "$rmemptydir" ]; then
  635. rmdir $rmemptydir 2> /dev/null || true
  636. fi
  637. return 0
  638. }
  639. # [D] line regex:
  640. Dre='\([^:]*\):\([^ ]*\)[ ]\([^ ]*\)[ ]\(\([^ ]\)[^ ]*\)[ ]\([^ ]*\)'
  641. # \1: package-desc-path \2: '[D]'
  642. # \3: cksum \4: archive-file
  643. # \5: first-letter-of-archive-file \6: download-url
  644. # NODIST flag regex:
  645. NODISTre='[nN][oO][dD][iI][sS][tT]'
  646. # source_file cksum file url flags...
  647. #
  648. # Create the file path from 'file' and 'flags'.
  649. # cksum and url are ignored
  650. # ([D] tag compatible format)
  651. source_file() {
  652. local pre="" file="$2"
  653. shift; shift; shift
  654. # inside Build-Pkg $archdir is set
  655. if [ -n "$archdir" ]; then
  656. pre=$base/; file="$( echo $file | sed 's,.\(t\?\)\(gz\|Z\)$,.\1bz2,' )"
  657. fi
  658. if echo $* | egrep -q "($NODISTre)"; then
  659. echo ${pre}download/nodist/${file:0:1}/$file
  660. else
  661. echo ${pre}download/mirror/${file:0:1}/$file
  662. fi
  663. }