Ben Rockwood: Exploring Sun Studio 10

Ben Rockwood: Exploring Sun Studio 10:

Alan Hargreaves recently blogged about Cscope-fast in OpenSolaris-Land. Cscope is a nifty tool, one that looks boring enough sittin in /opt/SUNWspro/bin untill you give it a spin and suddenly fall in love with it. I’ve always ment to really dig around with the tools that come with Sun Studio (aka: SOS) but never had the time, I just install it and use cc, thats it. Well, Alan get me interested, so I spent a little time today digging around.

I’m putting my devtools notes online. They aren’t fancy or anything, just what I jotted down as I played around.

Many of the tools supprised me, they are really handy! Simple things that I’ve known about but never actually bothered to use like indent and lint are pretty handy. Things I didn’t know where there like X Designer gave me a bit of a shock. But some nifty “hidden” treasures are there that I never bothered to notice like cscope, prof, cflow, dumpstabs, cxref, and ctrace. There are some kick ass tools in there if you only take the time to dig around, and now that I get to use Sun Studio for more than 60 days (thanks to OpenSolaris!) its time to learn.

Have a looksie at my notes and then take the time to dig around a little yourself, you’ll be glad you did.

[composed and posted with ecto]

Jeremy Teo: Evince/Poppler Packages up for testing

Jeremy Teo: Evince/Poppler Packages up for testing:

Evince and Poppler packages are up for testing.

What is Evince? Shamelessly ripped from their homepage:

“Evince is a document viewer for multiple document formats like pdf, postscript, and many others. The goal of evince is to replace the multiple document viewers that exist on the GNOME Desktop, like ggv, gpdf, and xpdf with a single simple application.”

And Poppler:

“Poppler is a PDF rendering library based on the xpdf-3.0 code base.”

Packages are available as linked below (You need poppler to run evince)

Evince

Poppler

As usual, you may need additional packages from blastwave. If you’re running Gnome 2.8 from blastwave, you should be set. You will also need CSWgcc3corert and CSWgcc3g++rt (which you most likely already have. Again, pkg-get is your friend)

As usual feedback is appreciated, particularly from Sparc folks, since I don’t have a Sparc desktop.

[composed and posted with ecto]

Ben Rockwood: Solaris Flash Archives: Protect your development box

Ben Rockwood: Solaris Flash Archives: Protect your development box:

If you’ve started to play with OpenSolaris you might have noticed that one of our constant concerns is turning your beloved development workstation into a brick. Brickification, or the result of a bad BFU (upgrade), can be painful. You have to remember that OpenSolaris is in fact the OS/Net conslidation of Solaris (and we call the Solaris 11 codebase we all now use Nevada, hence ONNV or OS/Net Nevada - thats OpenSolaris) is not simply the kernel like Linux but the whole base OS, from LibC to the tools, to the kernel, to the modules. On Linux if you build a bad kernel, no problem, reboot and select a diffrent kernel from GRUB or LILO and figure out what went wrong, but even on Linux if you jack up GNU LibC or the base toolset your gonna be reaching for a rescue or install CD. So when you upgrade a complete OpenSolaris system a lot is at stake. For the record, you can infact install only a kernel using the Install (pronounced Cap-Eye-Install) tool, but thats not nearly as much fun as upgrading the whole system via BFU. So, what we need is a way to protect our investment of time and effort. On Solaris we have two amazingly kick ass tools to help us solve this problem, and they become more important than ever in OpenSolaris development: Live Upgrade and Flash Archives.

I’ve actually written a paper on OpenSolaris development that covers both, but I haven’t completed it yet and don’t have time, so I’ll blog it in request to several folks who are curious about it. I’d like to extend a hearty thank you to Mr. John S. Howard who is no longer with Sun (who ever decided that was a dipshit), who is the unquestioned Jumpstart, Live Upgrade, Flash Archive god of Solaris. John, you rule.

Live Upgrade (LU) and Flash Archive (Flar) are both essentially big ass wrapper around CPIO, and neither do anything that seems particuarly unusual at first look, they are both definately “Ya, of course!” tools, but the point is that no one else does it, at least not as well as they do.

Live Upgrade allows you to create a copy of your root disk onto another disk in the system, and then (the Live bit) upgrade that copy (which we call an Alternate Boot Enviroment, or ABE). When you finish patching or upgrading the ABE you simply activate the ABE and reboot into it. In this way you can do time consuming (a complete recommended patch cluster on Solaris9 for instance can take 3-4 hours to install) upgrades to Solaris without incurring any more downtime than it takes to reboot.

Flash Archives on the other hand are root disk images. You create a flash archive using the “flar” tool, which will output a single file containing your system image. We can use these system images in a variety of ways to provide a robust imaging and snapshot/backup solution. The reason Flash Archives are so much more polished than other solutions is the fact that when you run the Solaris Installer (from CD usually) you’ll notice you actually are given 3 (or more) install options: Install, Upgrade, or Flash. When we create a Flash Archive we can store it on either an NFS, FTP or HTTP server and then access it again via a CD installer, as well as the fact that we can also use these archives via both JumpStart and Live Upgrade! When archives are installed onto a system they are done with the networking unconfigured (just like a sys-unconfig’ed system) making them great for imaging, just get a Solaris install how you like it, create the archive, then JumpStart install the archive onto your pool of servers, effortless rollouts!

For our purposes we’re interested in simply creating point in time snapshots of our system. Flash Archives indeed could be cron’ed and made to act as a nightly backup solution, but there are certainly better tools for doing that. When you feel you’ve got your box the way you like you can use “flarcreate” to create a Flash Archive, which we can store in some place accessable via NFS, FTP or HTTP. If for some reason we destroy or extensively damage our installation for some reason we can just pop in the Install CD, enter the networking information and point the installer to the archive… minutes later we’re booting back into our system. Every time I feel I’ve significantly improved or upgraded a system I cut an archive just in case.

Creating Flash Archives is easy. NFS provides the best method for archive storage, imho, so mount an NFS share locally, I prefer to mount to /flash. Then run run “flar create” with the appropriate arguments like this:

$ flarcreate -n "Monolyth B16 Snapshot" -a "benr@cuddletech.com"> \
-S -R / -x /flash /flash/Monolyth-Snapshot-`date '+%m-%d-%y'`.flar

So, looking at the arguments:

  • -n adds a description to the archive (this is displayed during installation later)
  • -a adds a string containing conact information
  • -S tells flarcreate to skip its size checks, normally it will estimate the size of the archive prior to creating it, which can take a really really long time, this argument just lets us speed up the process
  • -R specifies the root directory, by default its /, but I often supply it for completeness.
  • -x specifies a directory to exclude from the archive, supply one -x per directory to exclude (ie: -x /opt -x /export). NFS mounted filesystems are excluded by default, but again for completeness I tend to put them in there anyway.
  • (archivename).flar is the actual name of the output archive file. You can name it whatever you want, but typically its wise to put the hostname, archive creation date, and a .flar extention in the filename just to help identify it. The filename should be a absolute pathname, so since we’ve mounted our NFS archive repository to /flash, we’ll specify that path.

If your not using NFS then you should create a directory to put the archive in and be sure to exclude (-x) that directory during creation before you move it to your FTP or HTTP server.

As you can see, Flash Archives are quick and easy methods of creation snapshot backups of your system. I used one just this morning! I needed a bigger IDE harddrive in Monolyth, so I created an archive last night before I left the office, then this morning I shutdown, pulled the old drive completely and put in the new one, booted the installation CD (Solaris Express: Community Release in this case), setup networking, partitioned the new drive, and then installed from my NFS archive, all from the graphical installer. An hour later the copy completed and the system rebooted. I didn’t know anything had changed! I logged in and got back to work. Absolutely painless and I’ve got a faster disk with 70GB more space! :)

So, in the future as you play with OpenSolaris (or Solaris) and for whatever reason think that the system is good as it is, but you might want to reinstall it, or you want to see what rm -rf / does or whatever, don’t worry, don’t pull the drive and put it aside or mess with tapes, just create a Flash Archive and know that if you need to get back to where you were its only a quick install a way. Enjoy.

For more information check out:

[composed and posted with ecto]

Ben Rockwood: Burning CDs in Solaris

Ben Rockwood: Burning CDs in Solaris:

I’ve never actually burned CDs under Solaris. Its such a pain (I’m still getting over how terrible it was several years ago) on Linux that I just didn’t even wanna touch CD burning on Solaris. But, to my great amazement, its really really easy! Witness!:

root@monolyth benr$ cdrw -l
Looking for CD devices...
    Node                   Connected Device                Device type
----------------------+--------------------------------+-----------------
 cdrom0               | SONY     DVD RW DW-D18A   VYS2 | CD Reader/Writer
root@monolyth benr$ cdrw -i sol-nv-b16-x86-v1.iso
Looking for CD devices...
Initializing device...done.
Writing track 1...
Finalizing (Can take several minutes)...done.
root@monolyth benr$

Talk about painless. The cdrw tool is even part of the default Solaris install, so nothing to setup or anything. I’m happy. :)

[composed and posted with ecto]

Ben Rockwood: I wanna check out OpenSolaris…. Now what?

Ben Rockwood: I wanna check out OpenSolaris…. Now what?:

It’s happened. The source has returned from its 25 year sabbatical to the people. So maybe your thinking about trying out OpenSolaris, maybe you’ve tried it before, maybe you haven’t ever used it, or perhaps you use it all the time but never on the desktop. How do you get up and running? Here are some tips to get you off and running with OpenSolaris so that you can get snuggly and cuddly before you start building code.

This first thing to do, obviously, is to install OpenSolaris. Now, Solaris has been free (as in beer) for a long time, and even longer than that you’ve been able to download it and just ignore the fact that you were supposed to pay a license fee, but now thats all ended and we’re free as in beer and speech. Solaris 10 GA is good, and Solaris Express is even better, but what you really want is the Solaris Express: Community Release. The Solaris Express (commonly written as SX) Community Release (CR) is based on Nevada (what will eventually become Solaris 11) Build 16 which includes a lot of features not found in previous releases and with a good number of bug fixes. Chief ammoung the improvements in the SX:CR are: NewBoot (GRUB), no more stupid white console, alot of bug fixes, improved device support for several things. So even if you have Solaris10 GA or Express, I highly highly recommend you upgrade to or install SX:CR.

Okey, after installing the Solaris Express: Community Release your on the proper footing, you’ve got your system installed, and you can really start playing around. Now what?

Before you do anything else I want you to look around what you’ve already got. There is more there than you think! You’ll notice that with JDS you already have a lot of apps you want, such as GAIM, The GIMP 2.0, BASH, ZSH, MySQL, Apache and Apache2, wget, Net-SNMP, Mozilla, Gnome-Terminal, GPhoto2, Python, PERL, GCC 3.4.3, ncFTP, OpenJade, OpenSSL, OpenSSH, a basic TeX toolset, Bison, ant, Imlib, and much more! You want to look in /usr/sfw/bin (sfw stands for SunFreeWare). If your going to build your own software you want to look in /usr/sfw/include and /usr/sfw/lib to see that most of the standard libs you want (libjpeg, libpng, libz) are already there for you. Spend some time playing with these so that you don’t get frustrated about not having something that you might actually already have.

Two things to note are that some of the GNU tools conflict with the tradional Solaris/UNIX tools (such as make, sed, awk, etc) so the GNU tools are renamed to be preceeded by g for GNU, so GNU Make is gmake, GNU tar is gtar. To make life easier for yourself you might want to just create an alias in your shell’s profile such as “alias tar=’gtar’“. Also, if you try to create a home directory in /home and cant, the reason you can’t is because by default its an automount mount point. To change this edit /etc/auto_master, comment out the line “/home” and restart autofs (svcadm restart autofs) or simply disable autofs completely using ’svcadm disable autofs’.

But what if the included stuff isn’t enough, what then? There are several places to get binary software for Solaris, but the two most popular are SunFreeWare.com and Blastwave.org. On Solaris we use the standard SysV PKG format. You can look at whats installed on your box with the “pkginfo” command, look at package details with “pkginfo -l XXXmypkg”, add packages with ‘pkgadd -d XXXmypkg’, or remove packages with ‘pkgrm XXXmypkg’. At SunFreeWare.com you can download packages for your system from their wide selection of packages, however you have to download and install them all individually, which means you need to be aware of dependancies. SunFreeWare was a life saver for years, but Phil Brown wanted something simpler like Debian’s apt-get, so he write a Solaris equivelent called “pkg-get”, which became the foundation for Dennis Clarke’s Blastwave.org. On Blastwave you can download and install the pkg-get tool, then add /opt/csw/bin to your PATH and then add all the software you want like this: “pkg-get -i enlightenment’. You can see a full list of Blastwave’s avalible software on their package page. The 2 nice things about Blastwave is that its really quick to get software installed with no hassle, and all software installs in /opt/csw so you don’t have to worry about wierd stuff being installed all over your clean install.

Genearlly once my system is up and running I install the Blastwave package and nab my favorite tools that aren’t in Solaris, such as Subversion, CVS, GNU Screen, AutoMake and AutoConf, teTeX, and either Xchat or irssi depending on my mood. You’ll probly want Vim too but I tend to wait because Blastwave’s Vim package installs Gvim (graphical) too, which installs a ton of dependancies I don’t want. All this can be done easily and quickly with Blastwave:

# cd /tmp
# wget http://www.blastwave.org/pkg_get.pkg
# pkgadd -d pkg_get.pkg
 (follow the prompts)
# export PATH=$PATH:/opt/csw/bin
# pkg-get -i subversion cvs automake autoconf screen tetex xchat
 (follow the prompts)

Okey, so now you’ve got a kickin’ OpenSolaris box with some extra kickin’ tools. Now what?

I don’t really care for the JDS-ized Mozilla in Solaris these days… I’ve really become a Firefox man. And, I’ve also given up on mutt in favor of the very very very fast and easy to use Thunderbird. Thanks to the Sun Beijing Team they keep Mozilla.org populated with builds just for us… so go get ‘em. FireFox 1.0.4 for Solaris tarballs and Thunderbird 1.0.2 for Solaris tarballs. Because these change fairly often as new releases come out I just prefer to install them in my home directory, so just untar them there and when new releases come out you can just ‘rm -rf ~/firefox’ and then install the new one, quick and painless.

Once you’ve got Firefox and Thunderbird taken care of you’ll need to make sure you can kick back and relax when no ones lookin’, so got get Macromedia Flash, untar the tarball, and run the “flashplayer-installer” script to install. Then you can watch reallyfunny stuffwhile you should be working. (Oh, don’t forget to pkg-get xmms and then listen to the awesome audio streams at di.fm, the chillout room rules.)

The other non-open app you’ll want is Adobe Acrobat, but sadly thats only avalible for Solaris SPARC not X86, so go put your name on the list of people pissed about it, and then pkg-get gPDF from Blastwave.

At that point you’ve got a really usable system with all your goodies and your ready to rock. You just want to tweek your desktop itself. Solaris features two X servers: Xsun and Xorg. I highly recommend using Xorg. You can switch between the two by using the kdmconfig program. When y ou switch to Xorg the /etc/X11 directory will be created and you’ll be given a sample xorg.conf to tinker with. Sadly, Solaris doesn’t include the composite tools, although composite does work (so they say). Once you switch to Xorg, you’ll want to switch over to the nVidia driver if you have an nVidia graphics card. You can get the driver on nVidia’s driver page. Once you have the package just run the script which will install 2 packages: NVDAgraphics and NVDAgraphicsr. Now, these pckages are for Quadro cards which thankfully are now cheap, but if your really kool and have a geForce you’ll need to make a modification to /etc/driver_aliases to associate the driver with the hardware. What you do is run /usr/X11/bin/scanpci, find your video card and then add a line to /etc/driver_aliases… so if this is the output from scanpci:

pci bus 0x0001 cardnum 0x00 function 0x00: vendor 0x10de device 0x00f1
 nVidia Corporation NV43 [GeForce 6600/GeForce 6600 GT]

Then you want to add this “nvidia “pci10de,f1″‘ to your /etc/driver_aliases, noticing that the extra 0’s in the divice ID get hacked off. You’ll notice lots of nvidia lines in your driver_aliases but just ignore them, they’re fine. Please note, however, that if you ever choose to BFU your system you’ll need to remove the nVidia drivers and remove any modified lines in your driver_aliases prior to BFUing, so as to not cause problems. You aren’t really required to do this, but it’ll make your life much much simpler to just do it that way.

And finally, get yourself a real window manager. The OpenSolaris window manager of choice is Enlightenment (ok, I’m biased, but I’m right). You can get it from Blastwave or from me (see my earlier quick pack install). You can also find KDE, GNOME (non-JDS), XFCE, WindowMaker, and all the rest of those crappy E wannabe’s via Blastwave, SunFreeWare or search around google.

Good luck and happy hackin’! May the source be with you.

[composed and posted with ecto]

Peter Tribble: Cleaning up Solaris with removef

A great howto on removing those little bits of cruft that ship with Solaris:

Peter Tribble: Cleaning up Solaris with removef:

On Solaris, you can manage packages with the pkgadd and pkgrm commands. Those operate at the level of packages. What if you want to work at a finer level of granularity?

The removef command allows you to delete files, rather than packages.

So, for example, I want to remove the (very broken) copy of cc in /usr/ucb. One possibility is to remove the package (SUNWscpu) that contains it, but that removes the whole of /usr/ucb which could stop a lot of scripts working and removes some useful commands as well.

So, how do we remove /usr/ucb/cc cleanly?

If we look in /var/sadm/install/contents we can see that it’s only used by the SUNWscpu package:

# grep /usr/ucb/cc /var/sadm/install/contents
/usr/ucb/cc f none 0555 root bin 3487 14483 1106351583 SUNWscpu

This means that we don’t have to worry about dependencies, or other packages. So, we tell Solaris that we want to remove the file:

# removef SUNWscpu /usr/ucb/cc
>usr/ucb/cc
>usr/ucb/cc
/usr/ucb/cc

It prints out the names of those files you can remove. (If the file were also part of another package, you wouldn’t be able to delete it.) This doesn’t do the delete for you, it just marks it in the contents file:

# grep /usr/ucb/cc /var/sadm/install/contents
/usr/ucb/cc f none 0555 root bin 3487 14483 1106351583 -SUNWscpu

OK, so we can go and delete it for real:

# rm /usr/ucb/cc

And then we have to get Solaris to clean up the install database:

# removef -f SUNWscpu

And, yes, it’s no longer listed:

# grep /usr/ucb/cc /var/sadm/install/contents

Alongside /usr/ucb/cc, it’s an excellent idea to also eradicate /usr/ucb/lint and /usr/ucb/ld (and pkgrm the SUNWsrh and SUNWsra packages).

Note that, while useful, this technique isn’t safe against patches, updates, and upgrades. They’ll cheerfully put a copy back for you.

[composed and posted with ecto]