Confused by packages being installed again

Hi. I am learning FreeBSD and this is confusing me.

I installed and tested a lot of things. Then I installed Wine. But I couldn't run any Windows application because all I have are 32-bit applications. I didn't install the 32-bit capability for Wine. I don't even know how to do that, but I will find out. I came here to ask about something else.

Wine suggested that I run this:

/usr/local/share/wine/pkg32.sh install wine mesa-dri

Out of instinct, I did that in another terminal as godly root and the script told me something more or less to the effect of DON'T RUN THIS AS ROOT or something equally kind and useful.

So I went back to the lowly peon terminal and ran it and it began to download packages for installation, and that's when I got confused.

1) How am I installing packages while not as root?

2) Wait a minute. Haven't I already installed some of those packages? Let me check... Yes, I have!

So I canceled the whole thing, and here is what I don't understand, can I install things twice? One as godly root and again as lowly peon?

Apparently, yes. But why? Should I even do that?

I suppose I should install things only once, but in what mode, godly root or lowly peon? There must be a more logical choice.

This is an excellent opportunity to educate on the matter because this is just a messy trial run in Virtualbox that will be destroyed after I have decided I have tinkered enough with it and feel ready for a hopefully tidy bare metal installation.

Your input is appreciated, thank you very much.
 
What's in /usr/local/share/wine/pkg32.sh ?

Code:
#!/bin/sh -e

if [ "$(id -u)" = 0 ]
then
  echo "Don't run this script as root!"
  exit 1
fi

I386_ROOT="${WINE_i386_ROOT:-$HOME/.i386-wine-pkg}"

if [ ! -d "$I386_ROOT/usr/share/keys/pkg" ]
then
  mkdir -p "$I386_ROOT/usr/share/keys"
  ln -s /usr/share/keys/pkg "$I386_ROOT/usr/share/keys/pkg"
fi

ABI=$(pkg config ABI | sed s/amd64/i386/)
# Show what we're going to do, then do it.
echo pkg -o ABI="$ABI" -o INSTALL_AS_USER=true -o RUN_SCRIPTS=false --rootdir "$I386_ROOT" "$@"
exec pkg -o ABI="$ABI" -o INSTALL_AS_USER=true -o RUN_SCRIPTS=false --rootdir "$I386_ROOT" "$@"
 
I believe my problem with wine is fixed. I just deleted the ~/.wine directory created automatically by the installation and ran wineconfig. Two new directories (a new ~/.wine and ~/.i386-wine-pkg) were created and just like that I can run both 64-bit and 32-bit Windows applications. I won't pretend that I understand. It just works for some reason.

My real question was whether it was possible to install anything twice, I mean once as root then again as a regular user as some kind of "subsystem." I guess I misunderstand FreeBSD's concept of "system separated from userland."
I tried to run pkg install as the regular user and I wasn't allowed so I guess that partially answers my initial question. The wine works confused me.
 
See the --rootdir flag in the last two lines? That’s telling it where to install the packages. That’s why it can install as an unprivileged user - because it’s installing to a dir that you have write permissions.
 
My real question was whether it was possible to install anything twice,
Well, first see patmaddox answer, it's installed in a different location, so sure. And then, again, it's not the same thing. It's the same software, but once built for amd64 and once for i386. To run 32bit windows programs, you need the 32bit wine (plus dependencies), and that's what this script installs in some prefix below your home directory.

EDIT: Note this script is just a wrapper around pkg, adding the necessary options to use a different ABI (i386) and install into a different prefix (not the root of your system but some dir in your home). So, once you upgrade packages on your main system, you should also upgrade the i386 packages, e.g. like this:
Code:
/usr/local/share/wine/pkg32.sh upgrade
/usr/local/share/wine/pkg32.sh autoremove
/usr/local/share/wine/pkg32.sh clean
 
I now realize I made a very naive assumption about FreeBSD: I thought I could install pkgs and ports as the regular user and, if I ever upgraded or reinstalled the system, I wouldn't have to reinstall anything else.

Yes, I know.

My ideal model is that of Wine: I can reformat and reinstall the whole world, then copy my .wine directory over to my new home directory and everything just runs like magic.

Too tall and order for Linux or BSDs native applications I guess. ?
 
You might be able to. Take a closer look at the --root option that the script uses. See where the bin files get installed to, and add that to your PATH.

It seems to me that the wine script demonstrates the exact kind of thing you’re looking to do.

So, read the script, read the man pages, ask questions, figure out what’s going on… or don’t.
 
I now realize I made a very naive assumption about FreeBSD: I thought I could install pkgs and ports as the regular user and, if I ever upgraded or reinstalled the system, I wouldn't have to reinstall anything else.
Just install normally as root (this is necessary for writing to the "system-wide" tree that's in everyone's path, by default /usr/local). Really no trickery needed here, a FreeBSD upgrade/install won't touch packages. Of course you always have to reinstall all packages when you upgrade to a new major release because then, the ABI changes, but that's done with one simple command: pkg upgrade -f.
You might be able to. Take a closer look at the --root option that the script uses. See where the bin files get installed to, and add that to your PATH.
That's likely to fail with everything but the most simple applications: Very often, paths to other files needed (private libs, graphics, etc) are hardcoded during build, so they wouldn't be found.
It seems to me that the wine script demonstrates the exact kind of thing you’re looking to do.
The script demonstrates how to install into some alternate root, which is necessary because wine needs to install i386 packages on an amd64 system. It's also necessary to take additional measures for being able to run that ;-)
 
Back
Top