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.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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. svn_build_into)
  34. command="$1$command"
  35. [ "$#" -gt 0 ] && shift 1 && target="$1"
  36. ;;
  37. build_xmlstream)
  38. command="$1$command"
  39. [ "$#" -gt 0 ] && shift 1 && workfile="$1"
  40. [ "$#" -gt 0 ] && shift 1 && olang="$1"
  41. ;;
  42. tree_maker)
  43. command="$1$command"
  44. [ -n "$target" -o -n "$3" ] && shift 1 && tree="$1"
  45. shift 1; [ -n "$1" ] && target="$1"
  46. ;;
  47. process_file)
  48. command="$1$command"
  49. [ "$#" -gt 0 ] && shift 1 && workfile="$1"
  50. [ "$#" -gt 0 ] && shift 1 && processor="$1"
  51. [ "$#" -gt 0 ] && shift 1 && olang="$1"
  52. ;;
  53. map_tags)
  54. command="$1$command"
  55. shift 1
  56. break
  57. ;;
  58. sourceglobs)
  59. command="$1$command"
  60. [ "$#" -gt 0 ] && shift 1 && sourcesfile="$1"
  61. ;;
  62. lang_sources)
  63. command="$1$command"
  64. [ "$#" -gt 0 ] && shift 1 && sourceglobfile="$1"
  65. [ "$#" -gt 0 ] && shift 1 && lang="$1"
  66. ;;
  67. cast_refglobs)
  68. command="$1$command"
  69. [ "$#" -gt 0 ] && shift 1 && globfile="$1"
  70. [ "$#" -gt 0 ] && shift 1 && reffile="$1"
  71. ;;
  72. wakeup_news)
  73. command="$1$command"
  74. [ "$#" -gt 0 ] && shift 1 && today="$1"
  75. ;;
  76. *)
  77. print_error "Unknown option: $1"
  78. exit 1
  79. ;;
  80. esac
  81. [ "$#" -gt 0 ] && shift 1
  82. done
  83. olang="${olang:-en}"
  84. tree="${tree:-$basedir}"
  85. stagedir="${stagedir:-$target}"
  86. today="${today:-$(date +%F)}"
  87. readonly tree="${tree:+$(realpath "$tree")}"
  88. readonly stagedir="${stagedir:+$(realpath "$stagedir")}"
  89. readonly basedir="${basedir:+$(realpath "$basedir")}"
  90. readonly target="${target:+$(realpath "$target")}"
  91. readonly domain="${domain:-www.fsfe.org}"
  92. readonly command
  93. case "$command" in
  94. build_into) [ -z "$target" ] && die "Missing destination directory" ;;
  95. svn_build_into) [ -z "$target" ] && die "Missing destination directory" ;;
  96. process_file) [ -z "$workfile" ] && die "Need at least input file" ;;
  97. build_xmlstream) [ -z "$workfile" ] && die "Missing xhtml file name" ;;
  98. tree_maker) [ -z "$target" ] && die "Missing target location" ;;
  99. sourceglobs) [ -z "$sourcesfile" ] && die "Missing .sources file" ;;
  100. lang_sources) [ -z "$sourceglobfile" -o -z "$lang" ] && die "Need source globfile and language" ;;
  101. cast_refglobs) [ -z "$globfile" -o -z "$reffile" ] && die "Need globfile and reffile" ;;
  102. map_tags) true;;
  103. wakeup_news) true;;
  104. *help*) print_help; exit 0 ;;
  105. *) die "Urecognised command or no command given" ;;
  106. esac
  107. fi