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.

675 lines
18 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. # This function sets the 'confopt' and some other variables.
  124. # Re-run it in the package .conf file if you modify $prefix
  125. #
  126. set_confopt() {
  127. confopt="--prefix=$root/$prefix"
  128. bindir="$root/$prefix/bin"
  129. confopt="$confopt --bindir=\$bindir"
  130. sbindir="$root/$prefix/sbin"
  131. confopt="$confopt --sbindir=\$sbindir"
  132. libdir="$root/$prefix/lib"
  133. confopt="$confopt --libdir=\$libdir"
  134. if [ -z "$prefix" ]; then
  135. datadir="$root/usr/share"
  136. includedir="$root/usr/include"
  137. docdir="$root/usr/doc/$pkg"
  138. infodir="$root/usr/info"
  139. mandir="$oot/usr/man"
  140. else
  141. datadir="$root/$prefix/share"
  142. includedir="$root/$prefix/include"
  143. docdir="$root/$prefix/doc/$pkg"
  144. infodir="$root/$prefix/info"
  145. mandir="$root/$prefix/man"
  146. fi
  147. confopt="$confopt --datadir=\$datadir"
  148. confopt="$confopt --includedir=\$includedir"
  149. confopt="$confopt --infodir=\$infodir"
  150. confopt="$confopt --mandir=\$mandir"
  151. if [ "${prefix#opt/}" != "$prefix" ] ; then
  152. sysconfdir="$root/etc/$prefix"
  153. localstatedir="$root/var/$prefix"
  154. elif [ "${prefix#usr}" != "$prefix" ] ; then
  155. sysconfdir="$root/etc"
  156. localstatedir="$root/var"
  157. else
  158. sysconfdir="$root/$prefix/etc"
  159. localstatedir="$root/$prefix/var"
  160. fi
  161. confopt="$confopt --sysconfdir=\$sysconfdir"
  162. confopt="$confopt --localstatedir=\$localstatedir"
  163. if [ "$ROCKCFG_CONFIGURE_OPTS" ] ; then
  164. confopt="$confopt $ROCKCFG_CONFIGURE_OPTS"
  165. fi
  166. if [ "$ROCKCFG_OPT" = 1 ] ; then
  167. confopt="$confopt --disable-debug"
  168. fi
  169. if [ "$stagelevel" -le 1 -o "$ROCKCFG_DISABLE_NLS" = 1 ] ; then
  170. confopt="${confopt//--enable-nls/} --disable-nls"
  171. fi
  172. confopt="$confopt \$extraconfopt"
  173. if [ "$stagelevel" -eq 0 ]; then
  174. confopt="$confopt --target=\$arch_target --host=\$arch_build"
  175. else
  176. confopt="$confopt --build=\$arch_build --host=\$arch_target"
  177. fi
  178. }
  179. #
  180. # eval_config_command $( eval echo $confopt )
  181. #
  182. function eval_config_command() {
  183. local config_command
  184. for x in /usr/share/automake/*
  185. do
  186. [ -x "$x" -a -f "$x" ] || continue
  187. x="$( basename "$x" )"
  188. if [ -L $x -a ! -e $x ] ; then
  189. echo "Fixing dead symlink $x."
  190. ln -sf /usr/share/automake/$x .
  191. fi
  192. done
  193. if [ $autogen -eq 1 -a -f configure.in ] ; then
  194. if [ -f configure.orig ] ; then
  195. echo "Found configure.orig. Not" \
  196. "running autogen script."
  197. elif [ -f autogen.sh ] ; then
  198. echo "Running package autogen script."
  199. sh autogen.sh
  200. else
  201. echo "Running builtin autogen script."
  202. libtoolize --force --automake ; aclocal
  203. if grep AM_INIT_AUTOMAKE configure.in
  204. then automake ; fi
  205. autoconf
  206. fi
  207. fi
  208. if [ $stagelevel -le 1 ] ; then
  209. create_config_cache >> config.cache
  210. grep -q '.--cache-file=' $configscript &&
  211. set -- "$@" "--cache-file=config.cache"
  212. export cache_file=config.cache
  213. fi
  214. config_command="$configprefix $configscript"
  215. sub_scripts="$( find $( dirname $configscript ) -name configure )"
  216. # remove unsupported config script options
  217. for x ; do
  218. if grep -q "[[ ]${x%%=*}[]= ):]" $configscript $sub_scripts ; then
  219. config_command="$config_command $x"
  220. elif [[ $x = --*able-* ]] && egrep -q "\-\-(en|dis)able-\*" $configscript ; then
  221. echo "Autodetection for option impossible: " \
  222. "$x passed thru."
  223. config_command="$config_command $x"
  224. else
  225. echo "Removing unsupported '$x' from" \
  226. "configure option string."
  227. fi
  228. done
  229. echo Running "$config_command"
  230. eval "$config_command"
  231. }
  232. # run 'make check' if Makefile supports it.
  233. #
  234. function run_check() {
  235. if grep -q -e "^check:" ./Makefile; then
  236. echo "Running make check ..."
  237. $MAKE check
  238. fi
  239. if grep -q -e "^test:" ./Makefile; then
  240. echo "Running make test ..."
  241. $MAKE test
  242. fi
  243. }
  244. # move the static libs from lib to usr/lib and correct the libdir used
  245. # inside the .la file
  246. #
  247. postflist_static_lib() {
  248. echo_status "processing static lib corrections ..."
  249. egrep '^lib/.*\.(a|la)$' $builddir/flist.txt |
  250. while read fn ; do
  251. [ -e $root/$fn -o -L $root/$fn ] || continue
  252. if [[ $fn = *.a ]] ; then
  253. mv -fv $root/$fn $root/usr/$fn
  254. else
  255. sed "s,\([ =']\)/lib\(.*\),\1/usr/lib\2,g" \
  256. $root/$fn > $root/usr/$fn
  257. rm $root/$fn
  258. fi
  259. add_flist $root/usr/$fn
  260. done
  261. }
  262. # Parse the *.desc file. Use the description from PKG-DESC-FORMAT and
  263. # save the tag data in $desc_*.
  264. #
  265. parse_desc() {
  266. tag="`grep '^\[' $base/Documentation/Developers/PKG-DESC-FORMAT | \
  267. sed 's, (\*),,; s,\] \[,|,g; s,\[,,; s,\],,;'`"
  268. for tag in $tag ; do
  269. tagdata="`egrep "^\[($tag)\]" $confdir/$1.desc | \
  270. cut -f2- -d']' | sed 's,^ ,,'`"
  271. tag="`echo $tag | cut -f1 -d'|' | tr - _`"
  272. eval "desc_$tag=\"\$tagdata\""
  273. done
  274. }
  275. # This function is used for forcing a file to be in the flist
  276. #
  277. add_flist() {
  278. for addfile ; do
  279. echo "$addfile" | fl_wrparse -D -r "$xroot/" \
  280. >> $builddir/flist.txt
  281. done
  282. }
  283. # This function is used for forcing a package to be in the dependency list
  284. #
  285. add_dependency() {
  286. for addpackage ; do
  287. echo "$addpackage: add_dependency()" \
  288. >> $builddir/dependencies.debug
  289. done
  290. }
  291. # This function is used to subsitute some important variables
  292. # using a D_ prefix thru m4 ...
  293. rock_substitute() {
  294. sed -e s,D_prefix,$prefix,g -e s,D_sysconfdir,$sysconfdir,g \
  295. -e s,D_docdir,$docdir,g -e s,D_localstatedir,$localstatedir,g \
  296. -e s,D_datadir,$datadir,g -e s,D_infodir,$infodir,g \
  297. -e s,D_bindir,$bindir,g -e s,D_sbindir,$sbindir,g \
  298. -e s,D_libdir,$libdir,g -e s,D_mandir,$mandir,g $1
  299. }
  300. # This outputs a predefined config.cache file as it needed by some
  301. # packages to cross-build correctly in stages 0 and 1.
  302. #
  303. create_config_cache() {
  304. cat $base/scripts/config.cache
  305. echo -e "\n# Architecture specific stuff\n"
  306. echo "ac_cv_sizeof_short=$arch_sizeof_short"
  307. echo "ac_cv_sizeof_int=$arch_sizeof_int"
  308. echo "ac_cv_sizeof_long=$arch_sizeof_long"
  309. echo "ac_cv_sizeof_long_long=$arch_sizeof_long_long"
  310. echo "ac_cv_sizeof_char_p=$arch_sizeof_char_p"
  311. echo "ac_cv_c_bigendian=$arch_bigendian"
  312. echo "ac_cv_prog_CC=$CC"
  313. }
  314. # Abort build before actual build starts
  315. # (is overwritten in Build-Pkg)
  316. #
  317. abort() {
  318. echo -e "The package build aborted with the following config" \
  319. "error:\n$*" > $root/var/adm/logs/$stagelevel-$pkg.err
  320. echo_errorquote "`cat $root/var/adm/logs/$stagelevel-$pkg.err`"
  321. echo_pkg_abort $stagelevel $repository $pkg
  322. exit 1
  323. }
  324. # Dump Environment
  325. #
  326. dump_env() {
  327. # Dump $base - only set if there is not already an older value.
  328. #
  329. echo "base=\"\${base:-$base}\""
  330. # Dump all variables including their flags, but skip read-only
  331. # variables and $base.
  332. #
  333. # Substitute base directory with ${base}.
  334. #
  335. for name in ${!a*} ${!b*} ${!c*} ${!d*} ${!e*} ${!f*} ${!g*} ${!h*} \
  336. ${!i*} ${!j*} ${!k*} ${!l*} ${!m*} ${!n*} ${!o*} ${!p*} \
  337. ${!q*} ${!r*} ${!s*} ${!t*} ${!u*} ${!v*} ${!w*} ${!x*} \
  338. ${!y*} ${!z*} \
  339. ${!A*} ${!B*} ${!C*} ${!D*} ${!E*} ${!F*} ${!G*} ${!H*} \
  340. ${!I*} ${!J*} ${!K*} ${!L*} ${!M*} ${!N*} ${!O*} ${!P*} \
  341. ${!Q*} ${!R*} ${!S*} ${!T*} ${!U*} ${!V*} ${!W*} ${!X*} \
  342. ${!Y*} ${!Z*} ${!_*}
  343. do
  344. [ $name = base ] && continue
  345. if declare -p $name | head -1 | grep -qv '^declare -[a-z]*r'
  346. then
  347. declare -p $name | sed "s,\\(^\\|[\"=:]\\)$base\\([\"=:/]\\|\$\\),\\1\${base}\\2,g"
  348. fi
  349. done
  350. # Dump functions
  351. #
  352. declare -f | sed 's/^declare -f //; s/<<(/< <(/;'
  353. # Dump aliases
  354. #
  355. alias
  356. }
  357. # Check for a package in configuration
  358. #
  359. pkgcheck() {
  360. egrep -q "^$2.* ($1) " $base/config/$config/packages
  361. }
  362. # Register a window-manager
  363. #
  364. register_wm() {
  365. [ -e /usr/share/rock-registry/wm ] || mkdir -p $root/usr/share/rock-registry/wm
  366. echo -e "name=\"$2\"\nexec=\"$3\"\n" > $root/usr/share/rock-registry/wm/$1
  367. }
  368. # Register an application
  369. #
  370. register_application() {
  371. [ -e /usr/share/rock-registry/app ] \
  372. || mkdir -p /usr/share/rock-registry/app
  373. echo -e "name=\"$2\"\nexec=\"$3\"\n" > /usr/share/rock-registry/app/$1
  374. }
  375. # Create Package Database for gasgui install tool
  376. #
  377. create_package_db() {
  378. rm -f $3.tmp
  379. for file in $( ls -dr $1/descs/?* ) ; do
  380. pkg="${file##*/}"
  381. # only include the package if a binary file is available
  382. if [ "$ROCKCFG_PKGFILE_VER" = 1 ] ; then
  383. v=-$(grep '^Package Name and Version' \
  384. $1/packages/$pkg | cut -f6 -d' ')
  385. else
  386. v=""
  387. fi
  388. if [ "$ROCKCFG_CREATE_GEM" = 1 ] ; then
  389. bfile=${pkg}${v}.gem
  390. else
  391. bfile=${pkg}${v}.tar.bz2
  392. fi
  393. if [ -e $2/$bfile ] ; then
  394. [ "$pkg" = TRANS.TBL ] && continue
  395. ( echo -e "$pkg"
  396. echo -e "\027"
  397. cat $1/descs/$pkg
  398. echo -e "\027"
  399. cat $1/dependencies/$pkg
  400. echo -e "\027"
  401. cat $1/cksums/$pkg
  402. echo -e "\027"
  403. echo -e "\004"
  404. ) >> $3.tmp
  405. else
  406. echo_error "Binary file for $bfile not present." \
  407. "Skipped in package database."
  408. fi
  409. done
  410. gzip -c $3.tmp > $3 ; rm -f $3.tmp
  411. }
  412. # Add files to the 'badfiles' list
  413. #
  414. register_badfiles() {
  415. local x desc="$1"
  416. shift
  417. for x in "$@"; do
  418. var_append badfiles $'\n' " $x\$"
  419. badfiles_desc[$badfiles_nr]=" $x\$"$'\n'"$desc"
  420. (( badfiles_nr++ ))
  421. done
  422. }
  423. # Apply the given $patchfiles
  424. #
  425. apply_patchfiles() {
  426. for x in $patchfiles; do
  427. echo "Apply patch $x ..."
  428. if [[ $x = *.bz2 ]] ; then
  429. bzcat $x | patch $patchopt
  430. else
  431. patch $patchopt < $x
  432. fi
  433. done
  434. }
  435. # Main program for building a package
  436. #
  437. build_this_package() {
  438. if [ ".$desc_SRC" == "." ] ; then
  439. # Autodetect source tar and extract it
  440. #
  441. if [ $srctar = auto ] ; then
  442. xsourceballs=$( echo "$desc_D" | head -1 | tr ' ' '\t' | tr -s '\t' | \
  443. cut -f2 | sed 's,.\(t\?\)\(gz\|Z\)$,.\1bz2,' )
  444. if [ -z "$xsourceballs" ] ; then
  445. echo "Can't auto-detect srctar for package '$pkg'!"
  446. false
  447. fi
  448. else
  449. xsourceballs="$srctar"
  450. fi
  451. else
  452. sourceballs=$( echo "$desc_D" | tr ' ' '\t' | tr -s '\t' | \
  453. cut -f2 | sed 's,.\(t\?\)\(gz\|Z\)$,.\1bz2,' )
  454. xsrcpattern=$( echo "$desc_SRC" | tr ' ' '\t' | tr -s '\t' | tr '\t' '\n' )
  455. xsourceballs=$( echo "$sourceballs" | grep -F "$xsrcpattern" )
  456. fi
  457. for xsrctar in $xsourceballs; do
  458. if [ $autoextract = 1 ]; then
  459. echo "Extracting $xsrctar ($taropt) ... "
  460. cd $builddir
  461. tar -v $taropt $archdir/$xsrctar | tee untar.txt |
  462. cut -f1 -d/ | sort -u > xsrcdir.txt
  463. #
  464. if [ $srcdir = auto ]; then
  465. xsrcdir=${xsrctar%.tar.bz2}
  466. xsrcdir=${xsrcdir%.tbz2}
  467. if [ ! -d $xsrcdir ] ; then
  468. for x in $pkg-$ver $pkg_$ver $pkg \
  469. "`cat xsrcdir.txt`" ; do
  470. [ -d "$x" ] && xsrcdir="$x"
  471. done
  472. fi
  473. else
  474. xsrcdir="$srcdir"
  475. fi
  476. #
  477. if [ "$chownsrcdir" = 1 ]; then
  478. echo "Fixing ownership and permissions ..."
  479. chown -R 0.0 $builddir/$xsrcdir
  480. fi
  481. #
  482. if [ "$nocvsinsrcdir" = 1 ]; then
  483. echo "Removing CVS and .svn directories ..."
  484. egrep '(^|/)(CVS|\.svn)(/|$)' untar.txt |
  485. while read x; do
  486. echo "Removing $x ..."
  487. rm -rf "$x"
  488. done
  489. fi
  490. #
  491. echo "Changeing into $builddir/$xsrcdir ..."
  492. cd $builddir/$xsrcdir
  493. # Apply patches
  494. #
  495. if [ $autopatch = 1 ]; then
  496. hook_eval prepatch
  497. apply_patchfiles
  498. hook_eval postpatch
  499. fi
  500. else
  501. cd $builddir
  502. fi
  503. if [ "$createprefix" = 1 ]; then
  504. echo "Creating $root/$prefix/<..> if required ..."
  505. for x in $docdir $root/$prefix/bin $root/$prefix/lib \
  506. $root/$prefix/share $sysconfdir $localstatedir
  507. do
  508. if [ ! -e $x ]; then
  509. mkdir -p $x
  510. rmemptydir="$rmemptydir $x"
  511. fi
  512. done
  513. fi
  514. if [ ".$custmain" = "." ]
  515. then
  516. # Run configure scripts etc.
  517. #
  518. hook_eval preconf
  519. #
  520. if [ $runconf = 1 ]; then
  521. if [ -f $configscript -o $autogen = 1 ]
  522. then
  523. eval_config_command $( eval echo $confopt )
  524. fi
  525. fi
  526. # automated package build
  527. # styles without make run first:
  528. if [ -f setup.py -a $runpysetup = 1 ] ; then
  529. pyconfopt="${pyconfopt:=--prefix $root/$prefix}"
  530. eval python setup.py build install $pyconfopt
  531. else # styles that include a make run
  532. if [ ! -f Makefile -a ! -f makefile -a \
  533. -f Makefile.PL -a $runmkpl = 1 ]; then
  534. perl Makefile.PL
  535. fi
  536. #
  537. if [ ! -f Makefile -a ! -f makefile -a \
  538. -f Imakefile -a $runxmkmf = 1 ]; then
  539. xmkmf -a
  540. fi
  541. #
  542. # Build it
  543. #
  544. hook_eval premake
  545. if [ "$makeopt" ]
  546. then eval "$MAKE $makeopt"; fi
  547. hook_eval inmake
  548. if [ "$makeinstopt" ]
  549. then eval "$MAKE $makeinstopt"; fi
  550. hook_eval postmake
  551. fi
  552. else
  553. eval "$custmain"
  554. for x in preconf premake inmake postmake; do
  555. if eval "[ -n \"\$hookdirty_$x\" ]"; then
  556. echo "Hook $x is still marked as dirty ..."
  557. hook_eval $x
  558. fi
  559. done
  560. fi
  561. if [ "$createdocs" != 0 ]; then
  562. if [ ! -e $docdir ]; then
  563. mkdir -p $docdir
  564. rmemptydir="$rmemptydir $docdir"
  565. fi
  566. [ -z "$createdocs" ] && createdocs="$ROCKCFG_CREATE_DOCS"
  567. fi
  568. for file in $confdir/*.desktop ; do
  569. [ -f $file ] || continue
  570. echo -n "Install desktop file '$file': "
  571. mkdir -p $root/usr/share/rock-registry/app
  572. rock_substitute $file > \
  573. $root/usr/share/rock-registry/app/`basename $file`
  574. done
  575. if [ "$createdocs" = 1 ]; then
  576. echo "Trying to copy the default documentation ..."
  577. [ -d $builddir/$xsrcdir ] && cd $builddir/$xsrcdir
  578. for x in `find -type d \( -name 'doc' -o -name 'docs' -o \
  579. -name '[Dd]ocumentation' \) ! -empty`
  580. do
  581. if [ -d "$x" -a "`echo $x/*`" != "$x/*" ]
  582. then cp -rLv $x/* $docdir || true ; fi
  583. done
  584. for x in [A-Z][A-Z]* *.lsm ChangeLog*; do
  585. [ "${x#*.[cho0-9]}" ] || continue
  586. [ "${x#*.info*}" ] || continue
  587. if [ -f $x ] ; then cp -v $x $docdir/$x ; fi
  588. done
  589. for x in $confdir/*.doc; do
  590. if [ -f $x ]; then cp -v $x $docdir/${x%.doc}; fi
  591. done
  592. find $docdir/ -name '*.[0-9]' -o -name '*.info*' \
  593. -o -name '[Mm]akefile*' | \
  594. xargs -r rm -f 2> /dev/null || true
  595. find $docdir/* -type d -empty 2> /dev/null | \
  596. xargs -r rmdir 2> /dev/null || true
  597. fi
  598. hook_eval postdoc
  599. done
  600. if [ "$rmemptydir" ]; then
  601. rmdir $rmemptydir 2> /dev/null || true
  602. fi
  603. return 0
  604. }