reGen2 Linux Release Metatool
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.

92 lines
2.7 KiB

  1. #!/bin/bash
  2. #-------------------------------------------------------------------------------
  3. # Checks whether a supplied variable is defined or not
  4. # Parameters: %variable%
  5. #-------------------------------------------------------------------------------
  6. function isDefined() {
  7. [[ ${!1-X} == ${!1-Y} ]]
  8. }
  9. #-------------------------------------------------------------------------------
  10. # Checks whether a supplied variable is enabled or not
  11. # Parameters: %variable%
  12. #-------------------------------------------------------------------------------
  13. function isEnabled() {
  14. case "${1}" in
  15. [Ee][Nn][Aa][Bb][Ll][Ee][Dd])
  16. return 0
  17. ;;
  18. [Tt][Rr][Uu][Ee])
  19. return 0
  20. ;;
  21. [Yy][Ee][Ss])
  22. return 0
  23. ;;
  24. 1)
  25. return 0
  26. ;;
  27. esac
  28. return 1
  29. }
  30. #-------------------------------------------------------------------------------
  31. # Checks whether a variable is defined and if value's length > 0
  32. # Parameters: %variable%
  33. #-------------------------------------------------------------------------------
  34. function isSet() {
  35. if isDefined ${1}; then
  36. if [[ -n ${!1} ]]; then
  37. return 0
  38. fi
  39. fi
  40. return 1
  41. }
  42. #-------------------------------------------------------------------------------
  43. # Loads EzBuild configuration
  44. #-------------------------------------------------------------------------------
  45. function loadConfiguration() {
  46. source ${EZROOT}/config/${EZNAME}.conf
  47. source ${EZROOT}/config/layout.conf
  48. source /etc/ezbuild/${EZNAME}.conf
  49. source /etc/ezbuild/layout.conf
  50. }
  51. #-------------------------------------------------------------------------------
  52. # Loads all EzBuild Libraries
  53. #-------------------------------------------------------------------------------
  54. function loadLibraries() {
  55. source ${EZROOT}/libraries/colors
  56. }
  57. #-------------------------------------------------------------------------------
  58. # Returns a UNIX timestamp
  59. #-------------------------------------------------------------------------------
  60. function timestamp() {
  61. echo $(date +%s)
  62. }
  63. #-------------------------------------------------------------------------------
  64. # Returns lowercase string
  65. # Parameters: %string%
  66. #-------------------------------------------------------------------------------
  67. function toLower() {
  68. echo "${@}" | tr '[:upper:]' '[:lower:]'
  69. }
  70. #-------------------------------------------------------------------------------
  71. # Returns uppercase string
  72. # Parameters: %string%
  73. #-------------------------------------------------------------------------------
  74. function toUpper() {
  75. echo "${@}" | tr '[:lower:]' '[:upper:]'
  76. }
  77. #-------------------------------------------------------------------------------
  78. # Returns only the first part of a string, delimited by tabs or spaces
  79. # Parameters: %string%
  80. #-------------------------------------------------------------------------------
  81. function trim() {
  82. echo ${1}
  83. }