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.

36 lines
698 B

  1. #!/bin/bash
  2. if [ $# -ne 3 ]; then
  3. echo "Usage: $0 <application> <template_source_dir> <SPEC_dir>"
  4. exit 1
  5. fi
  6. app=$1
  7. src=$2
  8. dst=$3
  9. # Find spectemplate
  10. if [ ! -f "$src/$app.spec" ]; then
  11. if [ ! -f "$src/app-template.spec" ]; then
  12. echo "Source template not found."
  13. exit 1
  14. else
  15. srcfile="$src/app-template.spec"
  16. fi
  17. else
  18. srcfile="$src/$app.spec"
  19. fi
  20. # Copy spectemplate to SPECS
  21. cp "$srcfile" "$dst/$app.spec"
  22. # Apply any variables defined in .data
  23. if [ -f "$src/$app.data" ]; then
  24. srcdata="$src/$app.data"
  25. source "$srcdata"
  26. for var in `grep -v -e ^# -e ^\s*$ "$srcdata" | grep = | sed 's/\s*=.*$//'`
  27. do
  28. sed -i "s\\@${var}@\\${!var}\\g" "$dst/$app.spec"
  29. done
  30. fi