Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Does upgrading GCC result in orphaned files?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
halfgaar
l33t
l33t


Joined: 22 Feb 2004
Posts: 781
Location: Netherlands

PostPosted: Sat Mar 04, 2006 1:06 pm    Post subject: Does upgrading GCC result in orphaned files? Reply with quote

When you upgrade GCC, it often runs by all the .la files on your system to change hardcoded filepaths contained in them. You see messages like:

Code:
FIXING: /usr/kde/3.4/lib/libkdeui.la ...[v]


Now, what I'd like to know is, does emerge/portage correct the mtime and md5sum info in the DB which contains the installed packages of your system? It would appear it doesn't:

Code:

# equery check =kdelibs-3.4.1-r1
!!! /usr/kde/3.4/lib/kde3/kabc_net.la has incorrect md5sum
!!! /usr/kde/3.4/lib/kde3/kimg_xcf.la has incorrect md5sum
!!! /usr/kde/3.4/lib/kde3/kio_ftp.la has incorrect md5sum
!!! /usr/kde/3.4/lib/kde3/kio_http.la has incorrect md5sum
!!! /usr/kde/3.4/lib/libknewstuff.la has incorrect md5sum
!!! /usr/kde/3.4/lib/kde3/kdeprint_ext.la has incorrect md5sum
!!! /usr/kde/3.4/lib/kde3/kded_kdeprintd.la has incorrect md5sum
etc


But doesn't this mess up your entire system, because now you have hundreds of orphaned files, which don't get uninstalled when you remove kdelibs.

In my opinion, this is a rather serious bug. Any thoughts?
Back to top
View user's profile Send private message
drwook
Veteran
Veteran


Joined: 30 Mar 2005
Posts: 1322
Location: London

PostPosted: Sat Mar 04, 2006 3:32 pm    Post subject: Reply with quote

hmm... I haven't looked at it but it sounds a reasonable assumption from what you say... If you've an affected system you can afford to fiddle with, why not try unmerging kdelibs to confirm the files remain? (qpkg kdelibs or something first for quick reinstall :) ) Then if so open a bug on bugzilla.
Back to top
View user's profile Send private message
sg313
n00b
n00b


Joined: 25 Dec 2005
Posts: 34

PostPosted: Sat Mar 04, 2006 4:03 pm    Post subject: Reply with quote

hi! i've written a script that can fix the db. It overwrites the time/md5 entries with the values of the existing file in the filesystem.
Code:

#!/bin/bash
scripttitle="fixdb for Portage Package Database, v0.3 (4MAR06)"
pkgdb=/var/db/pkg/
declare -a packagenames
regex=0
ask=0
arg_vec=($@)
if [ $# -eq 0 ]; then arg_vec="--help"; fi

declare -i index
for (( index=0; $index <= $#; index++ )); do
   cur_arg="${arg_vec[$index]}"
   if [ "$cur_arg" == "--pkgdb" ]; then
      let "index=index+1";
      pkgdb="${arg_vec[index]}";
      if [[ $pkgdb =~ '.*[^/]$' ]]; then
         pkgdb="$pkgdb/"
      fi
   elif [ "$cur_arg" == "--ask" ]; then ask=1
   elif [ "$cur_arg" == "--regex" ]; then regex=1
   elif [ "$cur_arg" == "--help" ]; then
      echo -e "$scripttitle
Updates md5sums and mtimes of given packages and backups old CONTENTS file as CONTENTS_OLD.
ATTENTION: Sequential runs will overwrite CONTENTS_OLD!
This script was written by sg313@gmail.com. It is distibuted under the GPLv2.\n
Usage  :   fixdb [Options] packagenames
Options:   --pkgdb <loc>/  : use database at <loc> instead of '/var/db/pkg
           --ask           : if multiple versions are installed, ask which should be fixed
      --regex      : treate packagenames as regular expressions. all matching packages
                        will befixed. use --ask if you want a list to choose from.
           --help          : display this text.\n
Script will bail out if unknown option is given."
      exit
   elif [[ $cur_arg =~ '\-.*' ]]; then
      echo "Unknown Option: "$cur_arg". Try --help."
      exit
   else      
      packagenames=("$packagenames $cur_arg")
   fi
done

if [ ${#packagenames[@]} -eq 0 ]; then
   echo "No package to fix specified; try --help"
   exit
fi

echo "$scripttitle"
      
# generate an array of directories from imput
fixes=0; nonexistent=0;
for packagename in $packagenames; do
   declare -a pkgs
   if [ $regex -eq 1 ]; then
      package=( $(find $pkgdb -maxdepth 2 -regex ".*/$packagename" -type d) )
   else
      package=( $(find $pkgdb -maxdepth 2 -regex ".*/$packagename\-.*" -type d) )
   fi
   pkg_count=${#package[@]}

   if [ "$pkg_count" -eq "0" ]; then
      echo "No package found named $packagename  Exiting."
      exit
   elif [ "$pkg_count" -eq "1" ]; then
      pkg=${package[0]}
   elif [[ "$pkg_count" -gt "1" &&  $ask -eq 1 ]]; then
      echo "The following versions of $packagename were found"
      index=0;
      while [ "$index" -lt "$pkg_count" ]; do
         pkg_name=`echo ${package[$index]} | sed '#$pkgdb#d'`
         echo "$index. $pkg_name"
         let "index = $index + 1"
      done
      echo -n "Choose wisely: "
      read package_number
      pkgs=( $pkgs "${package[$package_number]}" )
   else
      pkgs=( $pkgs "${package[@]}" )
   fi
done

# now check all the directories in array 'pkgs'
declare -i pkg_i
for ((pkg_i=0; $pkg_i<${#pkgs[@]}; pkg_i++)); do
   pkg=${pkgs[$pkg_i]}
   pkg_name=`echo $pkg | sed '#$pkgdb#d'`
   let "pkg_i_out=pgk_i+1"
   echo "($pkg_i_out/${#pkgs[@]}) fixing $pkg_name..."
   cont=$pkg/CONTENTS_NEW
   rm -rf $cont
   touch $cont
   while read -a col
   do
      if [ "${col[0]}" == "dir" ];
      then
         echo ${col[0]} ${col[1]} >> $cont
      elif [ -e ${col[1]} ];
      then
         nmt=`stat --format=%Y ${col[1]}`

         if  [ "${col[0]}" == "obj" ];
         then
            if [ "${col[3]}" != "$nmt" ];
            then
               echo " fixing mtime for" ${col[1]}
               ((fixes++))
            fi

            nmd=`md5sum ${col[1]} | sed 's/^\(.*\)[ ].*/\1/'`
            if [ ${col[2]} != $nmd ]; then
               echo " fixing md5 for" ${col[1]}
               ((fixes++))
            fi
            echo ${col[0]} ${col[1]} $nmd $nmt >> $cont
         elif [ "${col[0]}" == "sym" ];
         then
            if [ "${col[3]}" == "$nmt" ];
            then
               echo " fixing mtime for" ${col[1]}
               ((fixes++))
            fi
            echo ${col[0]} ${col[1]} ${col[2]} ${col[3]} $nmt >> $cont
         fi
      else
         echo ${col[@]} >> $cont
         echo $pkg_name "(!exist)" ${col[0]} ${col[1]}
         let "nonexistent=nonexistent+1"
      fi
   done < $pkg/CONTENTS

   #rm  -rf -- $pkg/CONTENTS_NEW
   mv $pkg/CONTENTS $pkg/CONTENTS_OLD
   mv $pkg/CONTENTS_NEW $pkg/CONTENTS

done

if [ $fixes -gt 0 ]; then
   echo "$fixes entries fixed."
elif [ $nonexistent -eq 0 ]; then
   echo "Nothing to fix."
fi
if [ $nonexistent -gt 0 ]; then
   echo "!!! There are nonexistent files. These where not fixed. Take a look at the output above."
fi
Back to top
View user's profile Send private message
halfgaar
l33t
l33t


Joined: 22 Feb 2004
Posts: 781
Location: Netherlands

PostPosted: Sat Mar 04, 2006 4:06 pm    Post subject: Reply with quote

I've confirmed it with "atlantik" just now. "equery check" showed 4 invalid files, and they all remained after uninstall.

During unmerge, they are marked:

Code:
--- !mtime obj /usr/kde/3.4/lib/kde3/kio_atlantik.la


Where do I report this? I mean, which category? I think the bug applies to much more packages than GCC.

edit:

g313,

Your fix is very dangerous, because the mtime check during unmerge, is to prevent files which are overwritten legitimatly, to be uninstalled when you unmerge a package. Your fix would simply be equivalent to removing the mtime check from the unmerge procedure.
Back to top
View user's profile Send private message
sg313
n00b
n00b


Joined: 25 Dec 2005
Posts: 34

PostPosted: Sat Mar 04, 2006 4:28 pm    Post subject: Reply with quote

halfgaar, your right. so one has to be verry careful running that script. i needed it once I had to recover my root partition and thus had lost all filetimes.
Back to top
View user's profile Send private message
halfgaar
l33t
l33t


Joined: 22 Feb 2004
Posts: 781
Location: Netherlands

PostPosted: Sat Mar 04, 2006 4:32 pm    Post subject: Reply with quote

What do you mean, recover your root partition? Restoring a backup? Good backup tools set mtimes and such. And, when you use cp, just use cp -a. If you don't, you loose a lot more information, like hardlinks.
Back to top
View user's profile Send private message
sg313
n00b
n00b


Joined: 25 Dec 2005
Posts: 34

PostPosted: Sat Mar 04, 2006 5:14 pm    Post subject: Reply with quote

reiserfsck /dev/hda3 --rebuild-tree --scan-whole-partition
Took about 20 hours, but almost everything was there again. To validate my system, i checked all packages, reemerged those that had lost files and used fixdb for those that had all files, but incorrect mtimes and/or md5sums.
Definitly an obscure way, but it was a lot of fun ;)
And thanks for the cp -a, didn't know about it.
Back to top
View user's profile Send private message
halfgaar
l33t
l33t


Joined: 22 Feb 2004
Posts: 781
Location: Netherlands

PostPosted: Sat Mar 04, 2006 5:56 pm    Post subject: Reply with quote

Are you saying that the reiserfsck changed mtimes of files? Is that appropriate behaviour?
Back to top
View user's profile Send private message
halfgaar
l33t
l33t


Joined: 22 Feb 2004
Posts: 781
Location: Netherlands

PostPosted: Sat Mar 04, 2006 6:25 pm    Post subject: Reply with quote

OK, posted a bugreport.
Back to top
View user's profile Send private message
irondog
l33t
l33t


Joined: 07 Jul 2003
Posts: 715
Location: Voor mijn TV. Achter mijn pc.

PostPosted: Sat Mar 04, 2006 9:34 pm    Post subject: Reply with quote

I also remarked this problem and I don't like scripts like fix_libtool_files.sh.

https://forums.gentoo.org/viewtopic-p-3136868-highlight-.html#3136868
_________________
Alle dingen moeten onzin zijn.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum