Help answer threads with 0 replies.
Go Back > Blogs > rainbowsally
User Name


Rate this Entry

Stragest BugZ Part 2

Posted 01-15-2012 at 10:57 PM by rainbowsally
Updated 01-16-2012 at 12:48 AM by rainbowsally (code error)

[Edited: Corrected md5sum generator, Jan 15, 2012.]

Before I forget, I want to jot some notes on the screwiest bugs I've seen.

Kubuntu next.

I initially got the Live CD, version 11.10, but I have dialup. After playing with it a while I got 12.4 on the DVD and currently my Kubuntu is on mothballs but I do want to jot down a few things I noticed.

First of all, Kubuntu is so biased toward those with a high speed internet connection that I discovered some things most people will never notice. I have dialup and none of the modern linuxes work with my modem(s).

If you don't have an internet connection, first time you install you will probably succeed. But if you attempt to reinstall over an existing installation without reformatting, you could end up hanging like for hours.

Installing without reformatting is an option that can be VERY useful, by the way.

In Kubuntu, if you have a home folder you want to save, you can change its name temporarily, reinstall, and then change the name back to restore your settings, files, everything.

Very cool. But there are a couple of 'gotchas' to look out for.

Dialup Users: When you reinstall without reformatting, you MUST delete your /var folder and, if it exists, anything that looks like a dpkg cache in the root folder. If Kubuntu sees those directories it will try to go online and your installation will hang.

To be sure, you should also remove /etc and /usr I would think, just to make sure what's in your system after reinstalling is reflected in the package info.


This even happened when I had the 12.4 DVD installation. Later I reverted to 11.10, as I mentioned above, and so the discrepancies between what was installed and what was in the archives was more understandable. The installed files did not all match those in the archive.

This bug consists of the following:

If you set up your /etc/apt/sources.list file to point to your offline archives or your DVD (pools and dist) folder, and you type apt-get install <such and such> or if you use muon to install something, and it tells you it needs to uninstall some files.


More than once, sometimes when installing, other times when uninstalling, muon or apt-get would strip my system down to bare bones, kde and even x11 gone with the wind.

The cause.

What causes this is the extreme pickiness of the version requirements. There may be an archive that is binary compatible, right down to the md5sums but with a couple of changes in the docs and thus a different <VV>ubuntu<VR> identifier, and these software managers (muon and apt-get) will decide to shoot first, ask questions later.

I.e., if an exact version match can't be found, the files will be removed from your system and there's no way to restore them short of a full reinstall.


This is where I got to, and unfortunately I didn't have time to test it more than once before I took a break from Kubuntu.

The EXACT files in your system can be rebuilt as packages and you can recreate an archive that you can list in /etc/apt/sources.list.

Use dpkg-repack on every package in your system.


And you can discover which they are by listing them.


I don't want to leave you hanging but at the same time, don't count on this script being exactly right because I can't check it at this time.

Get a list of all installed packages.

df.installed() # find all installed or filter with substr
  # split into names and status lines
  local a=`dpkg --get-selections | sed 's|\t|\n|; /install/!d'`
  # delete status lines
  a=`echo "$a" | sed '/install$/d'`
  if [ "$1" != "" ];then
    a=`echo "$a" | sed '/'"$1"'/!d'`
  echo "$a"
And I THINK, if that works, then to recreate all the installed packages, you can do this in a temporary directory to catch the output files.

for i in `df.installed`; do
  dpkg-repack $i
[Any corrections or alternate methods are more than welcome.]

Once the collection of packages exist, they can be moved to an archive.

Now we need the Package file that lists the files and contains various checks to verify an exact match.

It will be horrendously large and very sensitive
as to the tags that are required, so we'll try to create a program to generate it.


  echo "
    pkgtype pkgpath   distname  poolname
    deb   file:///<path>  oneiric   main
    deb   file:///<path>  precise   test

    echo "Need distname and poolname (params 3 and 4 in /etc/apt/sources.list)"

create_package_files() # pkgpath poolname
  local pkgpath=$1
  local poolaname=$2
  local fsize
  local sum
  # echo $pkgpath/$poolname/pool; read key; cd pkgpath; return
  for i in `find $pkgpath/$poolname/pool/* -name *.deb`; do
    # extract the control info
    ar -x $i control.tar.gz || return 1
    tar -xaf control.tar.gz ./control || return 1

    # add to ../Packages file removing null lines as we go.
    cat control | sed '/^$/d' >> Packages

    # need filename tag, relative path 
    echo "Filename: $i" | sed 's|.*\/pool\/|pool\/|' >> Packages
    # need exact file size, use disk usage (du) to get total for one file
    fsize=`du -cb $i | sed '/total/!d; s| *total||'`
    echo "Size: $fsize"
    # need at least md5sum, sha1sum and sha256sum appear to be optional
#    sum=`md5sum $i`
# remove filename from md5sum output -rs
    sum=`md5sum $i | cut -d' ' -f1`
    echo "MD5sum: $sum"

  # move up to where the Packages.gz and/or bz2 will be
  cd ..
  mv tmp/Packages .
  # cleanup
  rm -f tmp/*
  rmdir tmp

# mk_Package() # distname poolname
  local pkgpath="$PWD"
  local distname=$1
  local poolname=$2
  local indexpath
  # syntax and error checks
  if [ "" == "$distname" ]; then 
    return 1

  if [ "" == "$poolname" ]; then 
    return 1
  if [ ! -x $poolname/pool ]; then 
    echo "Can't find '$poolname/pool' (deb files) folder"
    return 1
  mkdir -p $indexpath/tmp
  rm -f $indexpath/tmp/*
  # copy all the control files into the tmp dir
  # operating from that directory temporarily
  cd $indexpath/tmp 
  create_package_files $pkgpath $poolname
  cd $pkgpath
Run it as 'mk_pool' and see the help/usage notes. After testing in a dummy location, repeat as superuser in the real location for your archive if it looks like it's working. And...

If this all works, great. If not... let me know so I can start running. :-)

No dangerous globbed deletions or anything (other than in the tmp folder), so the worst any of this is likely to do is put files all over the place.

Still... no warrantees. Fair enough? :-)

I'll try to remember to update this if necessary when I get back into kubuntu.


If anyone knows of a utility that already exists that creates debian archives with Package lists, go ahead and post it here and I'll remove my own somewhat experimental inventions.

PS. if you think I should just post a bug report, let me ask you how much good that's done so far?

Besides. Here it is. If you think it's a valid observation, feel free to forward it anywhere you like.
Posted in Uncategorized
Views 470 Comments 0
« Prev     Main     Next »
Total Comments 0




All times are GMT -5. The time now is 11:43 AM.

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