Saturday, January 6, 2018

apt - Off-line Repository and software removal



I read up on the process here and came up with this script:



for i in `ls -1 /var/cache/apt/archives` ; do sudo cp /var/cache/apt/archives/$i /home/jj/Documents/Repository ; done



and to re-install:



sudo dpkg -i /home/jj/Documents/Repository/*.deb


Question:
how can I remove these (and their dependencies?) via a script before the re-install?




aisleriot
evolution
evolution-common
evolution-data-server
evolution-exchange
evolution-indicator
evolution-plugins
gbrainy
gnome-mahjongg
gnome-sudoku

gnomine
gwibber
gwibber-service
libevolution
openoffice.org-draw
openoffice.org-impress
quadrapassel


Thank you for your time.




I now see this link of which I chose this method: sudo apt-get remove -y $package
and probably cleandeb afterwords.
Advice? Suggestions?



Thank you!



There is a bash script for removing the dependencies after removing the packages.



#!/bin/bash


OLDCONF=$(dpkg -l|grep "^rc"|awk '{print $2}')
CURKERNEL=$(uname -r|sed 's/-*[a-z]//g'|sed 's/-386//g')
LINUXPKG="linux-(image|headers|ubuntu-modules|restricted-modules)"
METALINUXPKG="linux-(image|headers|restricted-modules)-(generic|i386|server|common|rt|xen)"
OLDKERNELS=$(dpkg -l|awk '{print $2}'|grep -E $LINUXPKG |grep -vE $METALINUXPKG|grep -v $CURKERNEL)
YELLOW="\033[1;33m"
RED="\033[0;31m"
ENDCOLOR="\033[0m"


if [ $USER != root ]; then
echo -e $RED"Error: must be root"
echo -e $YELLOW"Exiting..."$ENDCOLOR
exit 0
fi

echo -e $YELLOW"Cleaning apt cache..."$ENDCOLOR
aptitude clean

echo -e $YELLOW"Removing old config files..."$ENDCOLOR

sudo aptitude purge $OLDCONF

echo -e $YELLOW"Removing old kernels..."$ENDCOLOR
sudo aptitude purge $OLDKERNELS

echo -e $YELLOW"Emptying every trashes..."$ENDCOLOR
rm -rf /home/*/.local/share/Trash/*/** &> /dev/null
rm -rf /root/.local/share/Trash/*/** &> /dev/null

echo -e $YELLOW"Script Finished!"$ENDCOLOR



Copy the script and paste it in your text editor.And save the file with .sh extension(ie cleaner.sh)Right click the file choose properties>>permissions and check execute..



To run this script,type the following in terminal.



sudo bash /path/to/the/script

No comments:

Post a Comment

11.10 - Can't boot from USB after installing Ubuntu

I bought a Samsung series 5 notebook and a very strange thing happened: I installed Ubuntu 11.10 from a usb pen drive but when I restarted (...