Slashdot Mirror


FreeBSD Ports Tricks

BSD Forums writes "One of FreeBSD's biggest benefits is its ports collection. You can go years without learning more than just make install clean, but there are dozens of features built into the ports tools. OnLamp's Dru Lavigne demonstrates several of these tricks to simplify your life."

39 of 201 comments (clear)

  1. Gee golly! by cliffy2000 · · Score: 2, Funny

    It's a good thing that SCO isn't claiming ownership to ALL Unix variants... otherwise they'd have to call it 699DollarsBSD!

    1. Re:Gee golly! by hackrobat · · Score: 5, Funny
      Ha ha! Reminds me of Linus' post in 1993, asked why Linux should be chosen over BSD:
      > Other than the fact Linux has a cool name, could someone explain why I
      > should use Linux over BSD?

      No. That's it. The cool name, that is. We worked very hard on
      creating a name that would appeal to the majority of people, and it
      certainly paid off: thousands of people are using linux just to be able
      to say "OS/2? Hah. I've got Linux. What a cool name". 386BSD made the
      mistake of putting a lot of numbers and weird abbreviations into the
      name, and is scaring away a lot of people just because it sounds too
      technical.
  2. yes by Openadvocate · · Score: 4, Informative

    And you can even find the Bittorrent client.

    --
    my sig
    1. Re:yes by m0rten · · Score: 5, Informative
      Guys, what happens if I remove a piece of software after it's been installed and lots of other software depends on it. Will "Ports" warn me about what will break, or will it just go ahead and do it, and leave me scratching my head trying to figure out what happened?
      It will warn you that there are other ports depending on this port. However you can forcefully remove it if you wish (and then you're on your own..)
    2. Re:yes by GodOfNothing · · Score: 2, Informative

      Yes, the dependencies are fully listed in both directions (requires and required by)

  3. Useful by billatq · · Score: 4, Informative

    These are pretty useful little tips, thought it looks like almost all of them are in the FreeBSD handbook already.

  4. The feature I like most: by Krapangor · · Score: 5, Funny
    Zombiefication

    You just type e.g.:
    goat@blindeyes> make emacs --D UNDEAD=1
    And your installation of emacs is zombiefied. That means that an emacs process can never crash, is much stronger albeit slower and can only be killed by kill PID -SIGCUTINTOHALFWITHCHAINSAW.
    In fact I have a zombiefied apache running here for 742 days without any trouble. Although it eats sometimes other processes.

    So all you "*BSD is dead whiners": In fact the death of *BSD is a good thing. It has given the system many new occult powers of which a living system like Linux/MacOS X can only dream. With all these undead processes, vampiric servers and banshee IDS your system is much better than the boring old standard rubbish.
    I even heard some rumors from Redmond that MS is working on killing Windows, too. Just for gaining the great powers of an undead system.

    --
    Owner of a Mensa membership card.
    1. Re:The feature I like most: by FrostedWheat · · Score: 2, Funny

      You know what, FrostedWheat? *BSD is dying.

      I use dead OS's. All the time. They don't know there dead.

  5. Re:BSD is Dying by usotsuki · · Score: 4, Informative

    Maybe not but it sure as hell runs Debian!

    -uso.

    --
    Dreams, dreams, don't doubt dreams, dreaming children's dreaming dreams. Sailor Moon SS
  6. Zealotry by Ari+Rahikkala · · Score: 5, Funny

    [to save Slashdot users' bandwidth, a reply about how Gentoo GNU/Linux does most of this stuff, too, and some of it (like making package repositories) in an easier way has been deleted from this space]

  7. Kudos to the author! by dodell · · Score: 5, Interesting

    The complaint of many people who don't want to switch to BSD from Linux is that there aren't binary packages available and that they don't want to compile everything in ports. This article demonstrates that, indeed, using the ports collection, it is possible to check out and install binary packages using the pkg-* utilities.

    There are tons of really neat things about FreeBSD; I won't list them here because they're probably quite off topic. But for anybody interested in learning more; feel free to contact me and/or check out the FreeBSD handbook and the FreeBSD diary.

  8. Envy by __aavhli5779 · · Score: 5, Interesting

    Reading the article just makes me yearn for a true BSD ports system on OS X.

    The closest thing available right now is DarwinPorts but it's horrendously incomplete; I don't think any good package system can get away with lacking any way to track installed packages or perform upgrades; not only is there no facility for system-wide upgrades, but even upgrading an individual package requires an explicit uninstall, download, and reinstall.

    I know that the Gentoo, Fink, and OpenDarwin folks are supposed to be collaborating on a unified package system for OS X. Does anyone in the know have any inklings that it might be like BSD ports? A BSD ports system does seem ideal for an OS that is, at the core, BSD.

    1. Re:Envy by Phroggy · · Score: 3, Informative

      Somebody is working on iPortage, a Cocoa-based GUI front-end to Gentoo's packaging system...

      --
      $x='S24;r)>63/* h@<5+oZ)32"5cz';$me='phroggy'x$];
      $x=~y+ -xz+\0-Tx+;print$_^chop$me for split'',$x;
    2. Re:Envy by hondo_san · · Score: 3, Informative
      My father has been a Mac person since there *was* a Mac, and quite a geek, to boot. Recently, he proposed doing a bunch of of server-y stuff on his G4, to which I responded "why potentially mess up your OS-X install when you can get FreeBSD on another server in the house?" (wired Cat-5 in every room.) He hooked me up with a 1GHZ Pentium with 512MB of memory, and a 40GB drive, now running in the basement with 4.8, horribly underutilized, but ready for anything.

      I certainly don't wish to cast dispersions on OS-X, but since I work w/ FBSD, I'm more comfortable with this scenario, as the "critical data", i.e. 2 years of stuff, is still in its place on the Mac, and the new server is ready and willing to do whatever we throw at it.

      So, mostly a fear of screwing up the OS-X stuff (I am nervous about a server-capable machine with a gui), I fall back to what I know. A colleague of his is running a WAP and Postgres from his Mac laptop, so, I suppose it's really about what you're comfortable with - provided it works, and is secure out of the box.

      Before you flame, in my noob days, I got r00ted in RH (6.2 default) and FBSD (OpenSSH). But that was a lifetime ago, three years. In that time, the modularity of FBSD, IMHO, has allowed me to more easily and efficiently stay current and less vulnerable.

      The ports tree rocks.

    3. Re:Envy by battlej · · Score: 2, Informative

      the netbsd pkgsrc collection works fine on osx...

      [netbsd-pkgsrc]

    4. Re:Envy by ^Case^ · · Score: 2, Interesting

      Does anyone in the know have any inklings that it might be like BSD ports?

      I'm no BSD ports expert, but from what I hear the Gentoo team is porting their Portage system, which is heavily inspired by the BSD ports system, to other platforms (OS X).

      Portage does support the things you mention, system-wide upgrades and tracking installed packages.

      Checkout the Gentoo website for more information.

    5. Re:Envy by lahi · · Score: 2, Funny

      While you are probably right, you could have used fewer words:
      "netbsd works fine".

      -Lasse
      (Running NetBSD on my PCs, my good old MacIIci, and my iMac DV Special Edition)

  9. Re:BSD is Dying by SiliconJesus101 · · Score: 5, Informative
    Well, actually it can in fact run quite a few Linux applications. A friend of mine (ack, how cliche') has a Quake III Arena server running on his BSD box and as far as I know most Linux ELF binaries can be coaxed to run on BSD without too much of a hassle (again from what my friend says).

    From http://www.freebsd.org/doc/en_US.ISO8859-1/books/h andbook/linuxemu.html , actually it can in fact run quite a few Linux applications.

    "In a nutshell, the compatibility allows FreeBSD users to run about 90% of all Linux applications without modification. This includes applications such as Star Office, the Linux version of Netscape, Adobe Acrobat, RealPlayer 5 and 7, VMWare, Oracle, WordPerfect, Doom, Quake, and more. It is also reported that in some situations, Linux binaries perform better on FreeBSD than they do under Linux." "In a nutshell, the compatibility allows FreeBSD users to run about 90% of all Linux applications without modification. This includes applications such as Star Office, the Linux version of Netscape, Adobe Acrobat, RealPlayer 5 and 7, VMWare, Oracle, WordPerfect, Doom, Quake, and more. It is also reported that in some situations, Linux binaries perform better on FreeBSD than they do under Linux."

    --

    "The strong will do what they want, the weak will do what they must."
    -Thucydides

  10. Yes, FreeBSD does run Linux. by Anonymous Coward · · Score: 4, Informative

    The install process asks you: "Do you wish to enable Linux compatibility?"

    If you answer yes, it installs a loader that translates a Linux program's system calls into FreeBSD ones. It works rather well.

    I've personally run the Linux binaries of Unreal Tournament 2003 on FreeBSD 4.8 with full OpenGL 3D acceleration on my Pentium 3/800 with an NVidia GEForce 3. It ran better than the Windows version does on the same hardware.

    Many other 3D accelerated Linux games (like Quake 3) also run just fine under FreeBSD.

    1. Re:Yes, FreeBSD does run Linux. by TheRaven64 · · Score: 2, Interesting
      One thing it doesn't do, however, is set up the Linux procfs. /proc on a Linux box has a different structure to that on a FreeBSD box, and a lot of the problems with running Linux software on FreeBSD come from this. Fortunately, FreeBSD can mount a Linux style procfs. The bad news is that this is not mounted by default. This prevents some Linux programs (such as the Half Life dedicated server) from running. To fix this you need to add the following line to your /etc/fstab
      linproc /compat/linux/proc linprocfs rw 0 0
      --
      I am TheRaven on Soylent News
  11. My beef with FreeBSDs port system.. by guacamole · · Score: 4, Insightful

    My biggest concern about FreeBSD's port collection is that it's essentially "unstable". That is, it seems to be changing on the time. Imagine that you need to setup a web server at one customer's site that requires a set of packages from the ports collection to make the site work. A couple of months later, if you need another server like this, perhaps for a different customer, you might end up with different versions of the tools even though you're running the same version of FreeBSD at both sites. Perhaps, this is a great system for someone who wants to always keep running the latest and greatest but for people who'd like a stable working environment this is an annoyance. Since, I am averse to change, I also like to update only say the packages that have serious bugs or security problems. But with the ports collection, there is no easy way to tell whether a package has been updated because of security issues/bugs or because the port maintainers simply feel like bumping the package version.

    It would be a whole lot better if the ports tree was frozen together with the OS when it's released and later only security and bug fixes were merged into the ports (preferably by patching the originally released package instead of just using the latest version, but that would be too much to ask from non-paid volunteers, although Debian does manage to do it).

    1. Re:My beef with FreeBSDs port system.. by Metrol · · Score: 4, Insightful

      It would be a whole lot better if the ports tree was frozen together with the OS

      May your wish become reality... ala kazzam, *pooof*

      There ya go, now you can go to your favorite computer retail store, FreeBSD Mall, or even an absolutely free ISO, and get a RELEASE copy of FreeBSD.

      Yes, just recently (several years ago) FreeBSD started putting things on CDs. These CDs include on them at no extra charge... packages! These "packages" are pretty well frozen in time, and install the exact same code on every machine that CD is used on.

      later only security and bug fixes were merged into the ports

      Boy, demanding fella. Well, that's exactly what happens with the FreeBSD ports! Between application releases bug fixes go into the ports tree via patches, aka diff files.

      Case in point, there was a nasty layout problem with Konqueror that a KDE developer posted a patch for in the KDE bugzilla. I altered the files paths a bit and submitted to the KDE-FreeBSD project. This was then committed to the ports tree, which then produces new packages.

      This process took all of 2 days. I don't honestly know if any other OS has this fix in their build process or packages. My guess is that the rest of the Unix world either needs to manually patch and compile their KDE or wait for 3.1.3a.

      Bug fixes like this go into the applications in the ports tree every day, without having to wait for the originating project to release a new version. Best of all, since the FreeBSD ports utilize its own versioning scheme important changes, such as security fixes or major bugs, can flag "pkg_version" to let an admin know that there's an upgraded version to install.

      there is no easy way to tell whether a package has been updated because of security issues/bugs or because the port maintainers simply feel like bumping the package version.

      Port maintainers don't go willy nilly into bumping port revisions. Changes in maintanership, documentation, or other administrative issues do not warrant, nor do they get, a change in their port version.

      As for an easy way to determine why a port was upgraded, a quick visit to Fresh Ports can give you the exact reason why the port was upgraded, by who, and when.

      but that would be too much to ask from non-paid volunteers

      No it's not really. In fact, these kinds of issues are addressed every single day in the ports tree. It may look like a tangled mess upon first glance, but I assure you it is anything but. There's over 9000 applications being maintained for the OS. Every day many are added, a few deleted, and several are updated for a variety of reasons. This tree is as alive as the free software community it reflects.

      --
      The line must be drawn here. This far. No further.
    2. Re:My beef with FreeBSDs port system.. by junics · · Score: 2, Interesting

      It is possabile to download older makefiles (and whatever is required) of a port via the cvsweb interface on freebsd.org.
      It's not fun downloading individual files but it has saved my day on several occations.

      http://www.freebsd.org/cgi/cvsweb.cgi/ports/

    3. Re:My beef with FreeBSDs port system.. by the+uNF+cola · · Score: 3, Funny

      Dying? I hope it isn't doing T-shirts. Tie-dye is so lame.

      --

      --
      "I'm not bright. Big words confuse me. But Wanda loves me and that should be enough for you." - Cosmo

    4. Re:My beef with FreeBSDs port system.. by TCM · · Score: 2, Informative

      Just do a 'make package'. This will install the port and create a binary package which you can install with pkg_add(1) on other boxes.

      --
      Of course it runs NetBSD. BTC: 1NT7QvbetmANwaMzhpVL6
    5. Re:My beef with FreeBSDs port system.. by yanestra · · Score: 3, Informative
      My biggest concern about FreeBSD's port collection is that it's essentially "unstable". That is, it seems to be changing on the time.
      [...]
      It would be a whole lot better if the ports tree was frozen together with the OS when it's released and later only security and bug fixes were merged into the ports

      You have not much idea of what you are talking about, have you?

      Together with the OS comes a complete ports tree. If that ports tree is being changed to newer versions, it's because the sysadmin has set up a task to do so. It's no problem to keep an unchanged ports tree, additionally, if there is need for it.

      You can also make a binary package from a port, if you want to install software on several machines in the same way...

      BSD is an operating system for people who know what they're doing...

    6. Re:My beef with FreeBSDs port system.. by yanestra · · Score: 2, Informative
      Ok, but then if I don't cvsup the port tree I also won't be able to install the security updates/bug fixes.

      Simply copy the old ports tree before cvsupping...:
      cp -Rp /usr/ports /usr/ports.dist

      That's all...

      (Ok, you might have to resolve dependencies on your own if you want to mix distribution/updated packages, but that really should be trivial. <grin>)

  12. Warning for first time installers by AmiMoJo · · Score: 3, Informative

    When I installed FreeBSD for the first time, I noticed that on some configurations the default install is broken. Basically, if you have a small (500MB) /usr partition, you cannot instal ports by default as the standard newfs call used by the installer to create the initial filesystem does not allocate enough inodes.

    IIRC, you need to format /usr by hand using the "-i 2048" switch. This one got me the first time round, as it's not mentioned in any of the documentation.

    --
    const int one = 65536; (Silvermoon, Texture.cs)
    SJW, n: "Someone I don't like, and by the way I'm a fuckwit" - AC
  13. Zealotry? You asked for it! by Stephen+VanDahm · · Score: 4, Funny

    "[to save Slashdot users' bandwidth, a reply about how Gentoo GNU/Linux does most of this stuff, too, and some of it (like making package repositories) in an easier way has been deleted from this space]"

    I know that you're making fun of Gentoo zealots, but in the process, you're in danger of awaking a sleeping giant: The BSD Snob. Because you didn't think before posting, innocent Slashdot readers will be forced to read how the BSDs are better designed, more carefully developed, and are more portable across different platforms. Readers will even be forced to endure accusations that, being Linux users, they wet the bed. Gentoo certainly has its zealots, but BSD users have been looking down their noses at AT&T UNIX since, like, the 1970s. They're the original OS zealots!

    See, you've unleashed an Army of Darkness upon us all. Where's Bruce Campbell when you need him?

    Steve
    Linux and BSD User

  14. Re:BSD is Dying by DrSkwid · · Score: 4, Informative

    why yes, it does

    which would you like ?

    Red Hat
    /usr/ports/emulators/linux_base-6/pkg-descr
    /usr/ports/emulators/linux_base-8/pkg-descr

    or

    Debian
    /usr/ports/emulators/linux_base-debian/pkg-descr
    --
    There are places where the networks are not touching,and there are places where they are-Boeing's Lori Gunter
  15. Feeling of unease by Matey-O · · Score: 3, Interesting

    I've got a NetBSD box running as my external (wild, hairy, unsafe) webserver.

    I'd spent quite a bit of time learning Redhat 8, relearned Redhat 9, and again started over with NetBSD. (looking at mandrake, gentoo, and a raft of others as well)

    Why is is that these OS's are alike in name only? The package management is entirely different, the disk partitioning is entirely different, heck FINDING files is different ( find * | grep foo vs. find | grep foo)

    Enough is slightly different to make it feel like you're learning over from scratch (adduser v. useradd), and enough is COMPLETELY different to prove the point.

    One thing I've determined: If I get an applicant who says they know 'Unix' without specifying the flavor will get roundfiled.

    --
    "Draco dormiens nunquam titillandus."
    1. Re:Feeling of unease by Hatta · · Score: 2, Interesting

      Dunno, when I tried FreeBSD it was similar enough for me not to worry about it most of the time. I finally switched back to debian because I couldn't get acpi to function properly. But I don't see what the big deal is. There are a few differences, sure but BSD and GNU/Linux are not the same OS. What differences there are you can easily pick up on the fly.
      But why use grep with find? Why not just 'find . -name foo' This has the benefit that you can match on characteristics other than file name too. Like 'find . -name foo -ctime 1' to find files named foo that have changed in the past 24 hours. Or 'find . -name "fo*" -type d' to find directories that begin with the letters 'fo'. You can even use the exec flag to run a command on each file. Find has become so much more useful since I stopped using it with grep.

      --
      Give me Classic Slashdot or give me death!
  16. I'm surprised no one has mentioned portupgrade... by Edward+Scissorhands · · Score: 5, Informative

    There's a great utility in the ports tree called portupgrade. It's very handy and allows for quick and easy upgrading of your ports.

    It lives in /usr/ports/sysutils/portupgrade

    Check it out. Start with the manual page (man portupgrade) after you install it, then use Google for more info. It's well worth it.

  17. Worthless page by bluGill · · Score: 4, Informative

    That page is almost worthless. Don't waste your time reading it, the only tip worth anything is the one about doing a "make readmes". Everything else is better accomplished by using the portupgrade scripts.

    Trust me on this one, once you use portupgrade you will not go back to the pkg_* commands.

  18. Re:Gentoo!! by RdsArts · · Score: 3, Interesting

    But Portage is...

    Broken?

    I killed my Gentoo install when it failed compiling some new ebuild, or just while upgrading, again. And after getting tired of it beeping while compiling Mozilla more often then if someone was typing their thesis in vi in command mode.

    Meanwhile everything compiles with FreeBSD on the same computer. So, hey...

  19. The latest FBSD already has README.htmls by Istealmymusic · · Score: 3, Informative

    Thought I'd save someone some unnecessary building.

    --
    "The lesson to be learned is not to take the comments on slashdot too literally." --Vinnie Falco, BearShare
  20. Portupgrade! by Piquan · · Score: 4, Informative

    Every FreeBSD admin should know about portupgrade.

    It's in ports. It has several tools. One of them, portupgrade, upgrades ports. Another, pkgdb, fixes your ports db by updating out-of-date deps, merging multiple versions of the same port, etc. A third, pkg_version, is like port_version but much faster. A fourth, portsclean, cleans any debris from using ports, such as outdated shared libs.

    Get it. Learn it. Love it.

    1. Re:Portupgrade! by bmah · · Score: 4, Informative

      > A third, pkg_version, is like port_version but much faster.

      Actually, pkg_version is in the base system, portversion is the program that comes with portupgrade.

      portversion is faster because it relies on a database of installed packages, whereas pkg_version depends only on knowing what ports are installed (via pkg_info) plus either an up-to-date ports tree or an INDEX file. Both are useful IMHO.

      But I agree with the general sentiment...the whole portupgrade package is extremely useful, and it's one of the first things that goes on a system that I install if I think I'll ever be upgrading ports on it.

  21. Finding with grep by Thornae · · Score: 2, Informative
    find is even handier when you incorporate grep into it, say to find certain textfiles:
    find . -iname "*txt" -exec grep -Hi foo \{\} \;


    One of my most common uses for this is to look for ports that do certain things not included in their one line description, eg:
    find /usr/ports -name "pkg-descr" -exec grep -Hi quicktime \{\} \;
    Just a quick FYI, in case you were unaware of this handy thing.
    --
    |>
    Here be Dragons