Created
November 29, 2011 02:01
-
-
Save anatol/1403019 to your computer and use it in GitHub Desktop.
build tup PPA
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 <[email protected]> #{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