Talk:Portage-utils
From Gentoo Linux Wiki
[edit] Qcheck & Reinstall Broken Packages?
STATUS: qcheck.c within svn now has "--badonly" switch. This script will likely not be needed with ">portage-utils-0.1.29"! --Roger 23:53, 12 April 2008 (UTC)
So far, I have this much:
- !/bin/bash
qcheck --all --nocolor 2>&1 | tee qcheck.log
Now, I want to perform the following:
1) Find all package files with AFK
2) Find all files with MD5-DIGEST except /etc
3) Find all files with MTIME except /etc
4) Find all files with PERM
5) Rebuild these packages. (Mainly, I'm concerned about just rebuilding packages meeting #1 & #2 -- AFK & MD5-DIGEST... as I think most others are as well!)
Copy and past the following Python program and make executable
chmod a+x $HOME/bin/qcheck-rebuild.py
Please note, this program is untested. Also, qcheck should probably be run as root, else running as user may return PERM errors as well.
Simply copy/paste the output after typing your usual package installer command concatenation (ie. emerge -pv).
If I performed this program correctly, instead of manually finding each package -- around 50 packages yesterday, I should be successful in reinstalling the remainder 100 packages today in one click! Some /etc config files are controversial and per user whether to reinstall. The /etc config files are mostly excluded for now.
| File: $HOME/bin/qcheck-rebuild.py |
#!/usr/bin/python -O
#
# My first Python program parsing qcheck output, giving the user
# a list of packages requiring rebuilding.
#
# Author: Roger <roger@eskimo.com>
# You need a /tmp/qcheck.log file for this to work!
# qcheck --all --nocolor 2>&1 | tee /tmp/qcheck.log
# Initialize variables
line = ""
newline = ""
package_name = ""
print_package = 0
# Main
# Read in qcheck.log file and determine packages needing reinstall
f = open("/tmp/qcheck.log")
line = f.readline()
while line:
# See if we need to print a package's name
if ((line.startswith ("Checking")) and (print_package == 1)):
print package_name, # remove comma and prevent output all on one line
# Parse package name from input line and prefix with '='.
if line.startswith ("Checking"):
newline = line.replace('Checking','')
newline = newline.replace('...','')
newline = newline.strip()
package_name = '=' + newline
#print package_name # debug
# Reset flag ensuring we print package name once.
print_package = 0
# Find AFK files
elif (line.startswith(" AFK") == 1) and (line.startswith(" AFK: /etc") != 1):
print_package = 1
#print "DEBUG AFK " + package_name
# Find bad MD5-DIGEST files
elif (line.startswith(" MD5-DIGEST") == 1) and (line.startswith(" MD5-DIGEST: /etc") != 1):
print_package = 1
#print "DEBUG MD5-DIGEST " + package_name
# Find bad MTIME files
elif (line.startswith(" MTIME") == 1) and (line.startswith(" MTIME: /etc") != 1):
print_package = 1
#print "DEBUG MTIME " + package_name
# Find bad PERM files
elif line.startswith(" PERM"): # worry about etc config files?
print_package = 1
#print "DEBUG PERM " + package_name
line = f.readline()
f.close()
|
