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.

101 lines
3.2 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 &> /dev/null || panic
  47. source ${EZROOT}/config/layout.conf &> /dev/null || panic
  48. source /etc/ezbuild/${EZNAME}.conf &> /dev/null || panic
  49. source /etc/ezbuild/layout.conf &> /dev/null || panic
  50. }
  51. #-------------------------------------------------------------------------------
  52. # Loads all EzBuild Libraries
  53. #-------------------------------------------------------------------------------
  54. function loadLibraries() {
  55. source ${EZROOT}/libraries/colors &> /dev/null || panic
  56. }
  57. #-------------------------------------------------------------------------------
  58. # Outputs error message and aborts program execution
  59. #-------------------------------------------------------------------------------
  60. function panic() {
  61. echo -e "FATAL ERROR: Unable to load necessary files!"
  62. echo -e "Your EzBuild installation seems to be broken..."
  63. exit 1
  64. }
  65. #-------------------------------------------------------------------------------
  66. # Returns a UNIX timestamp
  67. #-------------------------------------------------------------------------------
  68. function timestamp() {
  69. echo $(date +%s)
  70. }
  71. #-------------------------------------------------------------------------------
  72. # Returns lowercase string
  73. # Parameters: %string%
  74. #-------------------------------------------------------------------------------
  75. function toLower() {
  76. echo "${@}" | tr '[:upper:]' '[:lower:]'
  77. }
  78. #-------------------------------------------------------------------------------
  79. # Returns uppercase string
  80. # Parameters: %string%
  81. #-------------------------------------------------------------------------------
  82. function toUpper() {
  83. echo "${@}" | tr '[:lower:]' '[:upper:]'
  84. }
  85. #-------------------------------------------------------------------------------
  86. # Returns only the first part of a string, delimited by tabs or spaces
  87. # Parameters: %string%
  88. #-------------------------------------------------------------------------------
  89. function trim() {
  90. echo ${1}
  91. }