Updating packages from a folder

Today I had to update a set of installed packages from a folder, but in that folder there were some deb packages that were not installed and that I did not want to install, so I thought of doing a script that check if that package were installed and if so, update them with the deb file.

Of course, the main issue here is that the deb package name is not the name of the package once installed (the deb is , say samba_1.2.3..deb while the package name would be just samba), so parsing basenames (and taking out the version numbers which where preceded by a _) was the clue here:

01#!/bin/bash
02# END
03for e in $(ls -F | grep -v [/,*])
04do
05#we'll store in $filename the dpkg package name.
06filename=$(echo $e | cut -d_ -f1)
07dpkg -l | grep $filename > /dev/null
08 
09    if [ $? == 0 ] ; then
10 
11        sudo dpkg -i $e
12    else
13        echo $filename "is not installed, ignored"
14    fi
15done

Deja un comentario