Jump to content

Script to Repair Installation


Steve Scrimpshire
 Share

Recommended Posts

This is a script I wrote, part of which was taken from aru. This script assumes you have your urpmi sources correctly configured and it contains no local sources. You can do that here:repair.png

http://urpmi.org/easyurpmi/index.php

I'm trying to figure out how to do this with local sources taken into consideration, too:

#!/bin/bash

# rpmfix - searches your system for missing files and reinstalls rpms they belong to
# Copyright (C) 2003  Steve Scrimpshire
# email: omarserenity@gmail.com

# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
# http://www.gnu.org/copyleft/gpl.html#SEC1

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.


rm -f notonmirrors
rm -f missing_files.list

rpm -Va --nodeps --nomd5 --noscripts | grep missing | grep -v "/dev/" | tee missing_files.list
TEST=$(rpm -qf $(awk '{print $NF}' missing_files.list) | uniq)

urpmi.update -a

for name in $TEST
 do
  echo $name
 GET=$(urpmq --sources $name 2>/dev/null)
  if [ $GET ]
	 then
	 if [[ $name != XFree* ]]
		then
		   wget $GET
		else
		   echo "I won't fix $name because I always have problems doing that!"
	 fi
	 else
		echo "$name does not exist on the mirrors!"
		echo "$name" >> notonmirrors
  fi
 done

DIR=$(ls)

for file in $DIR
  do
  if [[ $file == *.rpm ]]
	 then
		rpm -ivh --replacefiles --replacepkgs $file
		rm -f $file
  fi
  done

exit 0

 

I created a special directory to put this script in and after it runs, you may or may not see a new file in that directory called notonmirrors, which will contain the names of pkgs that have missing files, but urpmq could not find them on the mirrors, so you will have to fix them manually. I have it ignore XFree pkgs, because there is always some files for fonts that are missing and no matter how many times you reinstall it, they are still missing.

Edited by Steve Scrimpshire
Link to comment
Share on other sites

  • 1 month later...
  • Replies 40
  • Created
  • Last Reply

Top Posters In This Topic

It looks really good, but have not had a chance to try it. In middle of moving across the pacific and my desktop will be in a container for a month or so! :-) THanks for sharing it and did you ever get the local sources added to it? I like to download to a directory and install from local source and then keep cd's of the patches, etc so I can reinstall if I need to do so w/o re-downloading.

Link to comment
Share on other sites

Well I'm currently running the line to see if I am actually missing files ;)

This script would have been useful last time my system borked and mistakingly pressed "Y" when fsck asked me to check filesystem integrity (thus bypassing ext3 journal recovery). I lost lots of files and replaced by hand quite a few rpms. Once in a while I still find that some program that I haven't used since is broken, and I have to reinstall it.

 

Are you aware of any risk in using your script? (e.g. overwriting config files or nasty side-effects such as this?)

Link to comment
Share on other sites

  • 5 months later...
  • 5 weeks later...
  • 1 month later...
Has anyone found this useful at all?

Well, its kind of interesting to see what came out of the Missing Files and Not on Mirror lists, just not sure how to interpret the results!

 

For Examlple:

Not On Mirror says:

glibc-devel-2.3.3-20mdk

jre-1.5.0-fcs

j2re-1.4.2_05-fcs

xorg-x11-6.7.0-2mdk

xorg-x11-75dpi-fonts-6.7.0-2mdk

 

Missing Files Says:

missing /boot/kernel.h-2.6.8

missing /usr/java/jre1.5.0/lib/charsets.pack

missing /usr/java/jre1.5.0/lib/deploy.pack

missing /usr/java/jre1.5.0/lib/ext/localedata.pack

missing /usr/java/jre1.5.0/lib/javaws.pack

missing /usr/java/jre1.5.0/lib/jsse.pack

missing /usr/java/jre1.5.0/lib/plugin.pack

missing /usr/java/jre1.5.0/lib/rt.pack

missing /usr/java/j2re1.4.2_05/javaws/javaws.pack

missing /usr/java/j2re1.4.2_05/lib/charsets.pack

missing /usr/java/j2re1.4.2_05/lib/ext/localedata.pack

missing /usr/java/j2re1.4.2_05/lib/jsse.pack

missing /usr/java/j2re1.4.2_05/lib/plugin.pack

missing /usr/java/j2re1.4.2_05/lib/rt.pack

missing /usr/java/j2re1.4.2_05/lib/unpack

missing /usr/X11R6/lib/X11/fonts/Speedo/encodings.dir

missing /usr/X11R6/lib/X11/fonts/TTF/encodings.dir

missing /usr/X11R6/lib/X11/fonts/Type1/encodings.dir

missing /usr/X11R6/lib/X11/fonts/75dpi/encodings.dir

 

Since I am running Xorg from the 10.1CE, is it just a version issue since I have a cooker repository in my sources list? I am pretty sure I have kernel source installed too, so why the missing kernel.h? I am running 2.6.8.1-10mdk.

 

Robert

Link to comment
Share on other sites

Thanks, Gowator! :blush:

 

There are some packages that are going to always claim to be missing files...that has something to do with the packaging and nothing I can do except put an ignore line in the script.

 

As for the 'not on mirrors', sometimes they change naming conventions and that might cause that or the particular mirror you are using might not be updated properly.

Edited by Steve Scrimpshire
Link to comment
Share on other sites

  • 2 months later...
Has anyone found this useful at all?

Do birds fly? :P

 

Are you aware of any risk in using your script? (e.g. overwriting config files or nasty side-effects such as this?)

I'm not completely sure, but I think that "rpm --replace-files" saves a copy of the old config files as "configfile".rpmsave.

Or am I mistaking its behaviour with the one of urpmi? :unsure:

Edited by jeanackle
Link to comment
Share on other sites

  • 2 weeks later...

Ok, let's make it safer:

#!/bin/bash

# rpmfix - searches your system for missing files and reinstalls rpms they belong to
# Copyright (C) 2003  Steve Scrimpshire
# email: omarserenity@gmail.com
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
# http://www.gnu.org/copyleft/gpl.html#SEC1

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.


rm -f notonmirrors
rm -f missing_files.list

rpm -Va --nodeps --nomd5 --noscripts | grep missing | grep -v "/dev/" | tee missing_files.list
TEST=$(rpm -qf $(awk '{print $NF}' missing_files.list) | uniq)

urpmi.update -a

for name in $TEST
do
 echo $name
GET=$(urpmq --sources $name 2>/dev/null)
 if [ $GET ]
	then
	if [[ $name != XFree* ]]
	   then
		  wget $GET
	   else
		  echo "I won't fix $name because I always have problems doing that!"
	fi
	else
	   echo "$name does not exist on the mirrors!"
	   echo "$name" >> notonmirrors
 fi
done

DIR=$(ls)

for file in $DIR
 do
 if [[ $file == *.rpm ]]
	then
	   rpm -ivh --replacepkgs $file
	   rm -f $file
 fi
 done

exit 0

 

That way, it won't replace existing files. Thanks for pointing that out.

Edited by Steve Scrimpshire
Link to comment
Share on other sites

  • 1 month later...

G'Day Steve, I have tried the 2 scripts at the beginning of your thread but I get an empty page on the first webpage and a error on the second ,I'm wondering if their still valid or not as they seem to point to nowhere.. is there another thread somewhere that may have similar teachings on finding missing files ect? Thanks Jason

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...