PageRenderTime 40ms CodeModel.GetById 11ms RepoModel.GetById 0ms app.codeStats 0ms

/fw/bin/fw-init.in

http://fwtemplates.googlecode.com/
Autoconf | 186 lines | 115 code | 38 blank | 33 comment | 28 complexity | 08bdd9a62fbe658ac5914a8e99fc9179 MD5 | raw file
Possible License(s): BSD-3-Clause, MPL-2.0-no-copyleft-exception
  1. #! /bin/sh
  2. #---------------------------------------------------------------------
  3. # chicken and egg
  4. #---------------------------------------------------------------------
  5. which perl >/dev/null 2>/dev/null || {
  6. echo "fw-init: fatal: can't locate perl" 1>&2
  7. exit 1
  8. }
  9. if test -z "${FW_ROOT}"
  10. then
  11. FW_ROOT=`echo "$0" | perl -pe 's%bin//?fw-init$%%;'`
  12. export FW_ROOT
  13. fi
  14. test -f "${FW_ROOT}/share/fw/sh/fw-find.sh" || {
  15. echo "fw-init: fatal: can't determine FW_ROOT" 1>&2
  16. echo "fw-init; fatal: please set the environment variable" 1>&2
  17. exit 1
  18. }
  19. . "${FW_ROOT}/share/fw/sh/fw-find.sh"
  20. #---------------------------------------------------------------------
  21. # routines
  22. #---------------------------------------------------------------------
  23. fw_source "fw-init" "sh/fatal.sh"
  24. fw_source "fw-init" "sh/fw-exec.sh"
  25. fw_source "fw-init" "sh/parse-args.sh"
  26. fw_source "fw-init" "sh/validate-args.sh"
  27. base_initialize () \
  28. {
  29. local maintainer
  30. local who
  31. local where
  32. fw_exec "revision/$revision/init" "$@" || fatal "fw-init"
  33. cd "$name" || fatal "fw-init"
  34. ln -sf "${FW_ROOT}/share/fw" . || fatal "fw-init"
  35. fw_exec "revision/$revision/ignore-files" fw || fatal "fw-init"
  36. test -z "$localize" || test ! -e "${FW_ROOT}/share/fw.local" || (
  37. dir=`pwd`
  38. cd ${FW_ROOT}/share/
  39. find "fw.local" -print | cpio -pvd "$dir"
  40. ) || fatal "fw-init"
  41. cat > bootstrap <<EOD || fatal "fw-init"
  42. #! /bin/sh
  43. if test -d fw/bin
  44. then
  45. PATH="\`pwd\`/fw/bin:\$PATH"
  46. export PATH
  47. fi
  48. fwb=\`which fw-bootstrap\`
  49. if test -z "\$fwb"
  50. then
  51. echo "bootstrap: fatal: fw-bootstrap not installed or not in PATH" 1>&2
  52. exit 1
  53. fi
  54. "\$fwb" --fw_version "@PACKAGE_VERSION@" $@ "\$@"
  55. EOD
  56. chmod +x bootstrap || fatal "fw-init"
  57. fw_exec "revision/$revision/add-files" bootstrap || fatal "fw-init"
  58. mkdir fw-pkgin || fatal "fw-init"
  59. fw_exec "revision/$revision/add-dir" fw-pkgin || fatal "fw-init"
  60. (
  61. cd fw-pkgin || exit 1
  62. cat <<EOD > config || exit 1
  63. # The FW_PACKAGE_MAINTAINER field is populated with the environment
  64. # variable FW_PACKAGE_DEFAULT_MAINTAINER if non-empty at init time
  65. FW_PACKAGE_NAME="$name"
  66. FW_PACKAGE_VERSION="0.0.0"
  67. FW_PACKAGE_MAINTAINER="${FW_PACKAGE_DEFAULT_MAINTAINER:="`whoami` <`whoami`@`hostname`>"}"
  68. FW_PACKAGE_SHORT_DESCRIPTION="A short description."
  69. FW_PACKAGE_DESCRIPTION=\`cat README\`
  70. FW_PACKAGE_ARCHITECTURE_DEPENDENT="1"
  71. # Dependency information. The native syntax corresponds to Debian,
  72. # http://www.debian.org/doc/debian-policy/ch-relationships.html
  73. # Section 7.1 "Syntax of Relationship Fields"
  74. #
  75. # For other packaging systems, the syntax is translated for you.
  76. FW_PACKAGE_DEPENDS=""
  77. FW_PACKAGE_CONFLICTS=""
  78. FW_PACKAGE_PROVIDES=""
  79. FW_PACKAGE_REPLACES=""
  80. FW_PACKAGE_SUGGESTS=""
  81. FW_PACKAGE_BUILD_DEPENDS=""
  82. FW_PACKAGE_BUILD_CONFLICTS=""
  83. # dupload is used for submitting debian packages to a package archive
  84. # The FW_DUPLOAD_ARGS field is populated with the environment variable
  85. # FW_DEFAULT_DUPLOAD_ARGS if non-empty at init time
  86. FW_DUPLOAD_ARGS=\${FW_DUPLOAD_ARGS-"${FW_DEFAULT_DUPLOAD_ARGS:="-q"}"}
  87. # scp+createrepo is used for submitting rpm packages to a package archive
  88. # The FW_RPM_REPO_USER, FW_RPM_REPO_HOST, FW_RPM_REPO_BASEDIR,
  89. # and FW_RPM_POSTCREATEREPO_COMMANDS variables are populated with
  90. # FW_RPM_REPO_USER_DEFAULT, FW_RPM_REPO_HOST_DEFAULT,
  91. # FW_RPM_REPO_BASEDIR_DEFAULT, and FW_RPM_POSTCREATEREPO_COMMANDS_DEFAULT
  92. # respectively if non-empty at init time
  93. FW_RPM_REPO_USER=\${FW_RPM_REPO_USER-"${FW_RPM_REPO_USER_DEFAULT:=\`whoami\`}"}
  94. FW_RPM_REPO_HOST=\${FW_RPM_REPO_HOST-"${FW_RPM_REPO_HOST_DEFAULT:=localhost}"}
  95. FW_RPM_REPO_BASEDIR=\${FW_RPM_REPO_BASEDIR-"${FW_RPM_REPO_BASEDIR_DEFAULT}"}
  96. FW_RPM_CREATEREPO_ARGS=\${FW_RPM_CREATEREPO_ARGS-"${FW_RPM_CREATEREPO_ARGS_DEFAULT:="-q --database"}"}
  97. # this variable controls whether createrepo is run incrementally (--update).
  98. # possible settings are yes (always do it), no (never do it), and
  99. # auto (do it if the repository has been previously initialized)
  100. FW_RPM_CREATEREPO_INCREMENTAL=\${FW_RPM_CREATEREPO_INCREMENTAL-"auto"}
  101. # these commands will be run after a successful createrepo run
  102. FW_RPM_POSTCREATEREPO_COMMANDS=\${FW_RPM_POSTCREATEREPO_COMMANDS-"${FW_RPM_POSTCREATEREPO_COMMANDS_DEFAULT:="true"}"}
  103. # here's a suggestion:
  104. # FW_RPM_POSTCREATEREPO_COMMANDS="gpg --detach-sign --armor repodata/repomd.xml"
  105. EOD
  106. for x in post-install \
  107. post-remove \
  108. pre-install \
  109. pre-remove \
  110. start \
  111. stop
  112. do
  113. fw_find "build/automake/fw-pkgin/$x" file
  114. test -z "$file" && exit 1
  115. cp -f "$file" . || exit 1
  116. chmod +w "$x" || exit 1
  117. done
  118. fw_exec "revision/$revision/add-files" config \
  119. post-install \
  120. post-remove \
  121. pre-install \
  122. pre-remove \
  123. start \
  124. stop
  125. ) || fatal "fw-init"
  126. fw_find "revision/$revision/init-fw-pkgin-config" file
  127. test -z "$file" || {
  128. "$file" "$@" || fatal "fw-init"
  129. }
  130. }
  131. run_init () \
  132. {
  133. fw_exec "template/$template/init" "$@" || {
  134. echo "fw-init: error: init failed" 1>&2
  135. fatal "fw-init"
  136. }
  137. }
  138. #---------------------------------------------------------------------
  139. # main
  140. #---------------------------------------------------------------------
  141. parse_args "fw-init" "$@"
  142. test -z "$help" || {
  143. echo "usage: fw-init [ --trace ] --name name --revision revision --template template [ template specific args ... ] " 1>&2
  144. exit 0
  145. }
  146. validate_args "fw-init" "name revision template" "revision template"
  147. base_initialize "$@"
  148. run_init "$@"