summaryrefslogtreecommitdiffstats
path: root/arch-pkgs-update
blob: 3bd8f7491d3a26c16ead46d0b7a58ec8264328b0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/bin/bash

[ $# -lt 1 ] && echo "usage $0 pkg_list (generated with pacman -Q)" && exit 1

tmp=/tmp/__pkgs
bad=/tmp/__pkgs-bad
[ -e $tmp ] && rm $tmp
[ -e $bad ] && rm $bad

echo " * read packages list"
pkgs=`cat $1 | gawk '{ print $1 }'`
echo " * search packages to install"
for pkg in $pkgs; do
    pacman -Q $pkg >/dev/null 2>&1 || echo $pkg >> $tmp
done
if [ -e $tmp ]; then
    echo " * install packages"
    pacman -S `cat $tmp`
    if [ $? -ne 0 ];
    then
        echo " * clean package list"
        pacman -S `cat $tmp` 2>&1 | cut -d ':' -f 3 > $bad
        cat $bad | while read pkg; do sed -i "/$pkg/d"; done
        echo " * install packages"
        pacman -S `cat $tmp`
    fi
    pacman -Scc
    [ -r $tmp ] && echo "installed packages in $tmp"
    [ -r $bad ] && echo "failed packages in $bad"
    echo " * done"
else
    echo " * all good"
fi