Skip to content

Instantly share code, notes, and snippets.

@vitaliel
Created February 27, 2009 10:10
Show Gist options
  • Save vitaliel/71392 to your computer and use it in GitHub Desktop.
Save vitaliel/71392 to your computer and use it in GitHub Desktop.
#
# Helper tasks to build debian packages from git repository
#
# apt-get install git-buildpackage
# Create local branches
# $ rake deb:setup
# create a snapshot
# $ rake snap
branch = "snapshot"
desc "Build debian snapshot package, needs upstream branch"
task :snap => [:snap_dch, :deb]
task :snap_dch do
sh "git checkout work"
system "git branch -D " << branch
sh "git checkout -b " << branch
lines = []
fname = "debian/changelog"
File.open(fname) do |f|
lines = f.readlines
end
info = lines[0]
pkg, ver, rel, pri = info.split
st = ver.tr!('()', '')
# p pkg, ver, rel, pri, st
st = st << "0" << "~#{Time.now.to_i}"
l = []
l << [pkg, "(" << st << ")", rel, pri].join(' ')
l << ""
# TODO add git logs
l << " * snapshot"
l << ""
l << " -- #{ENV['DEBEMAIL']} #{Time.now.strftime("%a, %d %b %Y %H:%M:%S %z")}"
l << ""
l.map {|x| x << "\n" }
File.open(fname, "w") do |g|
g.write((l + lines).join)
end
sh "git commit -a -m snapshot"
end
task :deb do
sh "git-buildpackage --git-debian-branch=" << branch
# switch back to work
sh "git checkout work"
end
task :export do
dir = Dir.pwd
cd ".."
sh "export_debs && rsync_debs"
cd dir
end
namespace :deb do
desc "Init git branches used for git-buildpackage"
task :setup do
sh "git checkout -b upstream"
sh "git checkout -b work"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment