#!/usr/bin/ruby # # Ruby module that contains common functions for # building P4Ruby # module P4RubyCommon # # Relative path to P4Ruby relnotes. We need to copy them over when we're # building the distribution # @@RELNOTES_PATH = "../p4-doc/user/p4rubynotes.txt" # # Extract the P4Ruby version # def get_version v = nil p = nil n = nil File.open( "Version" ) do |f| f.each do |line| if ( line =~ /^RELEASE\s*=\s*(\d+) (\d+) ?(.*) ;/ ) v = "#{$1}.#{$2}" n = $3 n.gsub!(/ +/, '.') elsif ( line =~ /^PATCHLEVEL\s*=\s*(\d+)/ ) p = $1 end end end if ( ! v ) raise( RuntimeError, "Can't figure out the version of P4Ruby!" ) end v += ".#{p}" if p v += ".#{n}" if n return v end # # Build the tarball # def build_tarball( tarball, build_dir ) system( "tar -cvf #{tarball} #{build_dir}" ) system( "gzip -vf #{tarball}" ) end end