         # File lib/rake/packagetask.rb, line 99
     99:     def define
    100:       fail "Version required (or :noversion)" if @version.nil?
    101:       @version = nil if :noversion == @version
    102:
    103:       desc "Build all the packages"
    104:       task :package
    105:
    106:       desc "Force a rebuild of the package files"
    107:       task :repackage => [:clobber_package, :package]
    108:
    109:       desc "Remove package products"
    110:       task :clobber_package do
    111:         rm_r package_dir rescue nil
    112:       end
    113:
    114:       task :clobber => [:clobber_package]
    115:
    116:       [
    117:         [need_tar, tgz_file, "z"],
    118:         [need_tar_gz, tar_gz_file, "z"],
    119:         [need_tar_bz2, tar_bz2_file, "j"]
    120:       ].each do |(need, file, flag)|
    121:         if need
    122:           task :package => ["#{package_dir}/#{file}"]
    123:           file "#{package_dir}/#{file}" => [package_dir_path] + package_files do
    124:             chdir(package_dir) do
    125:               sh %{#{@tar_command} #{flag}cvf #{file} #{package_name}}
    126:             end
    127:           end
    128:         end
    129:       end
    130:
    131:       if need_zip
    132:         task :package => ["#{package_dir}/#{zip_file}"]
    133:         file "#{package_dir}/#{zip_file}" => [package_dir_path] + package_files do
    134:           chdir(package_dir) do
    135:             sh %{#{@zip_command} -r #{zip_file} #{package_name}}
    136:           end
    137:         end
    138:       end
    139:
    140:       directory package_dir
    141:
    142:       file package_dir_path => @package_files do
    143:         mkdir_p package_dir rescue nil
    144:         @package_files.each do |fn|
    145:           f = File.join(package_dir_path, fn)
    146:           fdir = File.dirname(f)
    147:           mkdir_p(fdir) if !File.exist?(fdir)
    148:           if File.directory?(fn)
    149:             mkdir_p(f)
    150:           else
    151:             rm_f f
    152:             safe_ln(fn, f)
    153:           end
    154:         end
    155:       end
    156:       self
    157:     end