Follow Slashdot blog updates by subscribing to our blog RSS feed

 



Forgot your password?
typodupeerror
×
BSD Operating Systems

FreeBSD Ports Tricks 201

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."
This discussion has been archived. No new comments can be posted.

FreeBSD Ports Tricks

Comments Filter:
  • Gee golly! (Score:2, Funny)

    by cliffy2000 ( 185461 )
    It's a good thing that SCO isn't claiming ownership to ALL Unix variants... otherwise they'd have to call it 699DollarsBSD!
    • by hackrobat ( 467625 ) <`moc.liamg' `ta' `inahtej.hsinam'> on Sunday August 10, 2003 @04:08AM (#6658636) Homepage
      Ha ha! Reminds me of Linus' post in 1993 [google.com], 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.
  • yes (Score:4, Informative)

    by Openadvocate ( 573093 ) on Sunday August 10, 2003 @03:59AM (#6658612)
    And you can even find the Bittorrent [freebsd.org] client.
    • If you mean to say 'FreeBSD's ports tree has BitTorrent', I thought you should know that Debian and Fink both provide it as well. I've never used portage, but I wouldn't be surprised if it was available there as well.
    • Re:yes (Score:1, Interesting)

      by Anonymous Coward

      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?

      Seems to cut to the heart of a real package system, IMO.

      • Re:yes (Score:5, Informative)

        by m0rten ( 307847 ) on Sunday August 10, 2003 @05:10AM (#6658753)
        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..)
  • Useful (Score:5, Informative)

    by billatq ( 544019 ) on Sunday August 10, 2003 @03:59AM (#6658613)
    These are pretty useful little tips, thought it looks like almost all of them are in the FreeBSD handbook already.
    • Re:Useful (Score:2, Funny)

      by vrt3 ( 62368 )
      I would hope they are in the handbook, because without these 'tricks' I think the ports system would be a pretty dumb package management system.
  • by Krapangor ( 533950 ) on Sunday August 10, 2003 @04:08AM (#6658634) Homepage
    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.

    • I'm sorry, but a zombie process never runs, and thus can't 'eat other processes' like you claim.
      • a zombie process never runs, and thus can't 'eat other processes' like you claim

        Obviously you've never configured this for running within a jailed environment. Only so many places to run in that tiny cyber-cell.
        • Yes, I have run processes in jail. This has nothing whatsoever to do with a process competing for processor time. Zombies never do, nor do they hold any resources whatsoever, thus they CANNOT run.

          Look elsewhere for your process-eater.
    • 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.

      Does it have a core system called the Red Queen? And cool lazer things (and no frickin' sharks either) protecting it?

      ResidentBSD: No-one is immune.
  • Zealotry (Score:5, Funny)

    by Ari Rahikkala ( 608969 ) on Sunday August 10, 2003 @04:15AM (#6658649) Journal
    [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]
    • by Stephen VanDahm ( 88206 ) on Sunday August 10, 2003 @07:17AM (#6658955)
      "[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 [linuxisforbitches.com]. 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 [spatula.net]. 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 [imdb.com] when you need him?

      Steve
      Linux and BSD User
  • Let's keep this thread Gentoo-free, shall we?

    [note: I actually use Gentoo, but Gentoo fanboys usually get on my nerves]
  • Kudos to the author! (Score:5, Interesting)

    by dodell ( 83471 ) <dodell@sTEAitetronics.com minus caffeine> on Sunday August 10, 2003 @04:19AM (#6658662) Homepage
    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 [freebsd.org] and the FreeBSD diary [freebsddiary.org].
    • by Anonymous Coward
      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.

      While this is wonderful news, does this mean us mere Linux users should want to switch to *BSD now?

  • Another trick that I always liked is (and isn't listed in the article) is

    $ make install

  • Envy (Score:5, Interesting)

    by __aavhli5779 ( 690619 ) on Sunday August 10, 2003 @04:34AM (#6658697) Journal
    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.
    • Re:Envy (Score:4, Informative)

      by Phroggy ( 441 ) * <slashdot3@NOsPaM.phroggy.com> on Sunday August 10, 2003 @05:15AM (#6658760) Homepage
      Somebody is working on iPortage [sourceforge.net], a Cocoa-based GUI front-end to Gentoo's packaging system...
    • Re:Envy (Score:3, Informative)

      by hondo_san ( 565908 )
      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

      • Before you flame, in my noob days, I got r00ted in RH (6.2 default) and FBSD (OpenSSH).

        What can I say??? That's really your own fault for not blocking access to SSH, and whatever else they exploited that you didn't specifically need publicly accessible.

        And BTW, if you are concerned with exploits, you should really use OpenBSD. Heavily audited, and new secrurity features as of 3.3 that make even exploitable bugs, exploitable no more. Systrace is installed so you can VERY finely control exactly what each

      • You completely undermined one of the fundemental goals of os X.

        Darwin, the userspace anyway, is LARGELY based on FreeBSD. The means that with your sexy gui, you get a neat kernel that is very freebsd like, so you, the freebsd-loving son, have a minimal ammount of learning(if any?) to take care of that.

        Secondly, a mac is infact a mac. which means a powerful gui. Things are easy to setup with the mac gui, things like servers, apache, etc. so that means your dad can fiddle around without having to learn a ne
    • Re:Envy (Score:2, Informative)

      by battlej ( 676746 )
      the netbsd pkgsrc collection works fine on osx...

      [netbsd-pkgsrc] [netbsd.org]
      • Bookmarked!

        I'm going to be giving this a shot when I have some time tomorrow. Looks like I finally have an excuse to format a UFS partition.

        Thanks :)
      • Re:Envy (Score:2, Funny)

        by lahi ( 316099 )
        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)
    • Re:Envy (Score:2, Interesting)

      by ^Case^ ( 135042 )
      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 [gentoo.org] for more information.
    • DarwinPorts is slow because you have to compile everything (compile, compile, compile -- dang, I only got 667 G4). Fink used to break stuff, but seems better now.

      But yeah, I wish there were something better too
  • by guacamole ( 24270 ) on Sunday August 10, 2003 @05:44AM (#6658797)
    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).
    • by Metrol ( 147060 ) on Sunday August 10, 2003 @06:37AM (#6658864) Homepage
      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 [freshports.org] 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.
      • 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.
        Debian Unstable

        Granted, it is binary packages for the most part (occasionally someone will mention apt-get -b source packagename) but releases and bugfixes come fast and furious in Debian Unstable.

    • Install the binary packages provided by FreeBSD.org.

      They change slowly.
    • 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/
    • 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.
    • Some of the ports are beta or release candidate. If you look in /usr/ports/x you will find alpha and release candidate versions of things like PHP and GCC along side stable ones.

      IF anything the bsd ports are more stable then Gentoo. Case in point is php. If you look at the makefiles with vi you will see if they are marked release candidates or unstable. I found out that only php 3.x is considered stable with FreeBSD 4.8??

      I tried the rc php 4.3x and it would not compile with all all the libraries during an
    • 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.

      You can generate packages (cd /usr/ports/www/whatever && make package) of whichever applications you want to install on a number of s

    • by yanestra ( 526590 ) on Sunday August 10, 2003 @07:07PM (#6661925) Journal
      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...

      • Ok, but then if I don't cvsup the port tree I also won't be able to install the security updates/bug fixes.
        • 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>)

    • the portsystem is in a CVS repository too: cvsweb [freebsd.org]

      So you can just check out the same revision / day as the system you want to clone, if you can't just copy it over.
    • The ports tree is tagged at the time of any FreeBSD release. If you install the ports tree during the FreeBSD installation, you will have the same ports tree across all installations.

      You can also use date tags in your ports supfiles to get the same ports tree across all your FreeBSD installations.

      And you can always just tar up the ports tree on one system, and untar is on all your other systems.
    • 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.

      If you don't like that you can go to the first system and make packages out of the installed ports (literally type "make packages") and install them on the second system. There are more details in the article here.

  • by AmiMoJo ( 196126 ) on Sunday August 10, 2003 @05:51AM (#6658806) Homepage Journal
    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.
    • use packages (Score:1, Informative)

      by Anonymous Coward
      If your /usr directory is that small then you should not be using ports anyway. Just install binary packages using /stand/sysinstall instead. That's what I do on my old Cyrix 5x86/100 mhz machine.
  • Feeling of unease (Score:4, Interesting)

    by Matey-O ( 518004 ) <michaeljohnmiller@mSPAMsSPAMnSPAM.com> on Sunday August 10, 2003 @07:53AM (#6659029) Homepage Journal
    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.

    • Re:Feeling of unease (Score:3, Interesting)

      by Hatta ( 162192 )
      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 'f
      • Finding with grep (Score:3, Informative)

        by Thornae ( 53316 )
        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.
    • Re:Feeling of unease (Score:1, Informative)

      by Anonymous Coward
      The differences that exist aren't really all that big - I regularly work on Solaris, AIX, FreeBSD, NetBSD, Debian, Redhat and Mandrake. Yes, there are differences, but checking the syntax via 'man' or even 'info' (if you have info pages installed of course) usually clears it up pretty quickly. Only real problem I have is when I have to work on pesky Windows platforms. The syntax is REALLY different there.

    • there is nothing alike about the names "redhat" and "netbsd"

      they are different OSs and people complaining about differences as minor as that are missing the point. when you get a new car do you complain that the knobs are not placed exactly as your old car? you paid for the chassis - the placement of the headlight switch is insignificant (unless it is under the seat, in which case it serves you right if you bought it). IMO, unix gets easier if you spend less time reading and more time doing.
  • by Anonymous Coward
    the author didn't mention, but making your package repository fetchable via ftp (or http i guess), and seeting PACKAGEROOT=ftp://yourserver allows you to do pkg_add -r from your machines, and the dependencies will fetch and install themselves.
  • by Edward Scissorhands ( 665444 ) on Sunday August 10, 2003 @10:40AM (#6659628)
    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.
  • "OnLamp's Dru Lavigne demonstrates several of these tricks to simplify your life."

    If there's any family connection, this article was written for him by an editor, and repackaged to sell his image.
  • Worthless page (Score:5, Informative)

    by bluGill ( 862 ) on Sunday August 10, 2003 @11:54AM (#6659972)

    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.

  • by Istealmymusic ( 573079 ) on Sunday August 10, 2003 @12:57PM (#6660252) Homepage Journal
    Thought I'd save someone some unnecessary building.
  • Portupgrade! (Score:5, Informative)

    by Piquan ( 49943 ) on Sunday August 10, 2003 @03:06PM (#6660879)

    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.

    • Re:Portupgrade! (Score:4, Informative)

      by bmah ( 99344 ) on Sunday August 10, 2003 @07:58PM (#6662130) Homepage
      > 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.

The computer is to the information industry roughly what the central power station is to the electrical industry. -- Peter Drucker

Working...