2005-11-21

listupgrade 20051121

portversion の出力じゃバージョン番号が分からなくてイヤんなので、かたくなにそれっぽいツールを自作してるという自己満足に浸るオレ様がきましたよ。

1年前の自分と比べると、

  1. 短いのにクラスとか使っちゃって OO かぶれのつもりかこの野郎
  2. でも短いメソッドに分解できて読みやすくて嬉しいわ
  3. ブロックを使って while を書かなくなった
  4. portversion と組み合わせた方が portupgrade -an 一本槍より少しは速かろう

の辺りに成長が見られるでしょうか。FreeBSD + portversion + portupgrade な環境にべったり依存したスクリプトなので使ってない人は華麗にスルーしてください。

#! /usr/bin/env ruby
# -*- ruby -*-

if ( (`which portversion`.chomp.size < 1) or
       (`which portupgrade`.chomp.size < 1) )
  abort "You need to install portupgrade first !"
end

puts "Have you executed PORTSNAP or CVSUP recently ?"
puts "Please wait for a while."

#
# Manipulating Upgradable Ports
#
class UpgradablePorts

  def initialize
    @needupgrade   = Hash.new()
    @pkgdb_correct = false

    make_list()
    store_versions()
  end # of new()

  #
  # List up upgradable ports with 'portversion' command
  #
  # without version detail
  #
  def make_list()
    open( '| portversion' ).each { |line|
      if ( /^([^\s]+)\s+\</ =~ line )
        @needupgrade.store( $1, false )
      end
    }
  end # of make_list()

  #
  # Storing two version infos, current installed one and latest one
  # with 'portupgrade -n' command
  #
  def store_versions()
    @needupgrade.each_key { |port|
      open( '| portupgrade -n ' + port + ' 2>&1' ).each { |line|
        if ( /Upgrading '(.*)' to '(.*)'/ =~ line )
          @needupgrade.store( $1, $2 )
        elsif ( /Listing the results/ =~ line )
          # This line will appear if portupgrade terminate normally.
          @pkgdb_correct = true
        end
      }
    }
  end # of store_versions()

  #
  # Output result
  #
  def output()
    if ( @needupgrade.size > 0 )
      maxlength = 0
      @needupgrade.each_key { |portname|
        if ( portname.length > maxlength )
          maxlength = portname.length
        end
      }

      @needupgrade.keys.sort.each { |port|
        if ( @needupgrade[port] != false )
          printf( "%-*s --> %s\n", maxlength, port, @needupgrade[port] )
        end
      }
    elsif ( @pkgdb_correct == true )
      puts "All ports are up-to-date ! Congratulation !"
    else
      puts "Something wrong with ``pkgdb'', maybe ? "
    end
  end # of output()

end # of class UpgradablePorts

#
# main()
#
list = UpgradablePorts.new()
list.output()

New www.freebsd.org's font-size is too small !

日本語版も順次移行してるみたいなんだけど、

  • Normal Text って CSS では font-size: 69%
  • Large Text でも font-size: 93%

何考えてんだ。

About

例によって個人のなんちゃらです

Recent Posts

Categories

Tool 日々 Web Biz Net Apple MS ことば News Unix howto Food PHP Movie Edu Community Book Security Text TV Perl Ruby Music Pdoc 生き方 RDoc ViewCVS CVS Rsync Disk Mail FreeBSD Cygwin PDF Photo Zebedee Debian OSX Comic Cron Sysadmin Font Analog iCal Sunbird DNS Linux Wiki Emacs Thunderbird Sitecopy Terminal Drawing tDiary AppleScript Life Money Omni PukiWiki Xen XREA Zsh Screen CASL Firefox Fink zsh haXe Ecmascript PATH_INFO SQLite PEAR Lighttpd FastCGI Subversion au prototype.js jsUnit Apache Trac Template Java Rhino Mochikit Feed Bloglines CSS del.icio.us SBS qwikWeb gettext Ajax JSDoc Rails HTML CHM EPWING NDTP EB IE CLI ck ThinkPad Toy WSH RFC readline rlwrap ImageMagick epeg Frenzy sysprep Ubuntu MeCab DTP ERD DBMS eclipse Eclipse Awk RD Diigo XAMPP RubyGems PHPDoc iCab DOM YAML Camino Geekmonkey w3m Scheme Gauche Lisp JSAN Google VMware DSL SLAX Safari Markdown Textile IRC Jabber Fastladder MacPorts LLSpirit CPAN Mozilla Twitter OpenFL Rswatch ITS NTP GUI Pragger Yapra XML Mobile Git Study JSON VirtualBox Samba Pear Growl Mercurial Rack Capistrano Rake Win RSS Mechanize Sitemaps Android JavaScript Python RTM OOo iPod Yahoo Unicode Github iTunes God SBM friendfeed Friendfeed HokuUn Sinatra TDD Test Project Evernote iPad Geohash Location Map Search Simplenote Image WebKit RSpec Phone CSV WiMAX USB Chrome RubyKaigi RubyKaigi2011 Space CoffeeScript Nokogiri Hpricot Rubygems jQuery Node GTD CI UX Design VCS Kanazawa.rb Kindle Amazon Agile Vagrant Chef Windows Composer Dotenv PaaS Itamae SaaS Docker Swagger Grape WebAPI Microservices OmniAuth HTTP 分析基盤 CDN Terraform IaaS HCL Webpack Vue.js BigQuery Middleman CMS AWS PNG Laravel Selenium OAuth OpenAPI GitHub UML GCP TypeScript SQL Hanami Document SVG AsciiDoc Pandoc DocBook Develop Jekyll macOS Node.js Vite Heroku Transformer AI Data Cloud Wasm