# Is it safe to rm -fR /usr/ports?



## jemate18 (Feb 8, 2009)

I have a fresh install of freebsd 7.1 on another machine. I have selected yes to the install ports collection.

After the installation I would like to update my ports. I have read in the handbook that I could use portsnap fetch and after that I will have to use portsnap extract. However, since my /usr/ports is populated, would it be safe to rm -fR it and then use portsnap fetch and portsnap extract?

Would my installed packages/ports be affected if i did that? Will I ever be able to update the installed packages/ports after doing the portsnap fetch/extract after the rm -fR ?

Thanks again


----------



## hydra (Feb 8, 2009)

The /usr/ports directory contains the information where to download the source files of programs, how to compile and where to install them. If you delete it, it will NOT affect your installed applications. All that is worth saving from /usr/ports are the subdirectories distfiles and packages. The 'distfiles' contains the program source files and the 'packages' contains the packages you've eventually downloaded. If you don't want to waste your bandwidth, save them somewhere.

Back to your question, it's fine to:

```
mv /usr/ports /usr/ports.old
portsnap fetch extract
mv /usr/ports.old/distfiles /usr/ports
mv /usr/ports.old/packages /usr/ports
```

But it's also fine to

```
rm -rf /usr/ports
portsnap fetch extract
```

Depends on you.


----------



## jemate18 (Feb 8, 2009)

hydra said:
			
		

> All that is worth saving from /usr/ports are the subdirectories distfiles and packages. The 'distfiles' contains the program source files and the 'packages' contains the packages you've eventually downloaded.



So distfiles pertain to my "old" ports.. If i chose the portsnap fetch/extract then mv /usr/ports.old/distfiles /usr/ports/distfiles will that source conflict the newly created /usr/ports from the portsnap fetch/extract

One more question. Assuming all went well with my new /usr/ports will i be able to update my installed ports/software to the new version included in the /usr/ports?

Thanks


----------



## Djn (Feb 8, 2009)

The disfiles are just the source code for the ports. As an example, installing lang/gcc43 will probably need gcc-4.3.1.tgz (or something like that). If that file is already in distfiles, great; if not, it'll be downloaded. The file names are unique per version, so you never risk ending up with an older version.

In short, a file existing in ports/distfiles will in the best case save you a download, and in the worst case waste some disk space.

Oh, and you don't need to delete anything to do a portsnap extract - it'll gleefully overwrite everything relevant anyway.


And for part two: The  information about what you've got installed is in /var/db/pkg, so messing with /usr/ports won't affect it.


----------

