Pacman cache share over LAN is a pain!

Hi fellows. As Arch Wiki - Pacman Tips say, i setup a nfs server in my home server so all the laptops can upgrade packages more quickly and without increasing load in the servers.
It all sounds great, but turns out there is one big problem. When a client is using the server to upgrade, the integrity check of packages takes a very long time. And believe me, downloading them is even faster than the that.
Is there something I can tweak to make this faster?
This is my fstab line in each client:
myserver:/var/cache/pacman/pkg /var/cache/pacman/pkg nfs4 defaults 0 0
And this is the line of /etc/exports in the server:
/var/cache/pacman/pkg *(rw,async,subtree_check,no_root_squash)
Thanks for your help in advance!

Stebalien wrote:You could try: http://xyne.archlinux.ca/projects/pacserve/
It doesn't use NFS but should be faster.
I thought about using it but i didn't wanted to depend on a extra package. Before using it, i want to know if my problem is easily solvable.

Similar Messages

  • [Solved] What is the best way to share pacman cache ?

    I'm wondering what is the best way to share the pacman cache .
    I went with the obvious choice 'sshfs' . But the cache on the server is owned by root so I can't use it dynamically unless I enable root logins , right ?
    Is it safe to enable root logins and mount with the root user ?
    What is the best and safest way to share pacman cache dynamically ?
    Last edited by Nezmer (2008-12-07 01:13:20)

    Interesting. I use sshfs and yes use root login to do business. But I see it this way you want more security created a stronger password. You want more security than that disable passwords and use keys. But once you start NFS you are surely introducing some security issue just as if you enable root ssh login, so why is NFS better?
    Just asking out of interest, I claim to know nothing about security.

  • Run a self-updating network shared pacman cache

    About a month ago I began working out how to share a pacman cache without the problems that the solutions proposed until now had.
    I wanted my cache to be:
    easily configurable
    in control of the packages in the cache
    capable of handling multiple clients simultaneously
    self-updating
    Especially the last point comes in handy if you frequently want to update your system without having to wait for a package download first.
    All you need for this to work is a device that is able to share files per SAMBA/NFS and that is online most of the time (preferably 24/7).
    If you're interested, head over to github and check it out.
    Last edited by n0stradamus (2012-05-28 13:36:28)

    Yep, well capable of doing that which is why I'm asking - I can't do that without having to have difficult conversations with the security team here. And, no, I don't need to be told about the lack of security implications in doing this
    As far as keys, I've just set the SigLevel to "Never" as I trust the packages on my workstation, but this all feels a little hinky.

  • Time Capsule - Share over WAN

    My Time Capsule is connected to another router through Ethernet as bridge mode and wireless. Therefor the option to Share disc over WAN and i can't access it over the internet. Is it possible to set up the same Share over WAN feature on my routers web interence?

    Ok, lets get down and dirty.
    What modem router are you running?
    Does it have a DMZ and have you tried placing the TC in the DMZ?
    Many routers do not allow a connection to be made even after you have port forwarded because the firewall is turned on. Turn off the firewall in the router. Turn off the firewall in the router on the wan connection. Check that the computer firewall is also not preventing the connection.
    *Firewall is a key issue for failure to connect over WAN connections*
    Sometimes upnp in the router can mess up with manual port forwarding. Try turning off upnp.
    I would also try reset of the modem and if possible see if you can get something to ping respond to you. If the modem has a ping responder in it, turn it on to ensure you can actually get packets to the router and back again.
    I also have to ask you are actually testing from a different internet connection?? You cannot test wan port opening from LAN.. well not without nat loopback or remote proxy setup.

  • Install Arch with nfs shared pacman cache

    Hello,
    I would like to make a post of some information that worked for me. I think it could find its way into the wiki, but I prefer not to be the one to do that. Two reasons for that:
    1. Just becuase it worked for me doesn't mean it is proper. If someone can confirm it is an acceptable method...
    2. I am a wiki reader, not a writer
    My situation is that I have a 3G internet conection. I like to only download the packages once... I run nfs4 exports from my desktop computer to share user data, pacman cache and sync folders See the Pacman tips I just did fresh installs of my systems. After the main system was running, I wanted to use the existing pacman cache to install the second system. I followed the Beginners guide and also used the Install from ssh article. I created my partitions with gparted on a live stick. Boot into the Arch install media, and follow the instructions for mounting the partitions. And here is where I make a brief detour to utilize my existing pacman cache.
    For reference, my nfs exports are on the desktop computer (hostname is nas) and the pkg cache is exported as:
    nas:/pkg
    Databases are exported as:
    nas:/sync
    mkdir -p /mnt/var/cache/pacman/pkg
    mkdir -p /mnt/var/lib/pacman/sync
    mount the nfs exports:
    mount -t nfs4 nas:/pkg /mnt/var/cache/pacman/pkg
    mount -t nfs4 nas:/sync /mnt/var/lib/pacman/sync
    Now I am back on track with the Beginners guide...
    pacstrap -i /mnt base base-devel
    While in the chroot, be sure to install nfs-utils (and openssh if you want to continue ssh after boot)
    When running the genfstab, it will create tons of options for the nfs4 mounts. I edited those in nano to look like other references on the site:
    nas:/pkg /var/cache/pacman/pkg nfs4 defaults,x-systemd.automount 0 0
    nas:/sync /var/lib/pacman/sync nfs4 defaults,x-systemd.automount 0 0
    And of course unmounting at the end of the Beginners guide requires unmounting these two directories too.

    Yep, well capable of doing that which is why I'm asking - I can't do that without having to have difficult conversations with the security team here. And, no, I don't need to be told about the lack of security implications in doing this
    As far as keys, I've just set the SigLevel to "Never" as I trust the packages on my workstation, but this all feels a little hinky.

  • Printing broken for HP LJ1150 over Lan

    All of sudden today I cannot print to my LaserJet 1150, although all other Win boxes can. The printer is connected via USB to a MacMini and shared over Lan. It's rather embarrassing.
    When I attempt to print from say Safari, I get a dialog that says "Print - Error while Printing. OK"
    Please help. Thanks people, as always.
    I checked my Console.log and I attach what I see:
    ===========================================
    ===== Wednesday, December 12, 2007 4:47:57 PM Europe/Athens =====
    Dec 12 16:48:03 any /Applications/Safari.app/Contents/MacOS/Safari: CGContextSetStyle: invalid context
    Dec 12 16:48:03 any /Applications/Safari.app/Contents/MacOS/Safari: CGContextSetStyle: invalid context
    Dec 12 16:48:03 any /Applications/Safari.app/Contents/MacOS/Safari: CGContextSetStyle: invalid context
    Dec 12 16:48:03 any /Applications/Safari.app/Contents/MacOS/Safari: CGContextSetStyle: invalid context
    Dec 12 16:48:03 any /Applications/Safari.app/Contents/MacOS/Safari: CGContextSetStyle: invalid context
    Dec 12 16:48:03 any /Applications/Safari.app/Contents/MacOS/Safari: CGContextSetStyle: invalid context
    Dec 12 16:48:03 any /Applications/Safari.app/Contents/MacOS/Safari: CGContextSetStyle: invalid context
    Dec 12 16:48:03 any /Applications/Safari.app/Contents/MacOS/Safari: CGContextSetStyle: invalid context
    Dec 12 16:48:03 any /Applications/Safari.app/Contents/MacOS/Safari: CGContextSetStyle: invalid context
    Dec 12 16:48:03 any /Applications/Safari.app/Contents/MacOS/Safari: CGContextSetStyle: invalid context
    Dec 12 16:48:03 any /Applications/Safari.app/Contents/MacOS/Safari: CGContextSetStyle: invalid context
    Dec 12 16:48:03 any /Applications/Safari.app/Contents/MacOS/Safari: CGContextSetStyle: invalid context
    Dec 12 16:48:03 any /Applications/Safari.app/Contents/MacOS/Safari: CGContextSetStyle: invalid context
    Dec 12 16:48:03 any /Applications/Safari.app/Contents/MacOS/Safari: CGContextSetStyle: invalid context
    Dec 12 16:48:03 any /Applications/Safari.app/Contents/MacOS/Safari: CGContextSetStyle: invalid context
    Dec 12 16:48:03 any /Applications/Safari.app/Contents/MacOS/Safari: CGContextSetStyle: invalid context
    Dec 12 16:48:03 any /Applications/Safari.app/Contents/MacOS/Safari: CGContextSetStyle: invalid context
    Dec 12 16:48:03 any /Applications/Safari.app/Contents/MacOS/Safari: CGContextSetStyle: invalid context
    Dec 12 16:48:03 any /Applications/Safari.app/Contents/MacOS/Safari: CGContextSetStyle: invalid context
    Dec 12 16:48:03 any /Applications/Safari.app/Contents/MacOS/Safari: CGContextSetStyle: invalid context
    Dec 12 16:48:03 any /Applications/Safari.app/Contents/MacOS/Safari: CGContextSetStyle: invalid context
    Dec 12 16:48:03 any /Applications/Safari.app/Contents/MacOS/Safari: CGContextSetStyle: invalid context
    Dec 12 16:48:03 any /Applications/Safari.app/Contents/MacOS/Safari: CGContextSetStyle: invalid context
    Dec 12 16:48:03 any /Applications/Safari.app/Contents/MacOS/Safari: CGContextSetStyle: invalid context
    Dec 12 16:48:03 any /Applications/Safari.app/Contents/MacOS/Safari: CGContextSetStyle: invalid context
    Dec 12 16:48:03 any /Applications/Safari.app/Contents/MacOS/Safari: CGContextSetStyle: invalid context
    Dec 12 16:48:03 any /Applications/Safari.app/Contents/MacOS/Safari: CGContextSetStyle: invalid context
    Dec 12 16:48:03 any /Applications/Safari.app/Contents/MacOS/Safari: CGContextSetStyle: invalid context
    Dec 12 16:48:03 any /Applications/Safari.app/Contents/MacOS/Safari: CGContextSetStyle: invalid context
    Dec 12 16:48:03 any /Applications/Safari.app/Contents/MacOS/Safari: CGContextSetStyle: invalid context
    Dec 12 16:48:03 any /Applications/Safari.app/Contents/MacOS/Safari: CGContextSetStyle: invalid context
    Dec 12 16:48:03 any /Applications/Safari.app/Contents/MacOS/Safari: CGContextSetStyle: invalid context
    Dec 12 16:48:03 any /Applications/Safari.app/Contents/MacOS/Safari: CGContextSetStyle: invalid context
    Dec 12 16:48:03 any /Applications/Safari.app/Contents/MacOS/Safari: CGContextSetStyle: invalid context
    Dec 12 16:48:03 any /Applications/Safari.app/Contents/MacOS/Safari: CGContextSetStyle: invalid context
    Dec 12 16:48:03 any /Applications/Safari.app/Contents/MacOS/Safari: CGContextSetStyle: invalid context
    Dec 12 16:48:03 any /Applications/Safari.app/Contents/MacOS/Safari: CGContextSetStyle: invalid context
    Dec 12 16:48:03 any /Applications/Safari.app/Contents/MacOS/Safari: CGContextSetStyle: invalid context
    Dec 12 16:48:03 any /Applications/Safari.app/Contents/MacOS/Safari: CGContextSetStyle: invalid context
    Dec 12 16:48:03 any /Applications/Safari.app/Contents/MacOS/Safari: CGContextSetStyle: invalid context
    Dec 12 16:48:03 any /Applications/Safari.app/Contents/MacOS/Safari: CGContextSetStyle: invalid context
    Dec 12 16:48:03 any /Applications/Safari.app/Contents/MacOS/Safari: CGContextSetStyle: invalid context
    Dec 12 16:48:03 any /Applications/Safari.app/Contents/MacOS/Safari: CGContextSetStyle: invalid context
    Dec 12 16:48:03 any /Applications/Safari.app/Contents/MacOS/Safari: CGContextSetStyle: invalid context
    Dec 12 16:48:03 any /Applications/Safari.app/Contents/MacOS/Safari: CGContextSetStyle: invalid context
    Dec 12 16:48:03 any /Applications/Safari.app/Contents/MacOS/Safari: CGContextSetStyle: invalid context
    2007-12-12 16:48:03.806 Safari[306] PMSessionValidatePrintSettings failed (error code = -50)
    Dec 12 16:48:03 any /Applications/Safari.app/Contents/MacOS/Safari: CGContextSetStyle: invalid context
    Dec 12 16:48:03 any /Applications/Safari.app/Contents/MacOS/Safari: CGContextSetStyle: invalid context
    Dec 12 16:48:03 any /Applications/Safari.app/Contents/MacOS/Safari: CGContextSetStyle: invalid context
    Dec 12 16:48:03 any /Applications/Safari.app/Contents/MacOS/Safari: CGContextSetStyle: invalid context
    Dec 12 16:48:03 any /Applications/Safari.app/Contents/MacOS/Safari: CGContextSetStyle: invalid context
    Dec 12 16:48:03 any /Applications/Safari.app/Contents/MacOS/Safari: CGContextSetStyle: invalid context
    Dec 12 16:48:03 any /Applications/Safari.app/Contents/MacOS/Safari: CGContextSetStyle: invalid context
    Dec 12 16:48:03 any /Applications/Safari.app/Contents/MacOS/Safari: CGContextSetStyle: invalid context
    Dec 12 16:48:03 any /Applications/Safari.app/Contents/MacOS/Safari: CGContextSetStyle: invalid context
    Dec 12 16:48:03 any /Applications/Safari.app/Contents/MacOS/Safari: CGContextSetStyle: invalid context
    Dec 12 16:48:03 any /Applications/Safari.app/Contents/MacOS/Safari: CGContextSetStyle: invalid context
    Dec 12 16:48:03 any /Applications/Safari.app/Contents/MacOS/Safari: CGContextSetStyle: invalid context
    Dec 12 16:48:03 any /Applications/Safari.app/Contents/MacOS/Safari: CGContextSetStyle: invalid context
    Dec 12 16:48:03 any /Applications/Safari.app/Contents/MacOS/Safari: CGContextSetStyle: invalid context
    Dec 12 16:48:03 any /Applications/Safari.app/Contents/MacOS/Safari: CGContextSetStyle: invalid context
    Dec 12 16:48:03 any /Applications/Safari.app/Contents/MacOS/Safari: CGContextSetStyle: invalid context
    Dec 12 16:48:03 any /Applications/Safari.app/Contents/MacOS/Safari: CGContextSetStyle: invalid context
    Dec 12 16:48:03 any /Applications/Safari.app/Contents/MacOS/Safari: CGContextSetStyle: invalid context
    2007-12-12 16:48:03.818 Safari[306] PMSessionEndDocumentNoDialog failed (error code = -30871)
    2007-12-12 16:48:04.601 Safari[306] Failed to end PMPrintContext

    Thanks greg,
    I had already Safe Booted and then re-added the printer by the time I had read your post. All is fine for now.
    Thanks.
    PS Prior to Safe-Booting, I had deleted/re-added the printer a number of times. Every time I attempted to print after adding the printer, it just locked and reproduced the error. Only after Safe-Boot did it come back alive.

  • FTP/SFTP/FISH (etc) slow file transfer rate over LAN

    Hi everyone,
    I have a problem with transferring files over my home network that has been bothering me for quite some time.
    I have a 802.11n router which should provide me with the transfer rate up to 150 Mbps (afaik). When I download files from the Internet, 3 MB/s data transfer rate is of no problem.
    However, when receiving or sending data over LAN, the transfer rate is much slower (1.8 MB/s).
    My rough guess is (after reading some papers on this topic) that TCP protocol is causing this (its flow control feature to be exact), since TCP max window size is too small on Linux by default.
    So, setting TCP max window size to a greater number should solve this.
    I tried putting this:
    # increase TCP max buffer size setable using setsockopt()
    # 16 MB with a few parallel streams is recommended for most 10G paths
    # 32 MB might be needed for some very long end-to-end 10G or 40G paths
    net.core.rmem_max = 16777216
    net.core.wmem_max = 16777216
    # increase Linux autotuning TCP buffer limits
    # min, default, and max number of bytes to use
    # (only change the 3rd value, and make it 16 MB or more)
    net.ipv4.tcp_rmem = 4096 87380 16777216
    net.ipv4.tcp_wmem = 4096 65536 16777216
    # recommended to increase this for 10G NICS
    net.core.netdev_max_backlog = 30000
    # these should be the default, but just to be sure
    net.ipv4.tcp_timestamps = 1
    net.ipv4.tcp_sack = 1
    in /etc/sysctl.conf but to no avail.
    So either there is no problem with the max window size setting, or the Linux kernel ignores it (maybe because /proc is no longer supported?).
    Thanks for any neat ideas.
    Last edited by Vena (2012-06-01 21:48:14)

    Bump? No ideas whatsoever?

  • Has anyone successfully used the serial-over-lan feature in ipmitool?

    The IPMI hardware in Apple's Intel Xserves ostensibly supports serial-over-LAN access via ipmitool. Attempting to access it with ipmitool doesn't appear to work, however; the command
    ipmitool -H hostname -U username sol activate
    simply returns without entering a serial session. I am able to perform other queries on the same interface with ipmitool, however. Is there some setting that I must enable in order to permit the above command to succeed?

    I have version 2.0.2 installed. The firmware is not up to date (its boot ROM is at version XS11.0080.B01); however, I never was able to figure out how to update it (see http://discussions.apple.com/thread.jspa?threadID=1569860&tstart=0). Querying the bmc info with ipmitool does work; it reports firmware revision 1.2.8. No manual changes were made within /dev to my knowledge.

  • X.25 over LAN using hme

    Hi there,
    I have to use hme for X.25 over LAN.
    But I can't see the hme in the device list on x25tool screen.
    I'm using SunLink X.25 9.0.
    Is there any way ? Modify some config files ?
    Thanks a lot

    Hi franky,
    I have just read your question with regards to configuring X.25
    over a LAN connection.
    What type/model of system is X.25 being configured on ?
    Has the hme ethernet card been added recently to the system?
    What devices do you have available to you ?
    Are you referring to the list under:
    Edit > Add Link > LAN > Device?
    Do you see the hme definition under the Board definition list?
    ie: Boards > Definition menu
    If not add a new device specifying a symbolic name Path to device
    which is /dev/hme, L for Lan device, number of lines/ports, MRU (usually 1515 for lan connections) and a Comment.
    I hope that this helps;
    Regards
    Derek SUN-DTS

  • "Share over Wan" - passworded but log files say differently?

    In a desperate attempt to get backup features to work on my TC, I enabled "Share over Wan". Thinking that I've got more than enough security with disk passwords, I didn't automatically think there'd be a problem.
    I then looked at my log files on my TC a day later and saw successful logins from IP's other than mine - but all within the same subdomain.
    Does "Share over Wan" supersede the disk passwords? I've tried accessing from other subdomains (my work) and always get prompted for passwords. Should I be worried about these successful logins or ignore them as successful pings (or the like?)
    I've, of coarse, now turned off "Share over Wan".

    awkwood wrote:
    Cheers omp!
    I have one suggestion: your count_lines method will be quite slow on large log files.
    Rather than use readlines you can optimize the read operations like so:
    line_count = 0
    File.open(identifier.to_cache_path) do |f|
    while block = f.read(1024)
    line_count += block.count("\n")
    end
    end
    The speed boost makes it comparable to shelling out to wc.
    Thanks for the suggestion; I just committed it.

  • RD120 Serial over Lan configuration.

    Hi,
    Does anyone know what the settings in the bios/BMC need to be on the RD120 to allow Serial over LAN...
    I am remote so I cannot see the bios or BMC utilities. There is no documentation on this on the Lenove website. I do not have an RSA adapter for this box as I really dont think I need it for Serial over LAN. I can see the BMC settings with ipmitool so I just need the SOL configuration steps.
    Does anyone know if I can set this up? I am looking for documentation on how to configure the bios and BMC..
    I can't find it anywhere.
    Thanks.

    Hi Bill,
    SoL is a special text based management path for users to access IBM blade servers via the Management Module uplink. On the IGESM, in code at 12.1(22)AY1 and below, it is necessary to configure a special VLAN on the IGESM to permit SoL to operate. Details on configuring SoL on older code IGESMs can be found in section 7.8 of the IGESM Redpaper:
    http://www.redbooks.ibm.com/abstracts/redp3869.html
    On code versions at 12.1(22)EA6 and above, there is a built in special hidden VLAN (4095) that does not require any configuration to support SoL. Based on this simplification, it is recommend to use code 12.1(22)EA6 or later if the use of SoL is desired.
    Thanks, Matt

  • Mac OS X 10.4.9 and Music Lab's "Midi Over LAN" broken?

    Hi all,
    I run "music lab's midi over lan" and am wondering if it doesn't work under the new OSX 10.4.9......
    I was forced to update 1 of my slave G5s and now "MolCP" no longer worx...... I can't be certain that it is 10.4.9, but I'm trouble-shooting,
    thanx in advance.
    SvK

    Er, that's not forced, that's just not knowing any better!
    You should have just gone to Apple and downloaded the 10.4.8 combo installer.
    http://www.apple.com/support/downloads/macosx1048comboupdateppc.html
    http://search.info.apple.com/?q=macos+x10.4.8&type=kbdload&search=Search&lr=lang_en&search=Go
    OSX updates are always recommended to be done from the full combo update, rather than the smaller cut-down software updates anyway.

  • HT1725 I have downloaded a movie and the downlaod has reached the end it will give a message saying "processing " and then it will start all over again . My pain I have spent so much on Internet data bundles  I can't afford to spend any more for just  one

    I have downloaded a movieĀ  I purchased form iTunes and every time I get to the end of the download I will see a message "processing " and before i know it , the download will start all over again . My pain is i have spent so much money on the Internet data bundle almost twice the cost of the movie ! i can't afford to keep repeating this process , pls any ideas on how to get me out of this mess !

    can you stop the download completely? try to stop the download, delete the downloaded file and then re-downloading it. itunes should save your purchase so you won't have to pay every time you download.

  • Time Capsule backup over LAN

    Hello,
    is it possible to Time Capsule backup a non wifi Mac over LAN?

    of course. you can back up over an ethernet connection.

  • Another simple bash script to clean pacman cache

    here is a simple script that I have written which cleans pacman cache folder in a way that only the packages which are now "updated" in the repositories, will get removed. This is different from what "pacman -Sc" does. pacman -Sc also removes any package which is not installed, while this script keeps all the packages which are updated whether they are installed or not.
    The functionality is some how like what "apt-get autoclean" does in debian.
    to use this script you need to run it with "list" or "clean" arguments.  you can also use the "help" argument for more help.
    I hope it helps
    #! /bin/bash
    # clcache - This script cleans pacman cache folder in a way that only the packages
    #+ which are now updated in the repositories, will get removed. This is
    #+ different from what "pacman -Sc" does. pacman -Sc also removes any package
    #+ which is not installed, while this script keeps all the packages which are
    #+ updated whether they are installed or not.
    # I have tweaked this script to be as fast as possible, it might still need a
    #+ couple of minutes to compelete based on the size of your cache folder.
    # to use this script you need to run it with "list" or "clean" arguments.
    # you can also use the "help" argument for more help.
    # This script is written by "Ali Mousavi". Please report bugs to [email protected]
    DIR="/var/cache/pacman/pkg" #the default directory of pacman cache.
    ROOT_UID=0 #Only users with $UID 0 have root privilages.
    TMPFILE="/tmp/cache.tmp"
    # Run as root
    if [ "$UID" -ne "$ROOT_UID" ]
    then
    echo "Must be root to run this script"
    exit 1
    fi
    # Check for the arguments
    if [ -z "$1" ]
    then
    echo -e 'What should I do?\nValid Argument are "list", "clean" or "help"'
    exit 1
    elif [ "$1" = "list" ]
    then
    ACTION="ls"
    MESSAGE="Are you sure you want to continue?"
    elif [ "$1" = "clean" ]
    then
    ACTION="rm -vf"
    MESSAGE="Are you sure you want to remove outdated packages? This process can not be undone!"
    elif [ "$1" = "help" -o "$1" = "-h" -o "$1" = "--help" ]
    then
    echo -e "This script checks the packages in your pacman cache directory and removes the packages that are outdated. It doesn't matter if the package is installed or not.\n\n3 arguments can be passed to the script:\n\nlist:\n\tchecks for package that are outdated and prints the names.\n\nclean:\n\tremoves outdated packages.\n\nhelp,-h,--help:\n\tprints this help text.\n\nThis script is written by \"Ali Mousavi\". Please report bugs to [email protected]"
    exit 0
    else
    echo 'Valid Argument are "list", "clean" or "help"'
    exit 1
    fi
    # Check if the user is sure!
    echo "This might take a while based on the amount of cached packages."
    echo -n "$MESSAGE(y/n) "
    read ANS
    if [ $ANS = "y" -o $ANS = "Y" -o $ANS = "yes" ]
    then
    echo "Processing packages..."
    elif [ $ANS = "n" -o $ANS = "N" -o $ANS = "No" ]
    then
    echo "Exiting on user request"
    exit 0
    else
    echo "Invalid answer"
    exit 1
    fi
    # Process the packages
    cd $DIR #change to cache directory.
    pacman -Sl | awk '{ print $2" "$3; }' > $TMPFILE
    for f in $(ls $DIR)
    do
    pname=$(file $f | cut -d: -f1) #Produces filename, like: fetchmail-6.3.19-1-i686.pkg.tar.xz"
    spname=$(echo $pname | sed 's/-[0-9][0-9]*.*//g') #removes package version: fetchmail
    pver=$(echo $pname | sed 's/.*-\([0-9\-\.][0-9\-\.]*-[0-9\-\.][0-9\-\.]*\).*/\1/g') #using pacman -Qi for all files takes a lot of time.
    if [ $(echo $pver | grep '[^0-9\-\.\-\-]' | wc -l) != 0 ] #checks if package version is alright
    then
    pver=$(pacman -Qpi $f | grep Version | awk '{print $3}')
    fi
    newpver=$(grep -e "^$spname " $TMPFILE | awk '{ print $2 }')
    if [[ $newpver != $pver ]]
    then
    $ACTION $f
    fi
    done
    rm -f $TMPFILE
    echo "Outdated packages processed successfully!"
    exit 0
    Last edited by tuxitop (2011-09-13 09:24:26)

    tuxitop wrote:# Check for the arguments
    if [ -z "$1" ]
    then
    echo -e 'What should I do?\nValid Argument are "list", "clean" or "help"'
    exit 1
    elif [ "$1" = "list" ]
    then
    ACTION="ls"
    MESSAGE="Are you sure you want to continue?"
    elif [ "$1" = "clean" ]
    then
    ACTION="rm -vf"
    MESSAGE="Are you sure you want to remove outdated packages? This process can not be undone!"
    elif [ "$1" = "help" -o "$1" = "-h" -o "$1" = "--help" ]
    then
    echo -e "This script checks the packages in your pacman cache directory and removes the packages that are outdated. It doesn't matter if the package is installed or not.\n\n3 arguments can be passed to the script:\n\nlist:\n\tchecks for package that are outdated and prints the names.\n\nclean:\n\tremoves outdated packages.\n\nhelp,-h,--help:\n\tprints this help text.\n\nThis script is written by \"Ali Mousavi\". Please report bugs to [email protected]"
    exit 0
    else
    echo 'Valid Argument are "list", "clean" or "help"'
    exit 1
    fi
    1. `echo -e 'foo\nbar\nbaz'` gets long and unreadable quickly. Instead, use here documents:
    cat <<EOF
    What should I do?
    Valid Argument are "list", "clean" or "help"
    EOF
    2. Use a case command, looks cleaner:
    case "$1" in
    list) ... ;;
    clean) ... ;;
    help|-h|--hep) ... ;;
    # Check if the user is sure!
    echo "This might take a while based on the amount of cached packages."
    echo -n "$MESSAGE(y/n) "
    read ANS
    if [ $ANS = "y" -o $ANS = "Y" -o $ANS = "yes" ]
    then
    echo "Processing packages..."
    elif [ $ANS = "n" -o $ANS = "N" -o $ANS = "No" ]
    then
    echo "Exiting on user request"
    exit 0
    else
    echo "Invalid answer"
    exit 1
    fi
    Try:
    read -p "hello: " -r
    echo $REPLY
    And again, `case` should be cleaner in this case.
    # Process the packages
    cd $DIR #change to cache directory.
    pacman -Sl | awk '{ print $2" "$3; }' > $TMPFILE
    While you quoted a lot, you left these two out. "$DIR" and "$TMPFILE" should be quoted, otherwise whitespaces will break the code.
    for f in $(ls $DIR)
    Apart from the same missing quotes, calling `ls` is a waste here. The following is sufficient and (maybe surprisingly) more accurate:
    for f in *
    How is it more accurate? Run this test script:
    #!/bin/bash
    DIR=/tmp/foo
    mkdir -p "$DIR"
    cd "$DIR"
    touch a\ b c$'\n'd
    for i in *; do
    printf '+%s+\n' "$i"
    done
    printf '%s\n' ---
    for i in $(ls $DIR); do
    printf '+%s+\n' "$i"
    done
    Let's not go too far here. Just get the idea.
    do
    pname=$(file $f | cut -d: -f1) #Produces filename, like: fetchmail-6.3.19-1-i686.pkg.tar.xz"
    Calling `file` here is, again, unnecessary. Also, filename of a package can contain ":", e.g., vi-1:050325-1-i686.pkg.tar.xz, which breaks your code.
    Don't complicate things:
    pname=$f
    spname=$(echo $pname | sed 's/-[0-9][0-9]*.*//g') #removes package version: fetchmail
    Broken for ntfs-3g-2011.4.12-1-i686.pkg.tar.xz, nvidia-173xx-utils-173.14.31-1-i686.pkg.tar.xz, etc...   Something less lousy:
    sed 's/\(-[^-]\+\)\{3\}$//' <<< "$pname"
    pver=$(echo $pname | sed 's/.*-\([0-9\-\.][0-9\-\.]*-[0-9\-\.][0-9\-\.]*\).*/\1/g') #using pacman -Qi for all files takes a lot of time.
    Although this might work for now, this would break if we had an architecture that starts with a digit, e.g. 686.  Something less lousy:
    sed 's/\(.*\)-\([^-]\+-[^-]\+\)-[^-]\+$/\2/' <<< "$pname"
    if [ $(echo $pver | grep '[^0-9\-\.\-\-]' | wc -l) != 0 ] #checks if package version is alright
    then
    pver=$(pacman -Qpi $f | grep Version | awk '{print $3}')
    fi
    Again, calling `wc` here is a waste. Anyway, why is this check necessary at all?
    newpver=$(grep -e "^$spname " $TMPFILE | awk '{ print $2 }')
    if [[ $newpver != $pver ]]
    then
    $ACTION $f
    fi
    done
    rm -f $TMPFILE
    echo "Outdated packages processed successfully!"
    exit 0
    The post is getting too long, so so much from me. If there's anything you don't understand yet, read bash(1).
    If I sound harsh or anything, don't be discouraged. Just keep reading, keep improving.
    Last edited by lolilolicon (2011-09-13 12:53:04)

Maybe you are looking for