#!/bin/env ruby

require_relative 'color'

dbpath = '~/config/status/db'

if 0 == packages = `yaourt -Qu --aur --dbpath #{dbpath}`.chomp.lines.count
    puts green("all packages up to date")
elsif
    puts red("#{packages} packages out of date")
end

arch = `uname -a`.split[12]
mirror = 'https://mirrors.kernel.org/archlinux/'

['community', 'core', 'extra', 'multilib'].each do |repo|
    `nohup curl -L https://mirrors.kernel.org/archlinux/#{repo}/os/#{arch}/#{repo}.db > #{dbpath}/sync/#{repo}.db &`
end

