#!/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