From: <jh...@us...> - 2009-11-14 06:37:51
|
Revision: 156 http://etch.svn.sourceforge.net/etch/?rev=156&view=rev Author: jheiss Date: 2009-11-14 06:37:45 +0000 (Sat, 14 Nov 2009) Log Message: ----------- Config file for rake to replace makefile. Besides the rpm, deb and sysv packages supported by the makefile this adds a generic "rake install" task that installs to appropriate directories based on the current ruby config, and a task to build a gem. Added Paths: ----------- trunk/client/Rakefile Added: trunk/client/Rakefile =================================================================== --- trunk/client/Rakefile (rev 0) +++ trunk/client/Rakefile 2009-11-14 06:37:45 UTC (rev 156) @@ -0,0 +1,426 @@ +require 'rbconfig' +require 'tempfile' +require 'tmpdir' + +ETCHVER = IO.read('../VERSION').chomp + +BUILDROOT = '/var/tmp/etch-client-buildroot' + +# Copies the etch client files to destdir. Appropriate subdirectories will be +# composed unless specified via options. +# options: +# :bindir +# :libdir +# :etcdir +# :mandir +# :crondir (note no default here, crontab will not be copied if not specified) +# :ruby (#! lines in scripts will be changed to specified ruby) +# :installbase (base directory where files will end up) +def copy_etch_files(destdir, options={}) + bindir = nil + if options[:bindir] + bindir = File.join(destdir, options[:bindir]) + else + bindir = File.join(destdir, 'bin') + end + mkdir_p(bindir) + binapps = ['etch', 'etch_to_trunk', 'etch_cron_wrapper'] + binapps.each do |binapp| + if options[:ruby] + # Change #! line + File.open(File.join(bindir, binapp), 'w') do |newfile| + File.open(binapp) do |oldfile| + # Modify the first line + firstline = oldfile.gets + # Preserve any options. I.e. #!/usr/bin/ruby -w + shebang, shebangopts = firstline.split(' ', 2) + newfile.puts "#!#{options[:ruby]} #{shebangopts}" + # Then dump in the rest of the file + newfile.write(oldfile.read) + end + end + else + cp(binapp, bindir, :preserve => true) + end + chmod(0555, File.join(bindir, binapp)) + end + + libdir = nil + if options[:libdir] + libdir = File.join(destdir, options[:libdir]) + else + libdir = File.join(destdir, 'lib') + end + mkdir_p(libdir) + clientlibs = ['etchclient.rb'] + clientlibs.each do |clientlib| + cp(clientlib, libdir, :preserve => true) + end + serverlibs = ['etch.rb', 'versiontype.rb'] + serverlibs.each do |serverlib| + cp(File.join('..', 'server', 'lib', serverlib), libdir, :preserve => true) + end + clientlibs + serverlibs.each do |lib| + chmod(0444, File.join(libdir, lib)) + end + + mandir = nil + if options[:mandir] + mandir = File.join(destdir, options[:mandir]) + else + mandir = File.join(destdir, 'man') + end + man8dir = File.join(mandir, 'man8') + mkdir_p(man8dir) + cp('etch.8', man8dir, :preserve => true) + chmod(0444, File.join(man8dir, 'etch.8')) + + etcdir = nil + realetcdir = nil + if options[:etcdir] + realetcdir = options[:etcdir] + else + realetcdir = '/etc' + end + etcdir = File.join(destdir, realetcdir) + mkdir_p(etcdir) + etcfiles = ['ca.pem', 'dhparams'] + etcfiles.each do |etcfile| + cp(etcfile, etcdir, :preserve => true) + chmod(0644, File.join(etcdir, etcfile)) + end + + if options[:crondir] + crondir = File.join(destdir, options[:crondir]) + mkdir_p(crondir) + # Note file renamed to 'etch' here. Filename is different in the repo for + # clarity and to avoid conflict with the main executable. + cp('etch_cron', File.join(crondir, 'etch'), :preserve => true) + chmod(0444, File.join(crondir, 'etch')) + end + + # Substitute ETCHVER into etchclient.rb + # Substitute proper path into CONFIGDIR in etchclient.rb if appropriate + newetchclient = File.join(libdir, 'etchclient.rb.new') + etchclient = File.join(libdir, 'etchclient.rb') + File.open(newetchclient, 'w') do |newfile| + IO.foreach(etchclient) do |line| + if line =~ /^\s*VERSION/ + line.sub!(/=.*/, "= '#{ETCHVER}'") + end + if options[:installbase] && line =~ /^\s*CONFIGDIR/ + line.sub!(/=.*/, "= #{realetcdir}") + end + newfile.write(line) + end + end + mv(newetchclient, etchclient) + chmod(0444, etchclient) +end + +desc 'Build an etch client RPM on a Red Hat box' +task :redhat => [:redhatprep, :rpm] +desc 'Prep a Red Hat box for building an RPM' +task :redhatprep do + # Install the package which contains the rpmbuild command + system('rpm --quiet -q rpm-build || sudo yum install rpm-build') +end +desc 'Build an etch client RPM' +task :rpm do + # + # Create package file structure in build root + # + + rm_rf(BUILDROOT) + + sbindir = File.join('usr', 'sbin') + libdir = File.join('usr', 'lib', 'ruby', 'site_ruby', '1.8') + mandir = File.join('usr', 'share', 'man') + etcdir = File.join('etc', 'etch') + crondir = File.join('etc', 'cron.d') + copy_etch_files(BUILDROOT, :bindir => sbindir, :libdir => libdir, + :mandir => mandir, :etcdir => etcdir, :crondir => crondir, + :installbase => '/') + + # + # Prep spec file + # + + spec = Tempfile.new('etchrpm') + IO.foreach('etch-client.spec') do |line| + line.sub!('%VER%', ETCHVER) + spec.puts(line) + end + + # + # Build the package + # + + system("rpmbuild -bb --buildroot #{BUILDROOT} #{spec.path}") + + # + # Cleanup + # + + rm_rf(BUILDROOT) +end + +desc 'Build an etch client deb' +task :deb do + # + # Create package file structure in build root + # + + rm_rf(BUILDROOT) + + mkdir_p(File.join(BUILDROOT, 'DEBIAN')) + File.open(File.join(BUILDROOT, 'DEBIAN', 'control'), 'w') do |control| + IO.foreach('control') do |line| + next if line =~ /^\s*#/ # Remove comments + line.sub!('%VER%', ETCHVER) + control.puts(line) + end + end + + sbindir = File.join('usr', 'sbin') + libdir = File.join('usr', 'local', 'lib', 'site_ruby', '1.8') + mandir = File.join('usr', 'share', 'man') + etcdir = File.join('etc', 'etch') + crondir = File.join('etc', 'cron.d') + copy_etch_files(BUILDROOT, :bindir => sbindir, :libdir => libdir, + :mandir => mandir, :etcdir => etcdir, :crondir => crondir, + :installbase => '/') + + # + # Set permissions + # + + system("sudo chown -R 0:0 #{BUILDROOT}") + + # + # Build the package + # + + system("dpkg --build #{BUILDROOT} etch-client-#{ETCHVER}.deb") + + # + # Cleanup + # + + rm_rf(BUILDROOT) +end + +desc 'Build etch client SysV packages for Solaris" +task :solaris => [:sysvpkg, :sysvpkgsparc] +desc 'Build an etch client SysV package' +task :sysvpkg do + # + # Create package file structure in build root + # + + rm_rf(BUILDROOT) + + sbindir = File.join('usr', 'sbin') + libdir = File.join('opt', 'csw', 'lib', 'ruby', 'site_ruby', '1.8') + mandir = File.join('usr', 'share', 'man') + etcdir = File.join('etc', 'etch') + copy_etch_files(BUILDROOT, :bindir => sbindir, :libdir => libdir, + :mandir => mandir, :etcdir => etcdir, + :ruby => '/opt/csw/bin/ruby', :installbase => '/') + + # + # Prep packaging files + # + + rm_rf('solbuild') + mkdir('solbuild') + File.open(File.join('solbuild', 'pkginfo'), 'w') do |pkginfo| + IO.foreach('pkginfo') do |line| + line.sub!('%VER%', ETCHVER) + pkginfo.puts(line) + end + end + File.open(File.join('solbuild', 'prototype'), 'w') do |prototype| + prototype.puts("i pkginfo=./pkginfo") + cp('depend', 'solbuild/depend') + prototype.puts("i depend=./depend") + cp('postinstall', 'solbuild/postinstall') + prototype.puts("i postinstall=./postinstall") + cp('postremove', 'solbuild/postremove') + prototype.puts("i postremove=./postremove") + # The tail +2 removes the first line, which is the base directory + # and doesn't need to be included in the package. + IO.popen("find #{BUILDROOT} | tail +2 | pkgproto") do |pipe| + pipe.each do |line| + # Clean up the directory names + line.sub!(BUILDROOT, '') + # Don't force our permissions on directories + if line =~ /^d/ + line.sub!(/\S+ \S+ \S+$/, '? ? ?') + end + prototype.write(line) + end + end + end + + # + # Build the package + # + + system("cd solbuild && pkgmk -r #{BUILDROOT} -d $PWD/solbuild") + system("pkgtrans solbuild ../YPCetch-#{ETCHVER}.pkg YPCetch") + + # + # Cleanup + # + + rm_rf('solbuild') + rm_rf(BUILDROOT) +end + +# On Sparc systems we're having problems with the CSW/Blastwave ruby core +# dumping when running etch. The Sunfreeware ruby seems to work. Sunfreeware +# doesn't play well with pkg-get, so we create a bit of a hybrid. We still +# express all the dependencies against CSW, and put our library file +# (etchclient.rb) into /opt/csw. We modify etch to use the Sunfreeware ruby +# in /usr/local/bin, but then tell it to also look in the /opt/csw directory +# for libraries. Users will have to manually install the Sunfreeware ruby +# package. +desc 'Build an etch client SysV package with hybrid CSW/Sunfreeware dependencies' +task :sysvpkgsparc do + # + # Create package file structure in build root + # + + rm_rf(BUILDROOT) + + sbindir = File.join('usr', 'sbin') + libdir = File.join('opt', 'csw', 'lib', 'ruby', 'site_ruby', '1.8') + mandir = File.join('usr', 'share', 'man') + etcdir = File.join('etc', 'etch') + copy_etch_files(BUILDROOT, :bindir => sbindir, :libdir => libdir, + :mandir => mandir, :etcdir => etcdir, + :ruby => '/usr/local/bin/ruby', :installbase => '/') + + # Since we're using the Sunfreeware ruby but CSW libraries we need to add + # the CSW ruby library directory to the search path + newetch = File.join(BUILDROOT, 'usr', 'sbin', 'etch.new') + etch = File.join(BUILDROOT, 'usr', 'sbin', 'etch') + File.open(newetch, 'w') do |newfile| + IO.foreach(etch) do |line| + if line =~ /unshift.*__FILE__/ + line << "$:.unshift('/opt/csw/lib/ruby/site_ruby/1.8')\n" + end + newfile.write(line) + end + end + mv(newetch, etch) + chmod(0555, etch) + + # + # Prep packaging files + # + + rm_rf('solbuild') + mkdir('solbuild') + File.open(File.join('solbuild', 'pkginfo'), 'w') do |pkginfo| + IO.foreach('pkginfo') do |line| + line.sub!('%VER%', ETCHVER) + pkginfo.puts(line) + end + end + File.open(File.join('solbuild', 'prototype'), 'w') do |prototype| + prototype.puts("i pkginfo=./pkginfo") + cp('depend', 'solbuild/depend') + prototype.puts("i depend=./depend") + cp('postinstall', 'solbuild/postinstall') + prototype.puts("i postinstall=./postinstall") + cp('postremove', 'solbuild/postremove') + prototype.puts("i postremove=./postremove") + # The tail +2 removes the first line, which is the base directory + # and doesn't need to be included in the package. + IO.popen("find #{BUILDROOT} | tail +2 | pkgproto") do |pipe| + pipe.each do |line| + # Clean up the directory names + line.sub!(BUILDROOT, '') + # Don't force our permissions on directories + if line =~ /^d/ + line.sub!(/\S+ \S+ \S+$/, '? ? ?') + end + prototype.write(line) + end + end + end + + # + # Build the package + # + + system("cd solbuild && pkgmk -r #{BUILDROOT} -d $PWD/solbuild") + system("pkgtrans solbuild ../YPCetch-#{ETCHVER}-sparc.pkg YPCetch") + + # + # Cleanup + # + + rm_rf('solbuild') + rm_rf(BUILDROOT) +end + +# Install based on Config::CONFIG paths +task :install, :destdir do |t, args| + destdir = nil + if args.destdir + destdir = args.destdir + else + destdir = '/' + end + copy_etch_files(destdir, + :bindir => Config::CONFIG['sbindir'], + :libdir => Config::CONFIG['sitelibdir'], + :mandir => Config::CONFIG['mandir'], + :etcdir => Config::CONFIG['sysconfdir'], + # Can't find a better way to get the path to the current ruby + :ruby => File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name']), + :installbase => '/') +end + +task :gem do + # + # Create package file structure in build root + # + + rm_rf(BUILDROOT) + copy_etch_files(BUILDROOT) + + # + # Prep gemspec + # + File.open(File.join(BUILDROOT, 'Rakefile'), 'w') do |gemspec| + IO.foreach('gemspec') do |line| + line.sub!('%VER%', ETCHVER) + gemspec.puts(line) + end + end + + # + # Build the package + # + + system("cd #{BUILDROOT} && rake gem") + gemglob = File.join(BUILDROOT, 'pkg', '*.gem') + gemfile = Dir.glob(gemglob).first + if gemfile + mv(gemfile, Dir.tmpdir) + puts "Gem is #{File.join(Dir.tmpdir, File.basename(gemfile))}" + else + warn "Gem file #{gemglob} not found!" + end + + # + # Cleanup + # + + rm_rf(BUILDROOT) +end + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jh...@us...> - 2009-11-14 17:25:22
|
Revision: 157 http://etch.svn.sourceforge.net/etch/?rev=157&view=rev Author: jheiss Date: 2009-11-14 17:25:15 +0000 (Sat, 14 Nov 2009) Log Message: ----------- Fix bad quote character Modified Paths: -------------- trunk/client/Rakefile Modified: trunk/client/Rakefile =================================================================== --- trunk/client/Rakefile 2009-11-14 06:37:45 UTC (rev 156) +++ trunk/client/Rakefile 2009-11-14 17:25:15 UTC (rev 157) @@ -210,7 +210,7 @@ rm_rf(BUILDROOT) end -desc 'Build etch client SysV packages for Solaris" +desc 'Build etch client SysV packages for Solaris' task :solaris => [:sysvpkg, :sysvpkgsparc] desc 'Build an etch client SysV package' task :sysvpkg do This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jh...@us...> - 2009-11-18 06:24:25
|
Revision: 176 http://etch.svn.sourceforge.net/etch/?rev=176&view=rev Author: jheiss Date: 2009-11-18 06:24:17 +0000 (Wed, 18 Nov 2009) Log Message: ----------- Fix cut-n-paste typo Modified Paths: -------------- trunk/client/Rakefile Modified: trunk/client/Rakefile =================================================================== --- trunk/client/Rakefile 2009-11-18 06:24:01 UTC (rev 175) +++ trunk/client/Rakefile 2009-11-18 06:24:17 UTC (rev 176) @@ -281,7 +281,7 @@ # system("cd solbuild && pkgmk -r #{BUILDROOT} -d $PWD/solbuild") - system("pkgtrans solbuild ../YPCetch-#{ETCHVER}.pkg YPCetch") + system("pkgtrans solbuild ../OSSetch-#{ETCHVER}.pkg OSSetch") # # Cleanup @@ -370,7 +370,7 @@ # system("cd solbuild && pkgmk -r #{BUILDROOT} -d $PWD/solbuild") - system("pkgtrans solbuild ../YPCetch-#{ETCHVER}-sparc.pkg YPCetch") + system("pkgtrans solbuild ../OSSetch-#{ETCHVER}-sparc.pkg OSSetch") # # Cleanup This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jh...@us...> - 2010-01-21 00:41:59
|
Revision: 195 http://etch.svn.sourceforge.net/etch/?rev=195&view=rev Author: jheiss Date: 2010-01-21 00:41:53 +0000 (Thu, 21 Jan 2010) Log Message: ----------- Fix a bug and a cut-n-paste typo. Modified Paths: -------------- trunk/client/Rakefile Modified: trunk/client/Rakefile =================================================================== --- trunk/client/Rakefile 2010-01-21 00:01:49 UTC (rev 194) +++ trunk/client/Rakefile 2010-01-21 00:41:53 UTC (rev 195) @@ -51,8 +51,8 @@ # Substitute ETCHVER into etchclient.rb # Substitute proper path into CONFIGDIR in etchclient.rb if appropriate - File.open(File.join(libdir, 'etchclient.rb.new'), 'w') do |newfile| - IO.foreach(File.join(libdir, 'etchclient.rb')) do |line| + File.open(File.join(libdir, 'etchclient.rb'), 'w') do |newfile| + IO.foreach('etchclient.rb') do |line| if line =~ /^\s*VERSION/ line.sub!(/=.*/, "= '#{ETCHVER}'") end @@ -408,7 +408,7 @@ # rm_rf(BUILDROOT) - copy_tpkg_files(BUILDROOT, + copy_etch_files(BUILDROOT, :bindir => 'bin', :libdir => 'lib') This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jh...@us...> - 2010-01-21 01:08:40
|
Revision: 196 http://etch.svn.sourceforge.net/etch/?rev=196&view=rev Author: jheiss Date: 2010-01-21 01:08:34 +0000 (Thu, 21 Jan 2010) Log Message: ----------- Fix bug that prevented the rpm task from working. Modified Paths: -------------- trunk/client/Rakefile Modified: trunk/client/Rakefile =================================================================== --- trunk/client/Rakefile 2010-01-21 00:41:53 UTC (rev 195) +++ trunk/client/Rakefile 2010-01-21 01:08:34 UTC (rev 196) @@ -137,6 +137,7 @@ line.sub!('%VER%', ETCHVER) spec.puts(line) end + spec.close # # Build the package This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jh...@us...> - 2010-01-21 04:09:53
|
Revision: 198 http://etch.svn.sourceforge.net/etch/?rev=198&view=rev Author: jheiss Date: 2010-01-21 04:09:46 +0000 (Thu, 21 Jan 2010) Log Message: ----------- Add some missing quotes. Modified Paths: -------------- trunk/client/Rakefile Modified: trunk/client/Rakefile =================================================================== --- trunk/client/Rakefile 2010-01-21 01:17:36 UTC (rev 197) +++ trunk/client/Rakefile 2010-01-21 04:09:46 UTC (rev 198) @@ -57,7 +57,7 @@ line.sub!(/=.*/, "= '#{ETCHVER}'") end if options[:etcdir] && line =~ /^\s*CONFIGDIR/ - line.sub!(/=.*/, "= #{options[:etcdir]}") + line.sub!(/=.*/, "= '#{options[:etcdir]}'") end newfile.write(line) end This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jh...@us...> - 2010-12-18 01:42:04
|
Revision: 227 http://etch.svn.sourceforge.net/etch/?rev=227&view=rev Author: jheiss Date: 2010-12-18 01:41:58 +0000 (Sat, 18 Dec 2010) Log Message: ----------- Set the postinstall/postremove scripts to be executable when building the Solaris packages. Modified Paths: -------------- trunk/client/Rakefile Modified: trunk/client/Rakefile =================================================================== --- trunk/client/Rakefile 2010-11-29 18:12:42 UTC (rev 226) +++ trunk/client/Rakefile 2010-12-18 01:41:58 UTC (rev 227) @@ -230,8 +230,10 @@ cp('depend', 'solbuild/depend') prototype.puts("i depend=./depend") cp('postinstall.solaris', 'solbuild/postinstall') + chmod(0555, 'solbuild/postinstall') prototype.puts("i postinstall=./postinstall") cp('postremove.solaris', 'solbuild/postremove') + chmod(0555, 'solbuild/postremove') prototype.puts("i postremove=./postremove") # The tail +2 removes the first line, which is the base directory # and doesn't need to be included in the package. @@ -319,8 +321,10 @@ cp('depend', 'solbuild/depend') prototype.puts("i depend=./depend") cp('postinstall.solaris', 'solbuild/postinstall') + chmod(0555, 'solbuild/postinstall') prototype.puts("i postinstall=./postinstall") cp('postremove.solaris', 'solbuild/postremove') + chmod(0555, 'solbuild/postremove') prototype.puts("i postremove=./postremove") # The tail +2 removes the first line, which is the base directory # and doesn't need to be included in the package. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jh...@us...> - 2010-12-22 21:51:56
|
Revision: 245 http://etch.svn.sourceforge.net/etch/?rev=245&view=rev Author: jheiss Date: 2010-12-22 21:51:50 +0000 (Wed, 22 Dec 2010) Log Message: ----------- Add desc to the gem task so that it shows up in the rake -T list Modified Paths: -------------- trunk/client/Rakefile Modified: trunk/client/Rakefile =================================================================== --- trunk/client/Rakefile 2010-12-22 21:09:27 UTC (rev 244) +++ trunk/client/Rakefile 2010-12-22 21:51:50 UTC (rev 245) @@ -406,6 +406,7 @@ puts "Portfile is #{portfile}" end +desc 'Build rubygem package' task :gem do # # Create package file structure in build root This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |