Skip to content

Instantly share code, notes, and snippets.

@titanous
Forked from anatol/build.rb
Last active August 29, 2015 14:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save titanous/a7b4479d449b8d16848e to your computer and use it in GitHub Desktop.
Save titanous/a7b4479d449b8d16848e to your computer and use it in GitHub Desktop.
#!/usr/bin/ruby
# directory git should contain 2 branches: origin/master and debian
system("rm -rf debian && mkdir debian")
Dir.chdir('git')
system('git remote update && git reset --hard origin/master')
version = `git describe`.chomp
version = version[1..-1]
if version =~ /^([\d\.]+)(-(\d+)-(g.*))?$/ then
tag_version = $1
counter = $3
git_version = $4
if counter then
tag_version += '.0' if tag_version =~ /^\d+\.\d+$/ #tag consists only 2 parts
tag_version += '.' + counter
debian_version = tag_version + '+' + git_version
else
debian_version = tag_version
end
else
raise "Cannot parse version #{version}"
end
# Thu, 03 Nov 2011 18:04:11 -0700
curr_time = Time.now.strftime('%a, %d %b %Y %H:%M:%S %z')
changelog=<<END
tup (#{debian_version}) lucid; urgency=low
[ Anatol Pomozov ]
* Daily build for Lucid.
-- Anatol Pomozov <anatol.pomozov@gmail.com> #{curr_time}
END
File.open("contrib/debian/changelog", "w") {|c|
c.write(changelog)
}
build_sh = File.read('build.sh')
build_sh.sub!('label=${TUP_LABEL:-bootstrap}', %Q{label="#{version}"})
File.open('build.sh', 'w') { |f| f.write(build_sh) }
system("git mv contrib/debian .")
system("git commit -am 1")
system("git archive --format=tar --prefix=tup-#{tag_version}/ HEAD | gzip > ../debian/tup_#{debian_version}.orig.tar.gz")
system("git reset --hard HEAD~")
Dir.chdir('../debian')
system("tar -xzvf tup_#{debian_version}.orig.tar.gz > /dev/null")
Dir.chdir("tup-#{tag_version}")
system('debuild -S')
exit
Dir.chdir('..')
system("dput ppa:anatol/tup tup_#{debian_version}_source.changes")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment