# I killed ports, how to repair?



## Alex4108 (Aug 30, 2011)

Let me be clear here what happened.

Somehow, the /usr/local/lib folder got erased during a hard drive failure (RAID-5 ftw), and caused a system blank.  I just restored the OS to the point where I can log in, but don't have full system backups.  I only backed up the important files (www data, mysql databases, etc.)

Now, my question is, that pkg_info still shows the list of packages it thinks are installed.  However, some are missing files.  

Example:
pkg_info says that apache 2.2.16 is installed
Try to make install in /usr/ports/www/apache22
Get an error that says it thinks apache is already installed, but can't continue because files are missing.

So is it possible, for portsnap to go check which files are missing from installs, and reinstall my missing files?


----------



## wblock@ (Aug 30, 2011)

`% pkg_info -ga`

will show packages with checksum mismatches.  Some editing of that list and it can be fed to ports-mgmt/portmaster.

There's also a "reinstall everything" procedure at the end of portmaster(8) which might be safer and take less experimentation.


----------



## femc7488 (Aug 30, 2011)

You can install sysutils/bsdadminscripts and use pkg_libchk to check missed library and use portmaster to reinstall the ports.


----------



## wblock@ (Aug 30, 2011)

That will find some, but not every port installs a library.


----------



## MasterCATZ (Apr 16, 2012)

```
checking for C compiler default output file name... configure: error: C compiler cannot create executables
```

*D*oes anyone know of a way to fix this? I cannot even reinstall anything. I have tried getting gcc clang binutils by using pkg_add but still no success (version mismatches etc.).  

I have some jails that are still working, however still unsure what broke and when. *M*aybe I can just update my jail and just copy all the files over onto root install?


----------



## UNIXgod (Apr 16, 2012)

if you can pkg_info then simply redirect it to a file. Then delete your ports (I believe the command is *pkg_deinstall* or *pkg_delete -a* or *** ).

Then view the file and install all the ports that you had before.


----------



## MasterCATZ (Apr 17, 2012)

I was not wanting to have rebuild everything from scratch again I just lose to many program settings. What is the exact package/port/location for the C compiler? I can not seem to remove binutils or update it.


```
pkg_delete: no such package 'binutils' installed
```


```
The newest available package (binutils-2.22)
       is older than the version in ports (binutils-2.22_1)
```

I might just try and build my own package from jail to suit installed dependencies I have installed 
or I might just try my coping files from updated jail  as I am pretty sure its a corrupted file and not a setting.

(fsck ran a few weeks back due to power failure but I am sure I compiled something after wards)

*T*he only other thing I had done since was play around with wifi settings and try and get ELF working with SVR4 but the FreeBSD 9 kernel didn't want to build with its setting so no changes were ever made.

*edit*

I ran a hash check to see if I could find a problem 


```
freebsd-update -r 9 IDS
```


```
/usr/libexec/cc1 has SHA256 hash 58a4b2316d6ee8e1f27c622a71958079443ac2f118e9428509291b0e79e3e70c, but should have SHA256 hash 40a6a26db513e7c3d130e24a9a49e2306252e2c27a7b3563b24675378b692d9d.
```

It looks like that was indeed my problem 

Thankfully I had a jail with good files /usr/libexec/ folder was indeed corrupted overwritten files and compiling started working again 

now to run a full update / rebuild of everything to make sure its all 100% again

Anyhow thanks for the reply.


----------



## nekoexmachina (Apr 18, 2012)

In such case, I'd use either `# portmaster -af`, either 
`# foreach pkg (`ls /var/db/pkg`); pkg_delete $pkg; end && sh ~/install-everything.sh`
also, pkg_info is pretty slow and in case when you need only package names, `# ls /var/db/pkg`serves better.


----------



## wblock@ (Apr 18, 2012)

There is a faster way to rebuild all ports at the end of the portmaster man page.  But with the compiler executable being corrupted, there are some lower-level worries to address first.


----------



## MasterCATZ (Apr 19, 2012)

I ran cvsup I noticed it repaired a few more things. I am still unsure how cvsup was deinstalled yet again and because I could not build any ports I had no way to get it back on until the compiler issue was solved. *T*he HDD tests fine (500 gig USB) .

I was using portmanager to rebuild ports I will use the portmaster method next time. fsck seems to always mess things up for me. *E*ven if system is cleanly shutdown it thinks it was not (assuming it because its USB).

*L*ately I have been doing a ZFS snapshot daily so if fsck does run on the array I can just revert to snapshot prior to fsck touching it. 

*T*hanks for the portmaster method.


----------



## wblock@ (Apr 19, 2012)

MasterCATZ said:
			
		

> I ran cvsup I noticed it repaired a few more things. I am still unsure how cvsup was deinstalled yet again and because I could not build any ports I had no way to get it back on until the compiler issue was solved. *T*he HDD tests fine (500 gig USB) .



Don't use cvsup, it was made obsolete years ago.  csup(1) is the current version.  It does not check for problems, it makes sure your local copy of the ports tree is up to date.  It does not compare that with what has been installed.



> fsck seems to always mess things up for me. *E*ven if system is cleanly shutdown it thinks it was not (assuming it because its USB).



Something is really wrong there.  Please start new, appropriately-titled threads to address these problems.


----------

