UbuntuThis forum is for the discussion of Ubuntu Linux.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I'm new to ubuntu but not linux. I have ubuntu 7.04 for my desktop and I have added a number of other packages via synaptic. When 7.10 gusty comes out I will re-install (never like upgrading too messy). Is there away I can list all of the packages that are not standard (base ubuntu) I know this is possible in Redhat but no idea for ubuntu.
That Way I can re-add any programs to the new build, for example I have added firestarter, bluefish, rapidsvn etc etc..
You can look at aptitude where you can find all the applications installed.
However, I suggest to reconsider the idea of upgrading instead of a fresh install. The upgrade procedure is very simple in ubuntu, remember this a reccomended distro for newbies.
You can look at aptitude where you can find all the applications installed.
However, I suggest to reconsider the idea of upgrading instead of a fresh install. The upgrade procedure is very simple in ubuntu, remember this a reccomended distro for newbies.
I agree with him actually, I hate upgrading. I've used Ubuntu since Dapper, and always do clean installs.
Frag..
What I think you want to do is "clone" your packages. Its generally worked well for me, this is how I've done it. Now granted, I've never tried this when moving from moving from say, Dapper to Edgy, but I think it will still work. I've generally done it to duplicate Feisty installs on a couple of different computers.
in a terminal...
Code:
dpkg --get-selections > ~/my-packages
This will create a file called "my-packages" in your home folder. back up that file. Install Gutsy. Once gutsy is installed, enable/add any additional repositories that you had under Feisty.
KPackage (my current choice of manager) has an "Installed" tab, & I imagine Synaptic has equivalent functionality. This, however, shows all installed packages, not just those added since the base install.
dpkg -l will give you a list of currently installed packages. If you do that on your current system & save it in a file, you will be able to compare it to its output on the new install. I would do something like this:
Code:
## on old system
dpkg -l | tee dpkg-l.7_04.00.txt | awk '/^ii/{print $2}' >dpkg-l.7_04.1.txt
## carry both files to new system & ...
dpkg -l | tee dpkg-l.7_10.00.txt | awk '/^ii/{print $2}' >dpkg-l.7_10.1.txt
OLD='dpkg-l.7_04.1.txt'
NEW='dpkg-l.7_10.1.txt'
# This should work, but doesn't
#apt-get install `grep -vFf $OLD $NEW`
# so do this instead:
diff --suppress-common-lines $OLD $NEW \
| awk '/</{print $2}' >add_to.7_10.txt
apt-get install `cat add_to.7_10.txt`
Short of actually installing anything, I used apt-get's "-s" option, I tested this on my MEPIS 6.0 system.
The ".0." files are to preserve the record & could be omitted.
Thanks Archtoad6 this is what I'm looking for, I've setup a cron job to report to me any packages that I've added as well and to send me a mail so I can keep a record, as I may not want to carry over all the packages that I've installed.
You're quite welcome. I could thank you for re-focussing my attention on an interesting problem that I have worked on before. The above is the cleanest solution I have thought of yet.
I like your cron job idea, it goes toward keeping a (dated) install log. Did you add any code to my suggestions to do it? -- I'd like to see what you came up with.
I think that 2 of the few shortcomings of Debian APT system are the lack of a package installation log & a rollback tool. -- Just a few hours after my post, I was following another thread & as a result installed httrack. To my horror, it un-installed
These flashed by in KPackage & I didn't have the presence of mind to grab the list there. Because I had tested the code I posted, I had the "before" list of packages I needed to compare to the "after" list I then generated. A few minutes later, my system was restored.
So, thank you also for indirectly saving me from a nasty situation.
There are at least 2 lessons here:
Keep an up-to-date list of installed packages.
Test/simulate new installs.
FWIW, I could not recreate the problem today -- httrack was still installed, & removing & re-installing did not remove any other packages this time.
I decided to change the bash scripts for a php script since the date handling was much easier, here is the script please try it out let me know what you think.
Code:
#!/usr/bin/php -q
<?php
/*
keith@fraginhell.com
Basic Package Management for my ubuntu system
- Creates a list of installed packages either as a base
- reference OR for Daily Checks.
- Usage.
-> On first run create a base package list for example
-> create_list.php create base /home/keith
-> Daily
-> Create todays output of packages.
-> create_list.php create today /home/keith
-> then to compare todays package list with
-> yesterday's
-> create_list.php compare today /home/keith
-> you can also compare back to the base list
-> create_list.php compare base /home/keith
*/
# get the Ubuntu Version.
exec("cat /etc/lsb-release |grep \"DISTRIB_RELEASE\" | cut -d\"=\" -f2", $output, $retval);
$Ubuntu_version = $output[0];
unset($output);
# Get Package List
exec("dpkg -l | awk '/^ii/{print $2}'", $output, $retval);
$Package_list = $output;
global $Ubuntu_version;
global $Package_list;
/*
create_base
paramater - directory to store base package list
function writes currently installed packge list to text file
*/
function create_base($basefilepath)
{
global $Ubuntu_version;
global $Package_list;
$filename = "base_list" . "_" . $Ubuntu_version . ".lst";
$basefile = $basefilepath . "/" . $filename;
$today = mktime(0, 0, 0, date("m") , date("d"), date("Y") );
echo "Creating Base Package List in $basefilepath as $filename\n";
$baselist = fopen($basefile, "w") or die ("Could not open $basefile for read/write");
foreach ($Package_list as $packages)
{
fwrite($baselist, $packages . "\n");
}
fclose ($baselist);
return;
}
/*
create_today
paramater - directory to store base package list
function writes currently installed packge list to text file
with date stamp on file name
*/
function create_today($basefilepath)
{
global $Ubuntu_version;
global $Package_list;
$filename = "package_list" . "_" . $Ubuntu_version . "_" . date("d") . date("m") . date("Y");
$basefile = $basefilepath . "/" . $filename;
echo "Creating Packing List $basefilebase as $filename";
$baselist = fopen($basefile, "w") or die ("Could not open $basefile for read/write");
foreach ($Package_list as $packages)
{
fwrite($baselist, $packages . "\n");
}
fclose ($baselist);
return;
}
/*
compare_today
paramater - directory to read base package list
function reads installed packge list from text file with
yesterdays date (errors if it cannot find it)
*/
function compare_today($basefilepath)
{
global $Ubuntu_version;
global $Package_list;
$yesterday = mktime(0, 0, 0, date("m") , date("d")-1, date("Y") );
$filename = "package_list" . "_" . $Ubuntu_version . "_" . date("d", $yesterday) . date("m", $yesterday) . date("Y", $yesterday);
$basefile = $basefilepath . "/" . $filename;
if (! (is_readable($basefile) ) )
{
echo "Error Could not find a file for yesterday in $basefilepath";
exit;
}
$fp = fopen($basefile, "r") or die ("Couldn't open $basefile");
while ( ! feof ( $fp ) )
{
$Base_packages[] = trim( fgets ( $fp, 1024 ) );
}
fclose ($fp);
// remove the last array item, as it a blank line from the while loop.
array_pop($Base_packages);
echo "Base Install had " . count($Package_list) . " packages installed\n";
$New = array_diff($Package_list, $Base_packages);
$Gone = array_diff($Base_packages, $Package_list);
echo "There are " . count($New) . " new packages installed\n";
echo "There are " . count($Gone) . " removed packages.\n";
foreach ($New as $item)
{
echo "Package " . $item . " Installed since " . date("d", $yesterday) . date("m", $yesterday) . date("Y", $yesterday) . " \n";
}
foreach ($Gone as $Old)
{
echo "Package " . $Old . " Removed Since " . date("d", $yesterday) . date("m", $yesterday) . date("Y", $yesterday) . " \n";
}
return;
}
/*
compare_base
paramater - directory to read base package list
function reads installed base package list from text file
and compare's it to the current list.
*/
function compare_base($basefilepath)
{
global $Ubuntu_version;
global $Package_list;
$filename = "base_list" . "_" . $Ubuntu_version . ".lst";
$basefile = $basefilepath . "/" . $filename;
$fp = fopen($basefile, "r") or die ("Couldn't open $basefile");
while ( ! feof ( $fp ) )
{
$Base_packages[] = trim( fgets ( $fp, 1024 ) );
}
fclose ($fp);
array_pop($Base_packages);
echo "Base Install had " . count($Package_list) . " packages installed\n";
$New = array_diff($Package_list, $Base_packages);
$Gone = array_diff($Base_packages, $Package_list);
echo "There are " . count($New) . " new packages installed\n";
echo "There are " . count($Old) . " removed packages\n";
foreach ($New as $item)
{
echo "Package " . $item . " Installed since base \n";
}
foreach ($Gone as $Old)
{
echo "Package " . $Old . " Removed Since base \n";
}
}
if ($argc > 1) {
# we have some CIL Params to think about here
if ($argv[1] == "create" && $argv[2] == "base" ) { create_base($argv[3]); }
if ($argv[1] == "create" && $argv[2] == "today" ) { create_today($argv[3]); }
if ($argv[1] == "compare" && $argv[2] == "base" ) { compare_base($argv[3]); }
if ($argv[1] == "compare" && $argv[2] == "today" ) { compare_today($argv[3]); }
}
?>
Last edited by FragInHell; 10-15-2007 at 07:20 PM.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.