You are not logged in.

#1 2009-10-15 10:42:07

hackmykack
Member
From: Bombay, India
Registered: 2005-11-18
Posts: 17

Script to keep Pacman packages current

Hi Guys,

This is just a small script to keep packages current.

"pacman -Sc" doesn't work coz it only takes care of <installed> packages.

Not sure if this is something anybody needs .. but either ways .. here it is :>)

Requirements are <<Ruby>> && U need to run this from the package directory.

See ya.


#!/usr/bin/ruby -w                           

##                                                       
# Program to keep Packages up to date       
# Note: You have to Run this from the         
# Directory where the packages are stored   
##                                                         

# Control Array
arr = `ls`.split("\n")
sleep(2)

# Array where stuff is actually deleted
delarr = `ls`.split("\n")
sleep(2)

puts "Here goes nothing )>^ . . . . "

# Prepare "arr" for processing
arr.each do |e|
  e.sub!(/-\d\..*$/, '')
end

sleep(1)

arr.each do |e|
  e.sub!(/-\d.*$/, '')
end

##                                                   
# Logic for when to Delete a package  
# If TWO Consecutive "arr" elements   
# have the <same> name, Delete the  
# first of the two elements                  
##                                                   
0.upto(arr.length - 1) do |i|
  if arr[i] == arr[i+1]
    system("rm -v #{delarr[i]}")
  end
end

Offline

#2 2009-10-15 10:45:09

Allan
Pacman
From: Brisbane, AU
Registered: 2007-06-09
Posts: 11,651
Website

Re: Script to keep Pacman packages current

man pacman.conf

CleanMethod = KeepInstalled | KeepCurrent
           If set to KeepInstalled (the default), the -Sc operation will clean
           packages that are no longer installed (not present in the local
           database). If set to KeepCurrent, -Sc will clean outdated packages
           (not present in any sync database). The second behavior is useful
           when the package cache is shared among multiple machines, where the
           local databases are usually different, but the sync databases in
           use could be the same.

Are you replicating KeepCurrent?

Offline

#3 2009-10-17 02:17:19

hackmykack
Member
From: Bombay, India
Registered: 2005-11-18
Posts: 17

Re: Script to keep Pacman packages current

hey Allan

Yes .. it would appear that this does <exactly> what "KeepCurrent" does ..

Thnx much for pointing that out :>)

Only reason I just may continue to use the above program is speed ..
Need to test "KeepCurrent" but, "KeepInstalled", seemed to take 5 - 10 secs longer that the above script.

Either way ...

Thnx again :>)

Hak

Offline

Board footer

Powered by FluxBB