View previous topic :: View next topic |
Author |
Message |
Lebkoungcity Apprentice
Joined: 16 Nov 2008 Posts: 212 Location: near Lebkoungcity (='Gingerbreadcity' =Nuremberg)
|
Posted: Thu May 05, 2016 2:51 pm Post subject: 'reset' a gentoo installation to default? |
|
|
Hi,
I have a gentoo installation on one of my machines which I installed back in 2010. I update it regularly (usually once or twice a week) but I'm thinking about to re-install it from scratch. It is because I have the feeling that there's some cruft that is interfering in a bad way with some new stuff. For example since I replaced the graphics card with a better one (both were nvidias used with the binary blob driver) the resolution changes sometimes after a reboot. Or some settings in config-files are left-overs from older versions of the specific package. Or the way some things are handled nowadays have changed. Or I have done some tweaks in the past that are obsolete by now or are done in another way (for example I experimented with flightgear years ago and I don't know which directories and files I created by hand and which ones are belonging to the current version). And there might also be some things that I have done in a not so advantageous but more cumbersome way...
All those things are not *that big* issues but from time to time one ore another point annoys me. So that I think there might be less hassle with a brand new installation. But on the other hand I don't want to waste time, energy and labor when there's some way to 'reset' the system without a complete re-installation.
I know that there's always the way to wipe out all those config-files in /home to get those all new. But what about those in /etc/ and other places (which other places)? I don't know which ones are outdated and which are not...
What would you do? What are advantages and disadvantages of keeping the installation and wiping out out-dated config and other stuff? And how could I identify on what I should lay my hand and what is OK the way it is?
Thanks a lot for your input _________________ "The most dangerous world view is the world view of the ones who haven't viewed the world."
Alexander von Humboldt (1769-1859) |
|
Back to top |
|
|
toralf Developer
Joined: 01 Feb 2004 Posts: 3922 Location: Hamburg
|
Posted: Thu May 05, 2016 5:45 pm Post subject: |
|
|
maybe look at the output of: Code: |
qcheck -v | grep -B 1 -e '^ MD5-DIGEST:' -e '^ AFK:'
emerge --depclean --quiet --ask; eix-test-obsolete -H brief | grep -v -e "^No " -e "^Skipping " -e "^$"
emerge --deep --update --newuse --changed-use --with-bdeps=y @world --ask
|
|
|
Back to top |
|
|
324874 Apprentice
Joined: 26 Jul 2014 Posts: 168
|
Posted: Thu May 05, 2016 7:51 pm Post subject: system administration |
|
|
Perhaps the following thread may be useful ?
--- [FAQ] Major Upgrades |
|
Back to top |
|
|
axl Veteran
Joined: 11 Oct 2002 Posts: 1144 Location: Romania
|
Posted: Thu May 05, 2016 8:20 pm Post subject: |
|
|
a while back, i asked myself the very same questions. so i came up with 2 scripts. use them as u will.
Code: |
#!/usr/bin/php -f
<?php
error_reporting(E_ALL);
ini_set("error_reporting", E_ALL);
ini_set("display_errors", true);
ini_set("display_startup_errors", true);
ini_set("log_errors", true);
ini_set("log_errors_max_len", 2048);
ini_set("ignore_repeated_errors", 0);
ini_set("ignore_repeated_source", 0);
ini_set("report_memleaks", 1);
ini_set("track_errors", 1);
ini_set("html_errors", 0);
ini_set("error_log", "site.log");
ini_set("allow_url_fopen", 1);
ini_set("memory_limit", "128M");
ini_set("max_execution_time", 0);
set_time_limit(0);
$excludes = array("/usr/portage", "/var/db/pkg", "/var/log", "/usr/src");
#echo "finding files on filesystem ... ";
ob_start();
system("/usr/bin/find /bin /boot /etc /lib /lib32 /lib64 /lost+found /media /opt /root /sbin /srv /usr /var -type f | /bin/sort");
#system("/usr/bin/find /lib64 -type f | /bin/sort");
$obj = ob_get_contents();
ob_end_clean();
$files_on_system = explode("\n", $obj);
#echo count($files_on_system) . " files fetched\n";
#echo "getting list of packets ... ";
$pkg = array(); $n = 0;
$dir = "/var/db/pkg/";
$d = dir($dir);
while (false !== ($entry = $d->read()))
{
if(($entry != ".") && ($entry != ".."))
{
$dd = dir($dir . $entry);
while (false !== ($entry2 = $dd->read()))
{
if(($entry2 != ".") && ($entry2 != ".."))
{
$pkg[$n] = $entry . "/" . $entry2;
$n++;
}
}
$dd->close();
}
}
$d->close();
ksort($pkg);
#echo $n . " packets fetched.\n";
#echo "getting list of files for packages ... ";
$dirs = array(); $syms = array(); $objs = array(); $d = 0; $s = 0; $o = 0;
foreach($pkg as $n => $pack)
{
$f = fopen($dir . $pack . "/CONTENTS", "r");
while(!feof($f))
{
$line = fgets($f, 1024);
$obj = substr($line, 0, 4);
if($obj == "obj ")
{
$objs[substr($line, 4, strlen($line) - 49)] = 1;
$o++;
}
}
fclose($f);
}
#echo $o . " objects\n";
ksort($objs);
foreach ($files_on_system as $n => $e)
{
if((!array_key_exists($e, $objs)) && ($e != ""))
{
$found = 0;
foreach($excludes as $exclude)
{
if($exclude == substr($e, 0, strlen($exclude)))
{
$found = 1;
}
}
if(!$found)
echo $e . "\n";
}
}
/*
$c = 0;
$d = 1; $dirs = array("");
$f = 0; $files = array();
echo "getting file list ...";
while(count($dirs) > 0)
{
foreach($dirs as $n => $path)
{
$dd = dir($path . "/");
while(false !== ($e = $dd ->read()))
{
$item = $path . "/" . $e;
if(($e != ".") && ($e != "..") && ($item != "/dev") && ($item != "/home") && ($item != "/mnt") && ($item != "/proc") && ($item != "/root") && ($item != "/run") && ($item != "/sys") && ($item != "/tmp"))
{
if(is_file($item))
{
$files[$f] = $item;
$f++;
}
elseif(is_dir($item))
{
$dirs[$d] = $path . "/" . $e;
$d++;
}
elseif(is_link($item))
{
echo "do nothing\n";
}
else
{
// most likely a socket
//echo $path . "/" . $e . "\n";
}
}
}
$dd->close();
unset($dirs[$n]);
$line = $n . " / " . $d;
$line = str_repeat(" ", 32 - strlen($line)) . $line;
#echo (($n != 0) ? str_repeat(", 32) : "") . $line;
}
$c++;
if($c % 10 == 0)
{
echo $c;
print_r($dirs);
}
//print_r($files);
}
print_r($files);
*/
/*
echo "getting list of packets ... ";
$pkg = array(); $n = 0;
$dir = "/var/db/pkg/";
$d = dir($dir);
while (false !== ($entry = $d->read()))
{
if(($entry != ".") && ($entry != ".."))
{
$dd = dir($dir . $entry);
while (false !== ($entry2 = $dd->read()))
{
if(($entry2 != ".") && ($entry2 != ".."))
{
$pkg[$n] = $entry . "/" . $entry2;
$n++;
}
}
$dd->close();
}
}
$d->close();
ksort($pkg);
echo $n . " packets fetched.\n";
echo "getting list of files for packages ... ";
$dirs = array(); $syms = array(); $objs = array(); $d = 0; $s = 0; $o = 0;
foreach($pkg as $n => $pack)
{
$f = fopen($dir . $pack . "/CONTENTS", "r");
while(!feof($f))
{
$line = fgets($f, 1024);
$obj = substr($line, 0, 4);
if($obj == "dir ")
{
$dirs[$d] = substr($line, 4, strlen($line) - 5);
$d++;
}
elseif($obj == "sym ")
{
$syms[$s] = substr($line, 4, strlen($line) - 5);
$s++;
}
elseif($obj == "obj ")
{
$objs[$o] = substr($line, 4, strlen($line) - 16);
$o++;
}
}
fclose($f);
}
echo $d . " dirs, " . $s . " syms and " . $o . " objects\n";
echo "processing files ... ";
$bads = array(); $b = 0;
foreach ($objs as $n => $line)
{
$md5 = substr($line, -32, 32);
$file = substr($line, 0, strlen($line) - 33);
if(@is_file($file))
{
$check = md5_file($file);
if($check != $md5)
{
$bads[$b] = $file;
$b++;
}
}
else
{
$bads[$b] = $file;
$b++;
}
$line = $n . " / " . $o;
$line = str_repeat(" ", 16 - strlen($line)) . $line;
echo (($n != 0) ? str_repeat(", 16) : "") . $line;
}
asort($bads);
print_r($bads);
*/
|
i call this one check_extras
Code: |
#!/usr/bin/php -f
<?php
echo "getting list of packets ... ";
$pkg = array(); $n = 0;
$dir = "/var/db/pkg/";
$d = dir($dir);
while (false !== ($entry = $d->read()))
{
if(($entry != ".") && ($entry != ".."))
{
$dd = dir($dir . $entry);
while (false !== ($entry2 = $dd->read()))
{
if(($entry2 != ".") && ($entry2 != ".."))
{
$pkg[$n] = $entry . "/" . $entry2;
$n++;
}
}
$dd->close();
}
}
$d->close();
ksort($pkg);
echo $n . " packets fetched.\n";
echo "getting list of files for packages ... ";
$dirs = array(); $syms = array(); $objs = array(); $d = 0; $s = 0; $o = 0;
foreach($pkg as $n => $pack)
{
$f = fopen($dir . $pack . "/CONTENTS", "r");
while(!feof($f))
{
$line = fgets($f, 1024);
$obj = substr($line, 0, 4);
if($obj == "dir ")
{
$dirs[$d] = substr($line, 4, strlen($line) - 5);
$d++;
}
elseif($obj == "sym ")
{
$syms[$s] = substr($line, 4, strlen($line) - 5);
$s++;
}
elseif($obj == "obj ")
{
$objs[$o] = substr($line, 4, strlen($line) - 16);
$o++;
}
}
fclose($f);
}
echo $d . " dirs, " . $s . " syms and " . $o . " objects\n";
echo "processing files ... ";
$bads = array(); $b = 0;
foreach ($objs as $n => $line)
{
$md5 = substr($line, -32, 32);
$file = substr($line, 0, strlen($line) - 33);
if(@is_file($file))
{
$check = md5_file($file);
if($check != $md5)
{
$bads[$b] = $file;
$b++;
}
}
else
{
$bads[$b] = $file;
$b++;
}
$line = $n . " / " . $o;
$line = str_repeat(" ", 16 - strlen($line)) . $line;
echo (($n != 0) ? str_repeat(", 16) : "") . $line;
}
asort($bads);
print_r($bads);
|
i call this one check_portage. |
|
Back to top |
|
|
Lebkoungcity Apprentice
Joined: 16 Nov 2008 Posts: 212 Location: near Lebkoungcity (='Gingerbreadcity' =Nuremberg)
|
Posted: Fri May 06, 2016 9:24 pm Post subject: |
|
|
axl wrote: | a while back, i asked myself the very same questions. so i came up with 2 scripts. use them as u will. |
Thank you! I will give them a try when the emerge of PHP is done. I'm curious about the results! _________________ "The most dangerous world view is the world view of the ones who haven't viewed the world."
Alexander von Humboldt (1769-1859) |
|
Back to top |
|
|
Lebkoungcity Apprentice
Joined: 16 Nov 2008 Posts: 212 Location: near Lebkoungcity (='Gingerbreadcity' =Nuremberg)
|
Posted: Sun May 08, 2016 8:43 am Post subject: |
|
|
OK, I tried to understand, what the scripts would do but I didn't. (My programming skills are very limited and PHP is completely new to me - when I was a teenager I've just written some very simple code on my commodore in BASIC ) So I've run the scripts (as a user) to see if the output would give me some useful information.
check_portage first reported an error:
Code: | PHP Parse error: syntax error, unexpected '"' in /home/andy/Desktop/tmp/scripts/check_portage_error on line 79 |
I tried to correct it with adding two characters to line 79:
axl wrote: |
Code: | (...)
echo (($n != 0) ? str_repeat(", 16) : "") . $line;
(...) |
|
Code: | echo (($n != 0) ? str_repeat(" ", 16) : "") . $line; |
Is this the way it was intended?
After this the scrips ran but honestly I don't understand the output (just the last few lines because it is longer than my terminal could show me):
Code: | (...)
[1813] => /usr/x86_64-pc-linux-gnu/i686-pc-linux-gnu/gcc-bin/4.9.3/i686-pc-linux-gnu-gcc-ranlib
[1821] => /usr/x86_64-pc-linux-gnu/i686-pc-linux-gnu/gcc-bin/4.9.3/i686-pc-linux-gnu-gcov
[1819] => /usr/x86_64-pc-linux-gnu/i686-pc-linux-gnu/gcc-bin/4.9.3/i686-pc-linux-gnu-gfortran
[2192] => /var/lib/misc/prelink.force
[2193] => /var/lib/misc/prelink.full
[2191] => /var/lib/misc/prelink.quick
[2194] => /var/log/prelink.log
[2221] => /var/run/distccd/.keep_sys-devel_distcc-0
[978] => /var/spool/cups/tmp/.keep_net-print_cups-0
)
|
The same is with the output of check_extras:
Code: | (...)
/var/tmp/portage/www-client/w3m-0.5.2-r4/work/w3m-0.5.2/w3mimg/x11/x11_w3mimg.c
/var/tmp/portage/www-client/w3m-0.5.2-r4/work/w3m-0.5.2/w3mimgdisplay.c
/var/tmp/portage/www-plugins/nspluginwrapper-1.4.4-r1/C:\nppdf32Log\debuglog.txt
/var/tmp/portage/www-plugins/nspluginwrapper-1.4.4-r3/C:\nppdf32Log\debuglog.txt
/var/tmp/tmpE9amUg
/var/tmp/tmpLeBGg4
/var/tmp/tmpeZGVT4
/var/tmp/tmpjTS0qM
Metallica
Warning: ob_get_contents(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in /home/andy/Desktop/tmp/scripts/check_extras on line 29
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 100998785 bytes) in /home/andy/Desktop/tmp/scripts/check_extras on line 29
|
(The latter one is also reported in a file called 'site.log')
So there's a problem with timezone and the amount of used memory - is this relevant?
What are those two scripts trying to tell me?
Anyway there seems to be no way for me to get the settings on this machine to a decent status - or does it?
Many greetings out of sunny Franconia
Andy _________________ "The most dangerous world view is the world view of the ones who haven't viewed the world."
Alexander von Humboldt (1769-1859) |
|
Back to top |
|
|
axl Veteran
Joined: 11 Oct 2002 Posts: 1144 Location: Romania
|
Posted: Sun May 08, 2016 11:40 am Post subject: |
|
|
Still having my first coffee, so if I sound incoherent, you know why that is. First, I hoped that php is simple enough for everybody to just pick up some code and modify it as they want. That is why my scripts have that unfinished feeling to it. They are not supposed to be finished, but simple to modify for your own needs. Don't mean to sound condescending but php is easy to understand just using the manual. http://php.net/manual/en/. At least give it a try.
The idea behind check_portage is to check if files installed by portage still have the same size and signature now like when they were first installed. I ran it on my rig just now, and it is working as intended. If you look at it's output as it runs, first it caches contents of dirs/files in /var/db/pkg, then checks files on system one by one for size/md5 signature. at the end, will output the array of files that do not match. So that output represents files that have different size/signature. The [number] is irrelevant.
As for the idea behind check_extras is to check which files on your system were NOT installed by portage. Sort of like which files are orphaned files. This script has to be adjusted a bit based on your system. First thing, look for the line:
Code: | ini_set("memory_limit", "128M"); |
It's the 18th line. Change it to 512M or even larger if you have lots of files. Second, line 23:
Code: | $excludes = array("/usr/portage", "/var/db/pkg", "/var/log", "/usr/src"); |
This is not mandatory, but a good idea. If you have paths that you KNOW contain ONLY files put there manually by admin / users and you dont want the script to check those files, then you add those paths to this line. and the script will NOT check if these files were installed by portage or not. The script doesn't check ALL of root, only a small number of paths. /bin /boot /etc /lib /lib32 /lib64 /lost+found /media /opt /root /sbin /srv /usr /var
So when it starts, it caches a file list, then checks against /var/db/pkg if those files were installed by portage, or not. So this script only outputs files that were not installed by portage.
Hope it helps.
PS check_portage doesn't have an error in it. it had a ^H sign in it that didn't paste properly as code here on the forums. try downloading them directly (this version also has enough memory specified for check_extras to run):
http://dale.ro/~axl/checks.tbz2 |
|
Back to top |
|
|
|
|
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
|
|