I'd like to be able add excludes to an array and exclude them from the package list. 'grep -v' I don't think will work as it will only look at lines. Anyone have an idea on how to do this?
]]>@Ghost, I would have used packup but I had a couple downgraded packages and I wanted to be able to troubleshoot it.
The tip about the grep -v doing 'shortnameplus' was a good tip, Profjim. I hadn't read this last post before and during the reinstall I was a bit surprised nvidia wasn't installed so... all is good now.
I created a script to be able to create the backup list and restores from it simliar to ghosts and am able to run it in cron job. Probably not a big deal, but... phhht. Here it is for anyone that can use it:
#!/bin/bash
# pacbac - Create and restore from list all installed packages
# Package list locations (official and local)
pkglsoff=/opt/backup/pc-emach/arch-pkglist-official
pkglsloc=/opt/backup/pc-emach/arch-pkglist-local
# Exclude packages
excldoff=()
excldloc=()
# Use filename as program name
prog=${0##*/}
# Text color variables
bldblu='\e[1;34m' # blue
bldred='\e[1;31m' # red
bldwht='\e[1;37m' # white
txtcyn='\e[0;36m' # cyan
txtund=$(tput sgr 0 1) # underline
txtrst='\e[0m' # text reset
info=${bldwht}*${txtrst}
pass=${bldblu}*${txtrst}
warn=${bldred}!${txtrst}
# If restoring, be sure yaourt is installed
if [[ "$1" == 'r' ]] && [[ -z $(pacman -Qs yaourt) ]]; then
echo ""
echo -e "$warn $prog requires ${txtund}}Yaourt${txtrst} to be installed."
echo -e " ${txtcyn}http://wiki.archlinux.org/index.php/Yaourt${txtrst}"
echo ""
exit
fi
case $1 in
b ) # Create list of official repository packages (core, extra, community)
echo -e "$info Creating list of official (core/extra/community packages) packages installed."
# Create list, remove local, base
pacman -Qqe | grep -vx "$(pacman -Qqg base)" | grep -vx "$(pacman -Qqm)" > "$pkglsoff"
# Create list of local packages (includes the AUR)
echo -e "$info Creating list of local (includes AUR) packages installed."
pacman -Qqm > "$pkglsloc"
echo -e "$pass Official package list saved to ${txtund}"$pkglsoff"${txtrst}"
echo -e "$pass Local package list saved to ${txtund}"$pkglsloc"${txtrst}" ;;
r ) # Update repository database, then restore packages from list
echo -e "$info Installing packages from lists"
sudo pacman -Sy
# use -f to overwrite conflicting files
sudo pacman -S --needed $(cat "$pkglsoff")
# Yaourt doesn't have --needed check
yaourt -S $(cat "$pkglsloc" | grep -vx "$(pacman -Qqm)") ;;
* ) echo -e " pacbac b - build installed packages list. (dir:${txtund}"${pkglsoff%/*}"${txtrst})"
echo -e " pacbac r - restore installed packages from package list." ;;
esac
The problem with that is that if you have "shortnameplus" in the list being filtered, and "shortname" in the filtering list, then "shortnameplus" is going to get suppressed.
Best to add a "-x" (match whole line) or "-w" (match words) to the filtering "grep -v".
]]>pacman -S --needed $(cat pkglist)
yaourt -S $(cat pkglocallist)
Oh and thanks for the --needed, hadn't thought of that.
Wow, Ghost, packup looks pretty cool. I'm gonna backup now and try it. Not sure how this is gonna go. I might have to do this manually. I got KDE installed and not sure just a pacman -Syu will do the trick. I'll get back.
]]>haha of course they could, but the idea is to do the first command as a daily backup... then you'll only run the second post-crash/reinstall.
besides, the above one liner will do nothing... because no packages will be --needed when the targets are built directly from the current -Qqe
I had skipped over some posts in the middle (i.e. #4) and didn't get why you posted that.. makes sense now.
]]>brisbin33 wrote:pacman -Qqe | grep -v "$(pacman -Qqm)" > pacman.lst
and
cat pacman.lst | xargs pacman -S --needed --noconfirm
just fyi, these can be combined into:
pacman -S --needed --noconfirm $(pacman -Qqe | grep -v "$(pacman -Qqm)")
haha of course they could, but the idea is to do the first command as a daily backup... then you'll only run the second post-crash/reinstall.
besides, the above one liner will do nothing... because no packages will be --needed when the targets are built directly from the current -Qqe
]]>pacman -Qqe | grep -v "$(pacman -Qqm)" > pacman.lst
and
cat pacman.lst | xargs pacman -S --needed --noconfirm
just fyi, these can be combined into:
pacman -S --needed --noconfirm $(pacman -Qqe | grep -v "$(pacman -Qqm)")
that said,
pacman -Qqe | grep -v "$(pacman -Qqm)" > pacman.lst
and
cat pacman.lst | xargs pacman -S --needed --noconfirm
are the best backup/restore lines i've seen (don't remember where i got them tho).
that will install only the packages you don't have installed already as well as pull in any needed deps. after that, -Syu and you're good to go.
/edit: typo
]]>EDIT: Sorry, I misread. It won't
]]>#!/bin/bash
# paclist - creates list of all installed packages
# reinstall with pacman -S $(cat pkglist)
USER=gen2ly
pacman -Qqet | grep -v "$(pacman -Qqg base)" | grep -v "$(pacman -Qqm)" > /home/ $USER/Desktop/pkglist
# A list of local packages (includes AUR and locally installed)
pacman -Qm > /home/$USER/Desktop/pkglocallist
This will do, will probably have to reinstall AUR packages manually but no big deal.
]]>