# Equivalent of Gentoo's world file?



## ClaytonL (Aug 15, 2010)

Hey I can't seem to find this so maybe it doesn't exist. In Gentoo I can look at a world file that shows explicitly installed packages (no dependencies), is there an equivelent in FreeBSD? Or another way?


----------



## UNIXgod (Aug 15, 2010)

Freebsd FreeBSD can show installed packages with pkg_info().

portupgrade (not in the base system) has a file called pkgtools.conf which is equivalent to Gentoo's /etc/portage/.

As for world files i.e. base system you may simply look into your /bin and /sbin dirextories. hier() can tell you more.


----------



## ClaytonL (Aug 15, 2010)

That's not exactly what I'm looking for. In Gentoo if I installed x11/xorg and www/firefox my world file would look like:


```
www/firefox
x11/xorg
```

I've looked through pkg_info man pages already so I will assume there's no eqiuv*a*lent then.


----------



## wblock@ (Aug 15, 2010)

ports-mgmt/pkg_cutleaves with the -l (ell) option shows top-level packages.  But it's not clear if that's what you want.


----------



## phoenix (Aug 15, 2010)

In Gentoo, there is only "the world", which covers the OS, apps, libraries, everything.

In FreeBSD, there is a clear separation between "the base OS" and "user installed apps".  Everyone gets the same base OS.  If you want to modify wants installed (remove parts of the OS), you can edit /etc/src.conf (see the src.conf(5) man page for details) and then do a buildworld cycle with a *make delete-old* and *make delete-old-libs* commands at the end.

User installed apps are handled via the ports tree, and information about them is stored in two places: /var/db/ports/* which covers the options you've selected when installing the app; and /var/db/pkg/* which is the "package database" that has all the details on what's installed.

You can query the "package database" either via standard command-line tools like *ls*, *grep*, and *find*.  Or, via the pkg_info(1) command.


----------



## DutchDaemon (Aug 15, 2010)

Are you talking about [cmd=]pkg_info -ao[/cmd] or something like that?


----------



## gcooper@ (Aug 15, 2010)

There simply isn't an equivalent to this paradigm in the base FreeBSD packaging tool, known as pkg_install.

Gentoo's [/var/lib/portage/?]world file lists what the user installs manually (I forget the exact location because I haven't munged around that file for a while now).

In FreeBSD, /var/db/pkg contains a list of the installed packages (either installed manually, or as dependencies), but AFAIK there isn't an equivalent in any of the non-base package/ports tools for the world file paradigm.

What exactly are you trying to determine that you could determine with the world file?


----------



## ClaytonL (Aug 16, 2010)

Alright I'm pretty sure theres no such thing. In Gentoo there is a file /var/lib/portage/world that only displays explicitly installed packages. So if I tell emerge to install package A, but it has to install packages B and C first, it will only show me package A in my world file. I'm trying to find it to make package maintainence easier. In Gentoo I can remove a package than use emerge to remove all of the now orphaned dependencies (if there is any). There isn't an equivelent in FreeBSD so I was thinking I could just look at what I've explicitly installed and use pkg_cutleaves to remove the main package and any orphaned dependencies. Why isn't there such features in FreeBSD? I've been trying to get into FreeBSD for a while because I'm anti GPL and it has a lot of hype behind it, but I find it lacks a lot of features. I'm assuming for some reason. Thanks for your thoughts.


----------



## UNIXgod (Aug 16, 2010)

ClaytonL said:
			
		

> Why isn't there such features in FreeBSD? I've been trying to get into FreeBSD for a while because I'm anti GPL and it has a lot of hype behind it, but I find it lacks a lot of features. I'm assuming for some reason. Thanks for your thoughts.



Hype? new for the unknown giant.

The ports system is old. Daniel Robbins used Freebsd and made portage and gentoo. Feel free to read about it in the ibm blog.

Use port management utilities for the 'features' you find it lacking and take the time to know what is already available on the system.

(off-topic: anyone remember pkg_version -c ? =P )


----------



## scottro (Aug 16, 2010)

What about /var/db/pkg?  Does that give you what you want? 

Also, please do take the time to read the ports man page (more than once), as well as taking a look at some of the port management utilities--portmaster springs to mind.   Not having used Gentoo in a few years, I can't make a knowledgeable statement, though I do know, as Unixgod says, that Mr. Robbins did use ports as inspiration for portage--no doubt he added a few things, but even in the past few years, there have been various additions to port management that make it easier.


----------



## gcooper@ (Aug 16, 2010)

ClaytonL said:
			
		

> Alright I'm pretty sure theres no such thing. In Gentoo there is a file /var/lib/portage/world that only displays explicitly installed packages. So if I tell emerge to install package A, but it has to install packages B and C first, it will only show me package A in my world file. I'm trying to find it to make package maintainence easier. In Gentoo I can remove a package than use emerge to remove all of the now orphaned dependencies (if there is any). There isn't an equivelent in FreeBSD so I was thinking I could just look at what I've explicitly installed and use pkg_cutleaves to remove the main package and any orphaned dependencies. Why isn't there such features in FreeBSD? I've been trying to get into FreeBSD for a while because I'm anti GPL and it has a lot of hype behind it, but I find it lacks a lot of features. I'm assuming for some reason. Thanks for your thoughts.



Correct me if I'm misunderstanding you, but you're looking for something like `emerge -C <package>`.

? There are multiple means to do this ... portmaster (third party tool) features this functionality, as does portinstall/portupgrade/etc (third party tool) IIRC. There are most likely other tools that help you prune unnecessary packages, but I'm not sure what they are right offhand.

Honestly, the world file was never really (IMO) meant to be a means of controlling what to have installed when doing a clean, but I suppose it could be used when doing an install from scratch on a system. Seems like an inefficient way though, because you'd basically have to do emerge -e world in order to do that, unless you iterated through just the contents.

If you're looking for a means of recording what you installed last for packages, it's a bit trickier because there are actually two facilities for installing what I term as leaf-packages (it's what other folks might call top-level dependent packages, or REQUIRED-BY packages). Either way, there are methods for determining what lives at the top and what can be pruned, but it hasn't been developed yet, outside of pkg_cutleaves -- which is a fantastic tool... don't get me wrong.. but it's easy to make mistakes when you're in a hurry diving through prompts.


----------



## dbi (Aug 16, 2010)

`portmaster -l` will list all installed ports by category, the categories being:

Root ports (No dependencies, not depended on)
Trunk ports (No dependencies, are depended on)
Branch ports (Have dependencies, are depended on)
Leaf ports (Have dependencies, not depended on)

Using these terms Gentoo's world file would contain root and leaf ports.

To generate a list of those ports you could use `portmaster --list-origins > world`

In theory. In practice both categories (root and leaf) will contain ports which you haven't explicitly installed, so you'd need to manually remove them from the list.


----------



## parakleta (Jul 1, 2014)

*Re: Equivelent of Gentoo's world file?*

I know this thread is kind of old, but for me it's the second hit in Google and the first appropriate one. After an hour of so of digging trying to find a solution to the same issue as the OP, I have this solution.

If using the new pkg tools (PKGNG) the following command will list all files in the equivalent of Gentoo's world file: `pkg query -e '%a=0' %o`. The %a represents that the package is automatic (i.e. not automatic means manually installed). To change the state of a port/package use the following command: `pkg set -A[01] "$pkgorigin"`, where $pkgorigin is something like x11/org or www/firefox, as returned by the `pkg-query` command above.


----------



## parakleta (Jul 1, 2014)

Just an update, it seems the pkg-set command asks for confirmation, so an easy way to change the state of many packages is as follows: `for p in `pkg query -e '%a=1 && %?r=0' %o`; do sudo pkg set -A0 "$p"; done` and `for p in `pkg query -e '%a=0 && %?r=1' %o`; do sudo pkg set -A1 "$p"; done`.

The first asks if you want to make non-automatic (i.e. add to the world file) any packages without any reverse dependencies.  These are likely build dependencies and I prefer to add these since otherwise they tend to get removed when cleaning up unused dependencies but I'll need them again next time I compile something with similar requirements (or rebuild the package that originally required them).

The second asks if you want to make automatic (i.e. remove from the world file) any packages which have reverse dependencies which would keep them in the set of installed packages.  This one I use a lot as well since if a package has a complex dependency tree I'll sometimes install sections of it manually so I can keep track of what is going on, but then I'll want to mark the staging points as automatic to restore the normal dependency cleaning behaviour.


----------

