Source files of fsfe.org, pdfreaders.org, freeyourandroid.org, ilovefs.org, drm.info, and test.fsfe.org. Contribute: https://fsfe.org/contribute/web/
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.

arguments.sh 3.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. #!/bin/sh
  2. [ -z "$inc_misc" ] && . "$basedir/build/misc.sh"
  3. if [ -z "$inc_arguments" ]; then
  4. inc_arguments=true
  5. basedir="$(realpath "${0%/*}/..")"
  6. while [ "$#" -gt 0 ]; do
  7. case "$1" in
  8. --legacyglobs)
  9. readonly legacyglobs=true
  10. ;;
  11. -s|--statusdir|--status-dir)
  12. [ "$#" -gt 0 ] && shift 1 && statusdir="$1"
  13. ;;
  14. --domain)
  15. [ "$#" -gt 0 ] && shift 1 && domain="$1"
  16. ;;
  17. --source)
  18. [ "$#" -gt 0 ] && shift 1 && basedir="$1"
  19. ;;
  20. --stage|--stagedir)
  21. [ "$#" -gt 0 ] && shift 1 && stagedir="$1"
  22. ;;
  23. -d|--dest|--destination)
  24. [ "$#" -gt 0 ] && shift 1 && target="$1"
  25. ;;
  26. -h|--help)
  27. command="help"
  28. ;;
  29. build_into)
  30. command="$1$command"
  31. [ "$#" -gt 0 ] && shift 1 && target="$1"
  32. ;;
  33. git_build_into)
  34. command="$1$command"
  35. [ "$#" -gt 0 ] && shift 1 && target="$1"
  36. ;;
  37. svn_build_into)
  38. command="$1$command"
  39. [ "$#" -gt 0 ] && shift 1 && target="$1"
  40. ;;
  41. build_xmlstream)
  42. command="$1$command"
  43. [ "$#" -gt 0 ] && shift 1 && workfile="$1"
  44. [ "$#" -gt 0 ] && shift 1 && olang="$1"
  45. ;;
  46. tree_maker)
  47. command="$1$command"
  48. [ -n "$target" -o -n "$3" ] && shift 1 && tree="$1"
  49. shift 1; [ -n "$1" ] && target="$1"
  50. ;;
  51. process_file)
  52. command="$1$command"
  53. [ "$#" -gt 0 ] && shift 1 && workfile="$1"
  54. [ "$#" -gt 0 ] && shift 1 && processor="$1"
  55. [ "$#" -gt 0 ] && shift 1 && olang="$1"
  56. ;;
  57. map_tags)
  58. command="$1$command"
  59. shift 1
  60. break
  61. ;;
  62. sourceglobs)
  63. command="$1$command"
  64. [ "$#" -gt 0 ] && shift 1 && sourcesfile="$1"
  65. ;;
  66. lang_sources)
  67. command="$1$command"
  68. [ "$#" -gt 0 ] && shift 1 && sourceglobfile="$1"
  69. [ "$#" -gt 0 ] && shift 1 && lang="$1"
  70. ;;
  71. cast_refglobs)
  72. command="$1$command"
  73. [ "$#" -gt 0 ] && shift 1 && globfile="$1"
  74. [ "$#" -gt 0 ] && shift 1 && reffile="$1"
  75. ;;
  76. wakeup_news)
  77. command="$1$command"
  78. [ "$#" -gt 0 ] && shift 1 && today="$1"
  79. ;;
  80. *)
  81. print_error "Unknown option: $1"
  82. exit 1
  83. ;;
  84. esac
  85. [ "$#" -gt 0 ] && shift 1
  86. done
  87. olang="${olang:-en}"
  88. tree="${tree:-$basedir}"
  89. stagedir="${stagedir:-$target}"
  90. today="${today:-$(date +%F)}"
  91. readonly tree="${tree:+$(realpath "$tree")}"
  92. readonly stagedir="${stagedir:+$(realpath "$stagedir")}"
  93. readonly basedir="${basedir:+$(realpath "$basedir")}"
  94. readonly domain="${domain:-www.fsfe.org}"
  95. readonly command
  96. if [ "$stagedir" != "$target" ] && printf %s "$target" |egrep -q '^.+@.+:(.+)?$'; then
  97. readonly target
  98. else
  99. readonly target="${target:+$(realpath "$target")}"
  100. fi
  101. case "$command" in
  102. build_into) [ -z "$target" ] && die "Missing destination directory" ;;
  103. git_build_into) [ -z "$target" ] && die "Missing destination directory" ;;
  104. svn_build_into) [ -z "$target" ] && die "Missing destination directory" ;;
  105. process_file) [ -z "$workfile" ] && die "Need at least input file" ;;
  106. build_xmlstream) [ -z "$workfile" ] && die "Missing xhtml file name" ;;
  107. tree_maker) [ -z "$target" ] && die "Missing target location" ;;
  108. sourceglobs) [ -z "$sourcesfile" ] && die "Missing .sources file" ;;
  109. lang_sources) [ -z "$sourceglobfile" -o -z "$lang" ] && die "Need source globfile and language" ;;
  110. cast_refglobs) [ -z "$globfile" -o -z "$reffile" ] && die "Need globfile and reffile" ;;
  111. map_tags) true;;
  112. wakeup_news) true;;
  113. *help*) print_help; exit 0 ;;
  114. *) die "Urecognised command or no command given" ;;
  115. esac
  116. fi