Ok, I understand, now. I just leave multiple desktops in place and switch between them as I want. But perhaps you have reasons to do it as you do. That is one thing I really appreciate about Linux, the fact that there are many, many ways to accomplish almost everything and that what is right and works for me may not be what works best for you.

Your scripting style is irrelevant so long as it gets the job done for you. And one tenet the Unix/Linux Philosophy is, "automate everything," which is what you have done.


On 02/26/2015 09:21 AM, Niki Kovacs wrote:


Le 26/02/2015 15:00, David Both a écrit :
Perhaps I have not been following closely enough, but why go backwards?
Why not start with a "minimal" installation and then add only those
packages that are needed for your situation?

Here's why.

I'm currently experimenting with CentOS on my workstation, trying out different desktop environments like GNOME3, KDE, MATE, Xfce. But at the same time, I'm also working on that same workstation, for example developing websites on a local LAMP stack, using multimedia apps like Audacity to edit some audio tracks for my training courses, etc.

When switching from one desktop environment to another for the sake of trying it out, there's always tons of cruft on the system, even after a yum groupremove "Old Desktop Environment". And I don't want to do a fresh reinstallation, because I have all my data and files in place, and this is a RAID 1 installation, so it's not exactly trivial to reinstall and put everything back in place.

Anyway, I spent a couple hours experimenting, and I found a satisfying solution. It's not very elegant, but it works. Here goes.

1. First, make a list of the packages contained in a minimal installation. This is easy, since I can do a minimal installation in a virtual guest, and then run the following little script:

#!/bin/bash
#
# create_package_list.sh
#
# (c) Niki Kovacs, 2014

TMP=/tmp
RPMLIST=$TMP/rpmlist.txt
PKGLIST=$TMP/pkglist.txt
rm -f $RPMLIST $PKGLIST
rpm -qa | sort > $RPMLIST
sed 's/-[^-]*-[^-]*\.[^.]*\.[^.]*$//' $RPMLIST > $PKGLIST

2. I copy that package list to the 'core' file in my Git repo and run the following script on the system I want to prune:

#!/bin/bash
#
# purge_system.sh
#
# (c) Niki Kovacs, 2014

CWD=$(pwd)
TMP=/tmp

RPMLIST=$TMP/rpmlist.txt
PKGLIST=$TMP/pkglist.txt
PKGINFO=$TMP/pkg_database

rpm -qa | sort > $RPMLIST

sed 's/-[^-]*-[^-]*\.[^.]*\.[^.]*$//' $RPMLIST > $PKGLIST

PACKAGES=$(egrep -v '(^\#)|(^\s+$)' $PKGLIST)

rm -rf $RPMLIST $PKGLIST $PKGINFO
mkdir $PKGINFO

# Create core package database
echo
echo "+=================================="
echo "| Creating core package database..."
echo "+=================================="
echo
sleep 3
CORE=$(egrep -v '(^\#)|(^\s+$)' $CWD/../pkglists/core)
for PACKAGE in $CORE; do
  printf "."
  touch $PKGINFO/$PACKAGE
done

unset CRUFT

# Check installed packages against core package database
echo
echo
echo "+========================================================"
echo "| Checking for packages to be removed from your system..."
echo "+========================================================"
echo
sleep 3
for PACKAGE in $PACKAGES; do
  if [ -r $PKGINFO/$PACKAGE ]; then
    continue
  else
    printf "."
    CRUFT="$CRUFT $PACKAGE"
  fi
done

echo
echo

# Remove all non-core packages
yum remove $CRUFT

I've tested this a few times, and it works as expected. I know my scripting style is a bit hodge-podge. If you have a more elegant solution, I'm always open for suggestions.

Cheers,

Niki



--


*********************************************************
David P. Both, RHCE
Millennium Technology Consulting LLC
Raleigh, NC, USA
919-389-8678

db...@millennium-technology.com

www.millennium-technology.com
www.databook.bz - Home of the DataBook for Linux
DataBook is a Registered Trademark of David Both
*********************************************************
This communication may be unlawfully collected and stored by the National
Security Agency (NSA) in secret. The parties to this email do not consent to the
retrieving or storing of this communication and any related metadata, as well as
printing, copying, re-transmitting, disseminating, or otherwise using it. If you
believe you have received this communication in error, please delete it
immediately.

_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos

Reply via email to