create-qt-repository.sh 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. #!/bin/bash
  2. SCRIPT_DIR=$(cd $(dirname $0); pwd)
  3. set -e
  4. usage()
  5. {
  6. cat << EOF
  7. usage: $0 options
  8. This script will create Qt Tizen repository for Qt online installer
  9. OPTIONS:
  10. -h Show this message
  11. -i DIR Path to install directory
  12. -c c1,c2,c3 component names for tizen installer
  13. -r r1,r2,r3 relative directories name e.g. tizen_x86 (Qt will be installed under /path/to/qt/install/dir/QtVersion/RELATIVE_DIR)
  14. -o DIR output repository dir
  15. example:
  16. $0 -i /path/to/target/install/dir -c qt.tools.qtcreator.tizen,qt.54.tizen_x86 -r Tools,tizen_x86 -o /path/to/repository/dir/which/will/be/created/or/updated
  17. EOF
  18. }
  19. installPath=""
  20. componentNames=""
  21. relativeDirs=""
  22. outputDir=""
  23. while getopts ":hi:c:r:o:" opt; do
  24. case $opt in
  25. h)
  26. usage
  27. exit
  28. ;;
  29. i)
  30. installPath="$OPTARG"
  31. ;;
  32. c)
  33. componentNames="$OPTARG"
  34. ;;
  35. r)
  36. relativeDirs="$OPTARG"
  37. ;;
  38. o)
  39. outputDir="$OPTARG"
  40. ;;
  41. ?)
  42. echo "Invalid option: -$OPTARG"
  43. usage
  44. exit
  45. ;;
  46. esac
  47. done
  48. doExit=""
  49. if [ "$installPath" = "" ]; then
  50. echo "No install path set. Provide install path with -i parameter"
  51. doExit="1"
  52. fi
  53. if [ "$componentNames" = "" ]; then
  54. echo "No component names set. Provide component names with -c parameter"
  55. doExit="1"
  56. fi
  57. if [ "$relativeDirs" = "" ]; then
  58. echo "No reative dirs set. Provide relative dirs with -r parameter"
  59. doExit="1"
  60. fi
  61. if [ "$outputDir" = "" ]; then
  62. echo "No output dir set. Provide output dir with -o parameter"
  63. doExit="1"
  64. fi
  65. if [ "$doExit" = "1" ]; then
  66. exit 1
  67. fi
  68. tmpComponentDir=$(mktemp -d)
  69. function createComponent() {
  70. if [ "$2" != "qt.tools.qtcreator.tizen" ]; then
  71. targetDir=$($1/bin/qmake -query QT_VERSION | grep -o "^[0-9]\+\.[0-9]\+")
  72. else
  73. targetDir=""
  74. fi
  75. installDir=$1
  76. relativeDir=$(basename $installDir)
  77. componentName=$2
  78. tmpComponentPartDir="$tmpComponentDir/$componentName"
  79. mkdir -p $tmpComponentPartDir/data $tmpComponentPartDir/meta
  80. export PATH=~/Qt/QtIFW-1.5.0/bin/:$PATH
  81. mkdir -p $tmpComponentPartDir/data/$targetDir/$relativeDir
  82. cp -r $installDir/* $tmpComponentPartDir/data/$targetDir/$relativeDir
  83. echo "archiving $componentName"
  84. archivegen $tmpComponentPartDir/data/$componentName.7z $tmpComponentPartDir/data/${targetDir:-$relativeDir}
  85. displayName=$(echo $componentName | grep -oi "tizen.*" | tr '_' ' ' )
  86. displayName=${displayName^}
  87. releaseDate=$(date "+%Y-%m-%d")
  88. if [ "$2" = "qt.tools.qtcreator.tizen" ]; then
  89. cat $SCRIPT_DIR/../common/qtrepositoryfiles/package-qtcreator.xml | sed "s/@ComponentName@/$componentName/g" \
  90. | sed "s/@ReleaseDate@/$releaseDate/g" \
  91. > $tmpComponentPartDir/meta/package.xml
  92. else
  93. relativePath="/$targetDir/$relativeDir"
  94. cat $SCRIPT_DIR/../common/qtrepositoryfiles/package-qt.xml | sed "s/@ComponentName@/$componentName/g" \
  95. | sed "s/@DisplayName@/$displayName/g" \
  96. | sed "s/@ReleaseDate@/$releaseDate/g" \
  97. > $tmpComponentPartDir/meta/package.xml
  98. cat $SCRIPT_DIR/../common/qtrepositoryfiles/installscript-qt.qs | sed "s#@RelativePath@#$relativePath#g" \
  99. | sed "s/@DisplayName@/$displayName/g" \
  100. > $tmpComponentPartDir/meta/installscript.qs
  101. fi
  102. rm -rf $tmpComponentPartDir/data/${targetDir:-$relativeDir}
  103. }
  104. echo "Generating repositories"
  105. componentNamesArray=($(echo $componentNames | tr ',' ' '))
  106. relativeDirsArray=($(echo $relativeDirs | tr ',' ' '))
  107. for index in ${!componentNamesArray[*]}
  108. do
  109. createComponent $installPath/${relativeDirsArray[index]} ${componentNamesArray[index]}
  110. done
  111. repogen -v -p $tmpComponentDir -i $componentNames --update $outputDir
  112. echo repository created in $outputDir