Page 1 of 1

[Solved]Suggested actions to undelete essential header files

Posted: 2. May 2016, 10:50
by Papasot
Greetings Salixers.
I am facing a serious issue, caused by a bug in a project's malfunctioning Makefile. In short, an included Makefile was accidentally moved to another directory, and a "make uninstall" in main Makefile deleted EVERYTHING in /usr/include. Of course, the one to blame is me and not Salix itself. That being said, I wonder what I can do to recover deleted content.
Note that the disk has an Intel(MBR) partition table, and Salix is installed in /dev/sda1 with personal data stored in /dev/sda2. There are no other operating systems installed in that machine, so the only partitions in the disk are those two, plus the swap..
Now, the options I think I have are:

(1) Use a rescue LiveCD/stick to recover the huge amount of header files deleted. Thankfully, I realized the mistake shortly after it happened. plus personal data are in a different partition. This means not much disk activity happened in /dev/sda1 after the deletion of /usr/include, so I guess most of the deleted files would still be recoverable. Not all of them, however - and go figure which ones are lost forever. Furthermore, I am not familiar with rescue LiveCDs, so not sure which one is best for undeleting files. I am thinking about Gparted live cd (which contains the program "Testdisk" for that purpose), but I am not sure really.

(2) Copy /usr/include/* from another computer running same operating system (Salix 14.1 64-bit). Most of the content should be the same, but I'm sure some header files would still be missing, and I have no idea which ones.

(3) Best solution would be a system integrity check program, something that would scan all packages installed in my system and, if those packages install header files, check if the corresponding content in /usr/include exists (if not, solve the issue by reinstalling header files that should be there). I have no idea if such a tool exists though.

Any suggestions/ideas more than welcome.

Re: Suggested actions to undelete essential header files.

Posted: 3. May 2016, 08:53
by gapan
The best thing to do in my opinion, is to reinstall everything that puts anything in /usr/include. It will take a while, but it will definitely work.

To do that, you can get a list of packages that include something in /usr/include with:

Code: Select all

grep -l "usr/include" /var/log/packages/* > PKGLIST
You can strip the package names only with running:

Code: Select all

sed -i "s|/var/log/packages/||" PKGLIST
sed -i "s/\(.*\)-\(.*\)-\(.*\)-\(.*\)/\1/" PKGLIST
And now reinstall everything in that list:

Code: Select all

sudo su
for i in `cat PKGLIST`; do slapt-get --reinstall -y -i $i; done 2>&1 | tee LOG
That will cover only the packages installed from the salix/slackware repositories though. It will not cover the packages you installed using slapt-src/sourcery, or manually. To find which these are, you can search in the LOG file that has been created:

Code: Select all

grep "No such package" LOG
or, if you have a greek locale (I guess you probably do):

Code: Select all

grep "Το πακέτο δεν βρέθηκε" LOG
You'll have to reinstall those the same way you installed them in the first place.

Re: Suggested actions to undelete essential header files.

Posted: 3. May 2016, 16:15
by Papasot
Worked like a charm. Actually, what gapan suggested was exactly what I was looking for. I made a script for that, and saved it just in case - not that I want to use it again.
Thank you gapan!

[Note to self: Think twice before you move makefiles around subdirectories - even better, always use abslute paths in makefiles.]