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.

153 lines
4.2 KiB

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