Skip to content

Instantly share code, notes, and snippets.

@AlexTalker
Created March 31, 2014 21:11
Show Gist options
  • Save AlexTalker/9902420 to your computer and use it in GitHub Desktop.
Save AlexTalker/9902420 to your computer and use it in GitHub Desktop.
#!/usr/bin/ruby
class Package
Makepkg = '/usr/bin/makepkg'
Pacman = '/usr/bin/pacman'
LogBuild = 'manager-build.log'
LogInstall = 'manager-install.log'
def initialize(file='PKGBUILD')
raise ArgumentErorr, "Package: argument must respond to to_s" unless file.respond_to? :to_s
@file = file.to_s
end
def build
system(Makepkg, '-s', '-p',@file, '--noconfirm', '-L', LogBuild)
$? == 0
end
def install
system(Makepkg, '-i', '--noconfirm', '--logfile', LogInstall, '--skipchecksums')
$? == 0
end
end
def cd(i)
begin
Dir.chdir(i)
rescue
puts "An error happened in cd().Path don't found: #{i}"
false
end
end
key, *args = ARGV.clone
def eaching
args.each do |package|
if cd(package)
p = Package.new(package)
yield p
end
end
end
Help = <<TEXT
build <packages> -- build packages in directories at it with name like name package
install <packages> -- build packages in directories at it with name like name package
help -- get this help
TEXT
case key
when 'help'
puts Help
when 'build'
eaching do |p|
puts "Build Error in package #{package}" unless p.build
cd('..')
end
when 'install'
eaching do |p|
puts "Install Error in package #{package}" unless p.install
cd('..')
end
else
puts "Unsuppported key, write 'manager help' for get help!"
end
# ARGV.each { |package|
# if cd(package)
# system('pwd')
# cd('..')
# end
# }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment