LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Ubuntu
User Name
Password
Ubuntu This forum is for the discussion of Ubuntu Linux.

Notices


Reply
  Search this Thread
Old 09-27-2007, 12:07 AM   #1
FragInHell
Member
 
Registered: Sep 2003
Location: Sydney Australia
Distribution: Redhat, Centos, Solaris, Ubuntu, SUSE
Posts: 282

Rep: Reputation: 45
Question Package Management and Upgrading


Hi Guys.

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..

Thanks.
 
Old 09-27-2007, 07:43 AM   #2
winfinit
Member
 
Registered: Jul 2006
Location: FL, Delray Beach
Distribution: Slackware11, LFS
Posts: 67

Rep: Reputation: 15
sry i am not Ubuntu guy too, but isnt a synaptic package manager listing all of your packages that are installed?
 
Old 09-27-2007, 08:09 AM   #3
Matz
Member
 
Registered: Oct 2006
Distribution: Kubuntu 9.04, Debian Etch
Posts: 178

Rep: Reputation: 31
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.
 
Old 09-27-2007, 08:23 AM   #4
IndyGunFreak
Senior Member
 
Registered: Aug 2003
Location: Indpls
Distribution: Laptops: Debian Jessie XFCE, NAS: OpenMediaVault 3.0
Posts: 1,355

Rep: Reputation: 70
Quote:
Originally Posted by Matz View Post
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.

Then run

Code:
sudo dpkg --set-selections < my-packages && apt-get dselect-upgrade
I imagnie it will probably work OK since you're staying with Ubuntu, but maybe not perfectly.

IGF
 
Old 09-27-2007, 08:45 AM   #5
archtoad6
Senior Member
 
Registered: Oct 2004
Location: Houston, TX (usa)
Distribution: MEPIS, Debian, Knoppix,
Posts: 4,727
Blog Entries: 15

Rep: Reputation: 234Reputation: 234Reputation: 234
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.
 
Old 10-01-2007, 09:18 PM   #6
FragInHell
Member
 
Registered: Sep 2003
Location: Sydney Australia
Distribution: Redhat, Centos, Solaris, Ubuntu, SUSE
Posts: 282

Original Poster
Rep: Reputation: 45
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.

Thanks again great help..
 
Old 10-02-2007, 07:17 AM   #7
archtoad6
Senior Member
 
Registered: Oct 2004
Location: Houston, TX (usa)
Distribution: MEPIS, Debian, Knoppix,
Posts: 4,727
Blog Entries: 15

Rep: Reputation: 234Reputation: 234Reputation: 234
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
Code:
hal
kpowersave
lvm-common
lvm2
mdadm
mepis-auto-6.0
mepis-onthego-6.0
mepis-simply-6.0
mepis-utilities-6.0
pcmciautils
powersaved
udev
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:
  1. Keep an up-to-date list of installed packages.
  2. 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.
 
Old 10-04-2007, 04:59 AM   #8
FragInHell
Member
 
Registered: Sep 2003
Location: Sydney Australia
Distribution: Redhat, Centos, Solaris, Ubuntu, SUSE
Posts: 282

Original Poster
Rep: Reputation: 45
Will do, I'm not in the office for the next week, but as soon as I get back I'll post them or send them to you, whatever you prefer.
 
Old 10-04-2007, 08:04 AM   #9
archtoad6
Senior Member
 
Registered: Oct 2004
Location: Houston, TX (usa)
Distribution: MEPIS, Debian, Knoppix,
Posts: 4,727
Blog Entries: 15

Rep: Reputation: 234Reputation: 234Reputation: 234
Thanks, please post as that may benefit other readers besides myself.

I'll look fwd. to the LQ e-mail notifying me of a new post in this thread .
 
Old 10-14-2007, 09:42 PM   #10
FragInHell
Member
 
Registered: Sep 2003
Location: Sydney Australia
Distribution: Redhat, Centos, Solaris, Ubuntu, SUSE
Posts: 282

Original Poster
Rep: Reputation: 45
Archtoad6,

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.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Simple Package management with Synaptic Package Manager LXer Syndicated Linux News 0 12-05-2006 06:33 PM
package management RzL Slackware 9 11-15-2006 06:10 PM
Using Package Archive style package management mugwump84 Linux From Scratch 3 08-25-2005 05:19 PM
package management laydros Slackware 6 01-21-2005 06:43 PM
9.2 package management Icarus315 SUSE / openSUSE 1 01-15-2005 06:12 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Ubuntu

All times are GMT -5. The time now is 12:56 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration