run.sh 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. #!/usr/bin/env bash
  2. ## Validate variables
  3. # $SOURCES_VERSION
  4. # $RELEASE_NUMBER
  5. # $SPEC_FILE
  6. # $OVERRIDE_VERSION_TO_LATEST
  7. # $CCACHE_LINKS_PATH
  8. # $OVERRIDE_PATH
  9. # $ALTERNATE_PATH
  10. #PATH=$CCACHE_PATH:$PATH
  11. #export PATH
  12. echo "Printing original environmental variables:"
  13. env
  14. echo "End of variables"
  15. case $ENABLE_CCACHE in
  16. false)
  17. echo "disabling ccache usage"
  18. USE_CCACHE=0
  19. ;;
  20. *)
  21. echo "using default ccache usage"
  22. # USE_CCACHE=1
  23. esac
  24. echo -n "USE_CCACHE="
  25. echo $USE_CCACHE
  26. case $CLEAR_CCACHE in
  27. true)
  28. echo "Clearing ccache data"
  29. /usr/bin/ccache -C
  30. ;;
  31. *)
  32. echo "ccache was not cleared"
  33. esac
  34. echo -n "Environment PATH => "
  35. echo $PATH
  36. export PATH=$CCACHE_LINKS_PATH:$PATH
  37. echo -n "Modifed Environment PATH => "
  38. echo $PATH
  39. gcc -v
  40. case $OVERRIDE_PATH in
  41. true)
  42. echo "Using the build parameters PATH"
  43. PATH=$ALTERNATE_PATH
  44. export PATH
  45. echo -n "Modifed Environment PATH => "
  46. echo $PATH
  47. gcc -v
  48. ;;
  49. *)
  50. echo "Using default PATH"
  51. esac
  52. # Clean up and create directories
  53. for dir in BUILD RPMS SRPMS
  54. do
  55. [[ -d $dir ]] && rm -Rf $dir
  56. mkdir $dir
  57. done
  58. for dir in SOURCES SPECS
  59. do
  60. mkdir $dir
  61. done
  62. VERSION_CHECKED="false"
  63. case $OVERRIDE_VERSION_TO_LATEST in
  64. true)
  65. # CHECK the latest vesion and set $SOURCES_VERSION
  66. echo "Checking for latest sources release"
  67. if [ -x "/usr/bin/ruby" ]
  68. then
  69. SOURCES_VERSION=`/usr/bin/ruby check_release.rb $VERSION_BRANCH`
  70. VERSION_CHECKED="true"
  71. fi
  72. if [ -x "/usr/bin/perl" ] && [ "$VERSION_CHECKED" = "false" ]
  73. then
  74. SOURCES_VERSION=`/usr/bin/perl check_release.pl $VERSION_BRANCH`
  75. VERSION_CHECKED="true"
  76. fi
  77. ;;
  78. *)
  79. echo "Using sources for release from the build parameters"
  80. VERSION_CHECKED="true"
  81. esac
  82. case $VERSION_CHECKED in
  83. false)
  84. echo "couldn't check the latest sources version"
  85. exit 1
  86. ;;
  87. *)
  88. echo "sources version was checked against the API or was manully configured"
  89. esac
  90. echo -n "Sources version for the build: "
  91. echo $SOURCES_VERSION
  92. ## fetch current stable version from a url
  93. ## Download squid sources(tar.xz+asc) if doesn't exists
  94. if [ -e "SOURCES/squid-$SOURCES_VERSION.tar.xz" ]
  95. then
  96. echo "tar.xz already exists"
  97. else
  98. wget -O "SOURCES/squid-$SOURCES_VERSION.tar.xz" "http://ngtech.co.il/squid/src/squid-$SOURCES_VERSION.tar.xz"
  99. fi
  100. if [ -e "SOURCES/squid-$SOURCES_VERSION.tar.xz.asc" ]
  101. then
  102. echo "tar.xz.asc already exists"
  103. else
  104. wget -O "SOURCES/squid-$SOURCES_VERSION.tar.xz.asc" "http://ngtech.co.il/squid/src/squid-$SOURCES_VERSION.tar.xz.asc"
  105. fi
  106. # Create rpm in RPMS/noarch/
  107. #rpmbuild --define '_topdir '`pwd` --define '_smp_mflags -j5' -ba SPECS/helloworld.spec
  108. echo -n "SMP FLAGS "
  109. echo $SMP_FLAG
  110. echo -n "Will be using the SPEC file for the build: "
  111. echo $SPEC_FILE
  112. echo "Printing changed environmental variables:"
  113. env
  114. echo "End of variables"
  115. rpmbuild --define '_topdir '`pwd` --define "_smp_mflags -j$SMP_FLAG" -ba -vv SPECS/$SPEC_FILE