Advertisement
trini

Untitled

Apr 13th, 2012
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. # Script to modify linux-stable recipe to build latest kernel tag
  2. # Requires ruby. To install ruby: sudo apt-get install ruby1.9.1
  3.  
  4. def get_latest_tag(force_tag)
  5. return force_tag if (force_tag && force_tag != '')
  6. x=`git ls-remote --tags git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git master v\*`
  7. x.scan(/refs\/tags\/(v[\d\.]+)\n/).flatten.last
  8. end
  9.  
  10. def need_to_run(tag)
  11. if !File.exists? "latest-linux-stable-run"
  12. update_latest_run(tag)
  13. return true
  14. else
  15. last_run = File.open("latest-linux-stable-run").read
  16. update_latest_run(tag)
  17. tag.strip != last_run.strip
  18. end
  19. end
  20.  
  21. def update_latest_run(tag)
  22. f = File.new("latest-linux-stable-run", 'w')
  23. f.write(tag)
  24. f.close
  25. end
  26.  
  27. def update_recipe(recipe,tag)
  28. `cat #{recipe} | sed 's/SRCREV = ".*"/SRCREV = "#{tag}"/g' > #{recipe}.tmp; mv #{recipe}.tmp #{recipe}`
  29. end
  30.  
  31. ########################################
  32. ########## START SCRIPT BODY ###########
  33. ########################################
  34. recipe = ARGV[0]
  35. force_tag = ARGV[1]
  36.  
  37. tag = get_latest_tag(force_tag)
  38.  
  39. if need_to_run(tag)
  40. update_recipe(recipe,tag)
  41. puts "Done. #{recipe} udpated to use tag #{tag}\n"
  42. exit 0
  43. else
  44. puts "There are no new tags. We are done! \n"
  45. exit 1
  46. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement