OpenBSD Journal

Two little tools for users following -current

Contributed by dwc on from the snap-to-it dept.

Landry Breuil (landry@) writes:

I love perl, I love OpenBSD on my desktops/laptops, and I love our ports-tree infrastructure. That's the main reason I created two little perl hacks which may sound useful to people following -current.

Where is the latest snapshot?

I often have the need to upgrade my machine. Snapshots are here for that but I never know from which mirror take them. So here comes, up2date, a web page showing all OpenBSD ftp mirrors, sorted by freshest snapshots.

The idea is simple : a perl script parses ftp.html using WWW::Mechanize, grabs ftp:// urls, then connects to each mirror using Net::FTP and fetches the last modification date of base42.tgz, xbase42.tgz and zoom-1.0.1.tgz (arbitrarily choosen in last packages), and stores each one in a large hash for i386, sparc64 and amd64 (randomly chosen as most used archs).

Then, with some magic from Template module, it generates the web page you see using this template. Nothing more, nothing less. BTW, it's a first shot, code may be ugly, but the main idea is here…

This page is generated nightly by a cron job on my personal machine, and I'll try to keep it up to date and available.

I want to be notified of updates!

As some may have noticed, two D-Bus notification daemons have been recently imported, I wanted to play a little with it and D-Bus, that was the perfect occasion. The result is update-notifier, another little perl hack.

Here, it uses LWP::Simple to fetch this RSS feed showing all changes made to the ports-tree and kindly provided by folks at ports.openbsd.nu. Then, with the help of XML::Simple, each item is parsed from the feed, and if it has not already been seen it's added to another hash. Then, in /var/run/update-notifier it writes the timestamp of the last item seen in the feed to avoid displaying the entire feed each time.

Finally, using the recently committed Net::DBus module, a connection to the local D-Bus session daemon is made, and a notification containing all updates/new/removed ports is sent to the notification daemon which displays it. An image is often better than words, so here is the mandatory screenshot.

If you want to use it, simply install prerequisite perl modules and one of the available notification daemons, be sure that D-Bus daemon is launched with your session, drop update-notifier somewhere on you system and simply run it from a crontab. Who said OpenBSD was not ready for daily desktop use? :) BTW, I know following ports-changes is another way to be noticed when ports are updated, but this code was fun to write and debug…

(Comments are closed)


Comments
  1. By Anonymous Coward (58.61.140.162) on

    So cool and useful. Thanks for your work. ^_^

  2. By Anonymous Coward (70.173.172.228) on

    good to see x11/xfce/notification-daemon-xfce doesn't suffer from <a href="http://trac.galago-project.org/ticket/144">this bug</a> unlike sysutils/notification-daemon. luckily landry@ didn't want a non-standard position for their notifications.

    Comments
    1. By Anonymous Coward (70.173.172.228) on

      > good to see x11/xfce/notification-daemon-xfce doesn't suffer from this bug unlike sysutils/notification-daemon. luckily landry@ didn't want a non-standard position for their notifications.

      and then i remembered to turn on html mode

  3. By Anonymous Coward (24.37.242.64) on

    Ultra nice work! Thank you!

    Now if only more great work like this was done for those who don't follow -current or for those that follow -stable... ;-)

  4. By e4ea (82.95.251.82) on

    Nice work ;-) In addition I would like to show you the script I am using to download the latest snapshot files.
    The script is checking some mirrors and the freshest files will be mentioned.
    They are compared to the latest files on disk and you can decide to start downloading them. One note; in the script the first mirror is openbsd itself, but ofcourse you should not download files from the master fanout site. Please remember that when using the script. I have added the master site so I know if files are already available there but not on the mirrors. When that is the case, it is worth checking again in a few hours, because most of the time, one of the mirrors is updated then.

    Here is the link to the script: http://pastebin.org/10875

    Hope it will help people using snapshots ;-)

    Jan

    Comments
    1. By e4ea (82.95.251.82) on

      Updated script with automatic mirror selection, or manually: http://pastebin.org/11659

      Comments
      1. Comments
        1. By e4ea (82.95.251.82) on

          Updated snapshot download script with:
          - some bugs fixed
          - functions instead of one large script
          - iso download and burning added
          - better input control
          - xterm colors used

          http://pastebin.org/12519

          Comments
          1. By Anonymous Coward (82.95.251.82) on

            Updated snapshot download script with:

            - automatic and manual selection combined in one function
            - functions instead of one large script
            - better outlining on screen
            - better input control
            - some bugfixes

            http://pastebin.org/15209

            Comments
            1. By e4ea (82.95.251.82) on

              Now available at this website

  5. By Chris Smith (68.61.77.153) on http://chrissmith.org/

    In case of any interest I'll add that I recently started using lftp for a smilar purpose. Lftp's mirror command works quite nicely for getting the latest snapshot, and it only downloads updated files.

    My lftp command file (/usr/local/etc/obsdlftp):
    =============================
    open your.mirror.here
    mirror -X * -i ports.tar.gz /pub/OpenBSD/snapshots /your/path/here/openBSD/snapshots/4.2
    mirror -X x* -X game* -x cdemu42.iso -x install42.iso /pub/OpenBSD/snapshots/i386 /your/path/here/openBSD/snapshots/4.2/i386
    =============================
    Of course the command file needs to be setup for your own use. I use OpenBSD for firewalls and therefore don't need any X-windows stuff, nor game stuff, and I also skip install42.iso.

    The script that calls lftp and makes the bootable ISO image (/usr/local/bin/getobsdsnap):
    =============================
    #!/bin/bash
    lftp -f /usr/local/etc/obsdlftp
    cd /your/path/here/openBSD/snapshots
    mkisofs -v -r -T -J -V "OpenBSD-4.2" -b 4.2/i386/floppy42.fs -c boot.catalog -o ../OpenBSD-i386-4.2snap.iso .
    =============================

    I use the above from my Linux desktop, but did notice that lftp is in ports. Speaking of ports, notice that the current ports.tar.gz file gets grabbed at the same time; that way there's an in sync ports tree on the snapshot CD as well.

    Chris

Latest Articles

Credits

Copyright © - Daniel Hartmeier. All rights reserved. Articles and comments are copyright their respective authors, submission implies license to publish on this web site. Contents of the archive prior to as well as images and HTML templates were copied from the fabulous original deadly.org with Jose's and Jim's kind permission. This journal runs as CGI with httpd(8) on OpenBSD, the source code is BSD licensed. undeadly \Un*dead"ly\, a. Not subject to death; immortal. [Obs.]