MandrivaUsers.org : Script to Repair Installation - MandrivaUsers.org

Jump to content

  • (3 Pages)
  • +
  • 1
  • 2
  • 3
  • You cannot start a new topic
  • You cannot reply to this topic

Script to Repair Installation with web urpmi sources

#1 User is offline   Steve Scrimpshire 

  • This is a dark ride
  • Group: OTW
  • Posts: 3,590
  • Joined: 13-December 02

Posted 28 December 2003 - 04:52 AM

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:http://semperphi.com/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.

This post has been edited by Steve Scrimpshire: 19 October 2007 - 02:13 PM

Posted Image
0

#2 User is offline   Steve Scrimpshire 

  • This is a dark ride
  • Group: OTW
  • Posts: 3,590
  • Joined: 13-December 02

Posted 15 February 2004 - 05:54 AM

Has anyone found this useful at all?
Posted Image
0

#3 User is offline   kmack 

  • Awesome
  • Group: Members
  • Posts: 492
  • Joined: 02-October 02

Posted 15 February 2004 - 08:00 AM

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.
Kmack Registered User #285515
My Webpage
0

#4 User is offline   neutro 

  • casual
  • Group: Members
  • Posts: 80
  • Joined: 31-January 04

Posted 15 February 2004 - 07:12 PM

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?)
0

#5 User is offline   Steve Scrimpshire 

  • This is a dark ride
  • Group: OTW
  • Posts: 3,590
  • Joined: 13-December 02

Posted 15 February 2004 - 07:51 PM

I have not experienced it overwriting config files, but that is not to say that it couldn't happen.
Posted Image
0

#6 User is offline   neutro 

  • casual
  • Group: Members
  • Posts: 80
  • Joined: 31-January 04

Posted 15 February 2004 - 10:19 PM

Well thanks, it worked well with no side effects so far.
Geez, I wass missing /usr/bin/passwd :o
0

#7 User is offline   Apoc 

  • New Here
  • Group: Members
  • Posts: 30
  • Joined: 14-May 04

Posted 13 August 2004 - 07:30 AM

Looks good will try this out tonight.. anything to make my life easier is good
:D
0

#8 User is offline   aroy_802701 

  • New Here
  • Group: Members
  • Posts: 4
  • Joined: 10-April 04

Posted 12 September 2004 - 02:10 PM

Steve Scrimpshire, on Feb 15 2004, 05:54 AM, said:

Has anyone found this useful at all?
<{POST_SNAPBACK}>

Yeah, thanks. Repaired broken deps for documentation, mainly. Couldn't find glibc-devel in any of the urpmi mirrors (because newer version existed in them) and had to do urpmi manually for that. But basically works really well.
0

#9 User is offline   frosterrj 

  • frequent
  • Group: Members
  • Posts: 159
  • Joined: 11-January 03

Posted 17 October 2004 - 04:11 PM

Steve Scrimpshire, on Feb 15 2004, 05:54 AM, said:

Has anyone found this useful at all?
<{POST_SNAPBACK}>

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
0

#10 User is offline   Gowator 

  • always learning
  • Group: Platinum
  • Posts: 5,674
  • Joined: 09-May 03

Posted 20 October 2004 - 01:38 PM

made sticky since its such an outstandingly useful tip!
Fere libenter homines id quod volunt credunt. (J.C. de Bello Gallico III/XVIII)

Visit my visitor site for coelaics, find out what a coelaic is even.
http://linuxmigratio....fr/glutenfree/
0

#11 User is offline   Steve Scrimpshire 

  • This is a dark ride
  • Group: OTW
  • Posts: 3,590
  • Joined: 13-December 02

Posted 25 October 2004 - 09:40 PM

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.

This post has been edited by Steve Scrimpshire: 25 October 2004 - 09:40 PM

Posted Image
0

#12 User is offline   jeanackle 

  • casual
  • Group: Members
  • Posts: 84
  • Joined: 25-July 03

Posted 31 December 2004 - 06:51 PM

Steve Scrimpshire, on Feb 15 2004, 05:54 AM, said:

Has anyone found this useful at all?
<{POST_SNAPBACK}>

Do birds fly? :P

neutro, on Feb 15 2004, 07:12 PM, said:

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

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:

This post has been edited by jeanackle: 31 December 2004 - 06:51 PM

0

#13 User is offline   Steve Scrimpshire 

  • This is a dark ride
  • Group: OTW
  • Posts: 3,590
  • Joined: 13-December 02

Posted 11 January 2005 - 07:09 AM

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.

This post has been edited by Steve Scrimpshire: 19 October 2007 - 02:14 PM

Posted Image
0

#14 User is offline   LatterDaySaint 

  • New Here
  • Group: Members
  • Posts: 22
  • Joined: 05-December 04

Posted 12 February 2005 - 11:47 PM

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
0

#15 User is offline   Steve Scrimpshire 

  • This is a dark ride
  • Group: OTW
  • Posts: 3,590
  • Joined: 13-December 02

Posted 12 February 2005 - 11:50 PM

What do you mean an empty page? What errors do you get?
The second version of the script should be the one to use.
Posted Image
0

Share this topic:


  • (3 Pages)
  • +
  • 1
  • 2
  • 3
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users