OpenSDE Packages Database (without history before r20070)
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.

152 lines
4.1 KiB

  1. #!/bin/sh
  2. # --- T2-COPYRIGHT-NOTE-BEGIN ---
  3. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  4. #
  5. # T2 SDE: package/.../runit/parse-config
  6. # Copyright (C) 2004 - 2006 The T2 SDE Project
  7. # Copyright (C) 1998 - 2003 Clifford Wolf
  8. #
  9. # More information can be found in the files COPYING and README.
  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; version 2 of the License. A copy of the
  14. # GNU General Public License can be found in the file COPYING.
  15. # --- T2-COPYRIGHT-NOTE-END ---
  16. #
  17. # prepare root links for DJB filesystem hierarchy inside chrooted env.
  18. #
  19. if [ "$SDECFG_PKG_DJB_LAYOUT" == "1" ]; then
  20. for x in package command service; do
  21. eval "pkg_djb_${x}dir='$x'"
  22. var_append flistroot ' ' $x
  23. done
  24. #pkg_djb_compatdir="usr/local/bin"
  25. elif [ "$SDECFG_PKG_DJB_LAYOUT" == "0" ]; then
  26. pkg_djb_packagedir=""
  27. pkg_djb_commanddir=""
  28. pkg_djb_servicedir="var/service"
  29. #pkg_djb_compatdir=""
  30. fi
  31. # package
  32. if [ "$pkg_djb_packagedir" ]; then
  33. mkdir -p $xroot/$pkg_djb_packagedir
  34. chmod 1755 $xroot/$pkg_djb_packagedir
  35. pkg_djb_packagedir=$root/$pkg_djb_packagedir
  36. fi
  37. # service
  38. if [ "$pkg_djb_servicedir" ]; then
  39. mkdir -p $xroot/$pkg_djb_servicedir
  40. chmod 1755 $xroot/$pkg_djb_servicedir
  41. pkg_djb_servicedir=$root/$pkg_djb_servicedir
  42. fi
  43. # command
  44. if [ "$pkg_djb_commanddir" ]; then
  45. mkdir -p $xroot/$pkg_djb_commanddir
  46. pkg_djb_commanddir=$root/$pkg_djb_commanddir
  47. fi
  48. #
  49. # add init scripts
  50. #
  51. if pkginstalled runit; then
  52. # runit_substitute
  53. #
  54. runit_substitute() {
  55. local logdir
  56. if [ "${localstatedir%$pkg}" != "$localstatedir" ]; then
  57. logdir=$localstatedir/log
  58. else
  59. logdir=$localstatedir/log/$pkg
  60. fi
  61. sed -e "s,D_logdir,$logdir,g" $1
  62. }
  63. # runit_tail_prepare /foo/bar/$pkg-$service.tail
  64. #
  65. runit_tail_prepare() {
  66. local tailfile=$1 pkg=$2
  67. local service=` echo $tailfile | sed -e "s,^.*/$pkg-,," -e "s,\.tail\$,," -e "s,_,/,g"`
  68. local servicedir=
  69. if [ "${service#runit-}" != "$service" ]; then
  70. servicedir=\$root/etc/runit/${service#runit-}
  71. else
  72. servicedir=\$root\$sysconfdir/$service
  73. fi
  74. echo_status "runit: Setting conf to install ${servicedir#\$root}/ (TAIL)"
  75. hook_add postdoc 5 "tail_install runit '$tailfile' '$servicedir'"
  76. }
  77. runitconfdir=$base/package/*/runit
  78. runit_has_script=0
  79. for x in $( ls -1 $runitconfdir/packages/$pkg-*.tail 2> /dev/null ); do
  80. runit_tail_prepare $x $pkg
  81. runit_has_script=1
  82. done
  83. for x in $( cd $runitconfdir/packages; ls -1 $pkg-*.txt 2> /dev/null ); do
  84. y=${x#$pkg-}; y=${y%.txt}; y=${y//_/\/}
  85. if [ "${y#runit-}" != "$y" ]; then
  86. y=\$root/etc/runit/${y#runit-}
  87. else
  88. y=\$root/\$sysconfdir/$y
  89. fi
  90. echo_status "runit: Setting conf to install $y"
  91. runit_has_script=1
  92. case "${y##*/}" in
  93. run|finish) runitxmode=1 ;;
  94. *) runitxmode= ;;
  95. esac
  96. hook_add postmake 8 "mkdir -p ${y%/*}; \
  97. ${runitxmode:+chmod 755 ${y%/*};} \
  98. cat $runitconfdir/packages/$x | rock_substitute \
  99. | runit_substitute > $y; \
  100. ${runitxmode:+chmod 755 $y;}"
  101. done
  102. if [ "$SDECFG_INIT" == "runit" ]; then
  103. if [ $runit_has_script -eq 1 ]; then
  104. install_init() {
  105. # i have already installed the script
  106. true
  107. }
  108. else
  109. install_init() {
  110. name=$1 ; file=$2 ; initdir="$root/etc/rc.d"
  111. echo -n "Install SysV Init script '$name' (xx/xx): "
  112. m4 -Dinitstyle=$SDECFG_INIT_STYLE \
  113. -D"D_prefix=/$prefix" -D"D_sysconfdir=$sysconfdir" \
  114. -D"D_docdir=$docdir" -D"D_localstatedir=$localstatedir" \
  115. -D"D_datadir=$datadir" -D"D_infodir=$infodir" \
  116. -D"D_bindir=$bindir" -D"D_sbindir=$sbindir" \
  117. -D"D_libdir=$libdir" -D"D_mandir=$mandir" \
  118. $base/package/base/sysvinit/init_macros.m4 \
  119. $file > $initdir/init.d/$name
  120. chmod +x $initdir/init.d/$name
  121. echo " done."
  122. }
  123. fi
  124. fi
  125. unset runitconfdir runitxmode runit_has_script
  126. # minimal services
  127. case "$pkg" in
  128. cron)
  129. hook_add postmake 9 'ln -svnf /etc/runit/cron $pkg_djb_servicedir/cron'
  130. ;;
  131. sysklogd)
  132. hook_add postmake 9 'ln -svnf /etc/runit/syslogd $pkg_djb_servicedir/syslogd'
  133. hook_add postmake 9 'ln -svnf /etc/runit/klogd $pkg_djb_servicedir/klogd'
  134. ;;
  135. esac
  136. fi