?

Log in

frequent updates in github, twtitter these days

May. 18th, 2015 | 12:25 am

I'm making frequent updates in github and twitter rather than this blog these days; The former for software development activities and the later for misc things mainly.

Link | Leave a comment | Share

python-jinja2-cli and python-anyconfig

May. 6th, 2013 | 05:37 pm

I wrote and keep maintain a jinja2-based template compiler called python-jinja2-cli and use to generate various files such like ks.cfg, KVM guest build scripts, libvirt network XML definitions, doc (rst) sources.

Jinja2 is very powerful template engine and maybe this tool help and be useful for others also.

ssato@localhost% jinja2-cli
Usage: /usr/bin/jinja2-cli COMMAND_OR_COMMAND_ABBREV [Options] [Arg ...]

Commands: render, dumpvars
Command abbreviations: r, d

ssato@localhost% jinja2-cli r -h
Usage: jinja2-cli render [OPTION ...] TEMPLATE_FILE

Options:
  -h, --help            show this help message and exit
  -T TEMPLATE_PATHS, --template-paths=TEMPLATE_PATHS
                        Colon ':' separated template search paths. Please note
                        that dir in which given template exists is always
                        included in the search paths (at the end of the path
                        list) regardless of this option. [., dir in which
                        given template file exists]
  -C CONTEXTS, --contexts=CONTEXTS
                        Specify file path and optionally its filetype, to
                        provides context data to instantiate templates.  The
                        option argument's format is
                        [type:] ex. -C
                        json:common.json -C ./specific.yaml -C yaml:test.dat,
                        -C yaml:/etc/foo.d/*.conf
  -o OUTPUT, --output=OUTPUT
                        Output filename [stdout]
  -E ENCODING, --encoding=ENCODING
                        I/O encoding [UTF-8]
  -D, --debug           Debug mode
  -W, --werror          Exit on warnings if True such like -Werror optoin for
                        gcc
ssato@localhost%

Also I wrote and keep maintain a python library called 'anycnfig' to load multiple cascading configuration files. As python-jinja2-cli depends on it, this is needed to install along with python-jinja2-cli.

python-anyconfig is available from: https://github.com/ssato/python-anyconfig or https://pypi.python.org/pypi/anyconfig

Link | Leave a comment | Share

Enjoyed classical concert: Mendelssohn Violin Concerto; Frankfurt Radio Symphony Orchestra; Paavo Ja

Jun. 6th, 2012 | 03:19 am

I went to the concert: Mendelssohn Violin Concerto; Frankfurt Radio Symphony Orchestra; Paavo Jarvi, Conductor last Saturday at the Minato Mirai Hall in Yokohama City.

She played Mendelssohn Vioiln Concerto w/ the Orchestra and two unaccompanied (?) Viollin Sonatas written by Bach. Her (Hilary-san's) play was very impressive and amazing. I really enjoyed her beautiful violin sounds.

I have almost all CDs played by her but don:t have the latest one: Silfra: Hilary Hahn & Hauschka and trying to get it via amazon

Link | Leave a comment | Share

swiched to xmonad w/o gnome from gnome3

Jan. 15th, 2012 | 02:42 pm

I upgraded my vaio-p from fedora 14 to 16 a while back as X finally became working w/o any closed blobs, only w/ kernel built-in psb_gfx (thanks a lot alan cox for creating this!) + X fbdev.

In Fedora 16, gnome-shell is the default desktop. Unfortunately, 3D acceleration required for gnome-shell is not available in vaio-p: fbdev + psb_gfx do not support 3D acceleration yet and gnome-shell does not work in native mode (run in fallback mode) until Features/Gnome shell software rendering is implemented in Fedora 17.

Gnome-shell fallback mode works fine but it has some features I don't like, so I finally decided to switched to xmonad w/o gnome env. from gnome + xmonad. To accompllish this, I made ~/.Xmodmap, ~/.Xresources for urxvt (rxvt-unicode), ~/.xmonad/session to start {gnome-keyring-daemon, tayer, nm-applet, ibus-daemon}, ~xmobarrc and rpm specs for tayer and yeganesh (tayer.spec, yeganesh.spec and yeganesh-2.4-build-wo-xdg.patch to build yeganesh w/o ghc-xdg-basedir-devel). And I also updated ~/.xmonad/xmonad.hs works w/o gnome:

Now almost all work fine and I quite pleased with this my new lightweight and very efficient desktop env.

Here is a screenshot:

Link | Leave a comment | Share

longest common prefix in python

Aug. 14th, 2011 | 11:34 pm

from all_eq and longest_common_prefix in rpmkit/swapi.py:

# import itertools

def all_eq(xs):
    """Whether all items in xs (list or generator) equals each other.

    >>> all_eq(c for c in "")
    False
    >>> all_eq(c for c in "aaba")
    False
    >>> all_eq(c for c in "aaaa")
    True
    >>> all_eq([c for c in "aaaa"])
    True
    """
    if not isinstance(xs, list):
        xs = list(xs)  # xs may be a generator...

    return xs and all(x == xs[0] for x in xs[1:]) or False


def longest_common_prefix(*args):
    """Variant of LCS = Longest Common Sub-sequence.

    >>> longest_common_prefix("abc", "ab", "abcd")
    'ab'
    >>> longest_common_prefix("abc", "bc")
    ''
    """
    return "".join(x[0] for x in itertools.takewhile(all_eq, itertools.izip(*args)))

Link | Leave a comment | Share

xpack-0.2+

Apr. 13th, 2011 | 01:54 am

I've just released xpack-0.2. Now it looks working on debian system as far as tested in chroot-ed debian system built with debootstrap.

root@gescom:~# ./xpack.py --build-self --format=deb
16:35:38 [WARNING] get_email: 'module' object has no attribute 'check_output'
16:35:38 [WARNING] get_fullname: 'module' object has no attribute 'check_output'
16:35:38 [WARNING] get_email: 'module' object has no attribute 'check_output'
16:35:38 [WARNING] get_fullname: 'module' object has no attribute 'check_output'
configure.ac:2: installing `./install-sh'
configure.ac:2: installing `./missing'
dh binary
   dh_testdir  
   dh_auto_configure
configure: WARNING: unrecognized options: --disable-maintainer-mode, --disable-dependency-tracking
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... no
checking for mawk... mawk
checking whether make sets $(MAKE)... yes
checking whether ln -s works... yes
checking for a sed that does not truncate output... /bin/sed
configure: creating ./config.status
config.status: creating Makefile
configure: WARNING: unrecognized options: --disable-maintainer-mode, --disable-dependency-tracking
   dh_auto_build
make[1]: Entering directory `/tmp/xpack-build-ZG7uDg/xpack-0.2'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/tmp/xpack-build-ZG7uDg/xpack-0.2'
   dh_auto_test
   dh_testroot
   dh_prep
   dh_installdirs
   dh_auto_install
make[1]: Entering directory `/tmp/xpack-build-ZG7uDg/xpack-0.2'
make[2]: Entering directory `/tmp/xpack-build-ZG7uDg/xpack-0.2'
make[2]: Nothing to be done for `install-exec-am'.
test -z "/usr/bin" || /bin/mkdir -p "/tmp/xpack-build-ZG7uDg/xpack-0.2/debian/xpack/usr/bin"
 /usr/bin/install -c -m 644 src/usr/bin/xpack '/tmp/xpack-build-ZG7uDg/xpack-0.2/debian/xpack/usr/bin'
make[2]: Leaving directory `/tmp/xpack-build-ZG7uDg/xpack-0.2'
make[1]: Leaving directory `/tmp/xpack-build-ZG7uDg/xpack-0.2'
   dh_install  
   dh_installdocs
   dh_installchangelogs
   dh_installexamples
   dh_installman
   dh_installcatalogs
   dh_installcron
   dh_installdebconf
   dh_installemacsen
   dh_installifupdown
   dh_installinfo
   dh_pysupport
   dh_installinit
   dh_installmenu
   dh_installmime
   dh_installmodules
   dh_installlogcheck
   dh_installlogrotate
   dh_installpam
   dh_installppp
   dh_installudev
   dh_installwm
   dh_installxfonts
   dh_bugfiles 
   dh_lintian  
   dh_gconf
   dh_icons
   dh_perl
   dh_usrlocal 
   dh_link
   dh_compress 
   dh_fixperms 
   dh_strip
   dh_makeshlibs
   dh_shlibdeps
   dh_installdeb
   dh_gencontrol
dpkg-gencontrol: warning: Depends field of package xpack: unknown substitution variable ${shlibs:Depends}
   dh_md5sums  
   debian/rules override_dh_builddeb
make[1]: Entering directory `/tmp/xpack-build-ZG7uDg/xpack-0.2'
dh_builddeb -- -Zbzip2
dpkg-deb: building package `xpack' in `../xpack_0.2_all.deb'.
make[1]: Leaving directory `/tmp/xpack-build-ZG7uDg/xpack-0.2'
root@gescom:~# ls /tmp/xpack-build-ZG7uDg/
usr  xpack-0.2  xpack_0.2_all.deb
root@gescom:~# dpkg -i /tmp/xpack-build-ZG7uDg/xpack_0.2_all.deb
Selecting previously deselected package xpack.
(Reading database ... 20120 files and directories currently installed.)
Unpacking xpack (from .../xpack_0.2_all.deb) ...
Setting up xpack (0.2) ...
root@gescom:~# dpkg -l xpack
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                              Version                           Description
+++-=================================-=================================-==================================================================================
ii  xpack                             0.2                               A python script to build packages from existing files on your system
root@gescom:~# dpkg -L xpack
/.
/usr
/usr/bin
/usr/bin/xpack 
/usr/share
/usr/share/doc 
/usr/share/doc/xpack
/usr/share/doc/xpack/changelog.gz
/usr/share/doc/xpack/copyright
root@gescom:~#
# echo /etc/resolv.conf | ./xpack.py -n resolvconf -w w --format deb -
13:11:59 [WARNING] get_email: 'module' object has no attribute 'check_output'
13:11:59 [WARNING] get_fullname: 'module' object has no attribute 'check_output'
configure.ac:2: installing `./install-sh'
configure.ac:2: installing `./missing'
dh binary
   dh_testdir
   dh_auto_configure
configure: WARNING: unrecognized options: --disable-maintainer-mode, --disable-dependency-tracking
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... no
checking for mawk... mawk
checking whether make sets $(MAKE)... yes
checking whether ln -s works... yes
checking for a sed that does not truncate output... /bin/sed
configure: creating ./config.status
config.status: creating Makefile
configure: WARNING: unrecognized options: --disable-maintainer-mode, --disable-dependency-tracking
   dh_auto_build
make[1]: Entering directory `/root/w/resolvconf-0.1'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/root/w/resolvconf-0.1'
   dh_auto_test
   dh_testroot
   dh_prep
   dh_installdirs
   dh_auto_install
make[1]: Entering directory `/root/w/resolvconf-0.1'
  ... (snip) ...
dpkg-gencontrol: warning: Depends field of package resolvconf: unknown substitution variable ${shlibs:Depends}
   dh_md5sums
   debian/rules override_dh_builddeb
make[1]: Entering directory `/root/w/resolvconf-0.1'
dh_builddeb -- -Zbzip2
dpkg-deb: building package `resolvconf' in `../resolvconf_0.1_all.deb'.
make[1]: Leaving directory `/root/w/resolvconf-0.1'
#

(xpack is an automatic package building tool just from file list, available from https://github.com/ssato/rpmkit )

Link | Leave a comment | Share

東京電力: 計画停電エリアリスト

Mar. 16th, 2011 | 02:03 am

東京電力の計画停電のリストが PDF (しかもテキストコピー禁止) しかなくていらいらするので全部まとめて、更新があるか手元になければダウンロードして csv 出力するという一連の Makefile とスクリプトを書いてみました: https://github.com/ssato/misc/tree/master/tepco. しかし今は xls 形式もあるようなのであまり意味がなくなってしまったかも。とりあえず意地で xls からの変換にも対応済み。

必ず make -n 等で事前確認を。python-xlrd が必要。やっつけで適当なので Makefile の内容を理解できる方だけ自己責任でどうぞ。なおかつ不正アクセスととられないように頻繁な実行は絶対に避けて下さい。

Link | Leave a comment | Share

xpack.py - cont.

Mar. 10th, 2011 | 01:27 am

I continued working on xpack.py and added some features since its 0.1 release.

As still I don't have a chance to test .deb output and am not sure whether that function works or not in actual. If anyone tried and found any problems on it, please let me know.

Link | Leave a comment | Share

xpack.py - a "super" packaging tool

Feb. 26th, 2011 | 03:03 am

I wrote a script to make "package" in tgz, rpm or deb (experimental) from given files list. Here is an example session how it works:

$ ls
files.list  xpack.py
$ cat files.list
/etc/auto.*
/etc/modprobe.d/*
/etc/resolv.conf
/etc/yum.repos.d/fedora.repo
#/etc/aliases.db
/etc/system-release
/etc/httpd/conf.d
$ python xpack.py -n sysdata -w ./0 -q files.list
03:52:50 [WARNING]  /etc/auto.master is owned by autofs and it (sysdata) will conflict with autofs
03:52:50 [WARNING]  /etc/auto.misc is owned by autofs and it (sysdata) will conflict with autofs
03:52:51 [WARNING]  /etc/auto.net is owned by autofs and it (sysdata) will conflict with autofs
03:52:51 [WARNING]  /etc/auto.smb is owned by autofs and it (sysdata) will conflict with autofs
03:52:51 [WARNING]  /etc/httpd/conf.d is owned by httpd and it (sysdata) will conflict with httpd
03:52:51 [WARNING]  /etc/modprobe.d/blacklist-visor.conf is owned by pilot-link and it (sysdata) will conflict with pilot-link
03:52:51 [WARNING]  /etc/modprobe.d/blacklist.conf is owned by hwdata and it (sysdata) will conflict with hwdata
03:52:51 [WARNING]  /etc/modprobe.d/dist-alsa.conf is owned by module-init-tools and it (sysdata) will conflict with module-init-tools
03:52:52 [WARNING]  /etc/modprobe.d/dist-oss.conf is owned by module-init-tools and it (sysdata) will conflict with module-init-tools
03:52:52 [WARNING]  /etc/modprobe.d/dist.conf is owned by module-init-tools and it (sysdata) will conflict with module-init-tools
03:52:52 [WARNING]  /etc/modprobe.d/libmlx4.conf is owned by libmlx4 and it (sysdata) will conflict with libmlx4
03:52:52 [WARNING]  /etc/modprobe.d/poulsbo.conf is owned by xorg-x11-drv-psb and it (sysdata) will conflict with xorg-x11-drv-psb
03:52:52 [WARNING]  /etc/system-release is owned by fedora-release and it (sysdata) will conflict with fedora-release
03:52:53 [WARNING]  /etc/yum.repos.d/fedora.repo is owned by fedora-release and it (sysdata) will conflict with fedora-release
03:52:53 [WARNING] [Errno 1] Operation not permitted: '/tmp/t/0/sysdata-0.1/src/etc/httpd/conf.d'
$  ls
0  files.list  xpack.py
$ ls 0
sysdata-0.1
$ ls 0/sysdata-0.1/
MANIFEST            README          configure     rpm.mk                         sysdata-0.1.tar.gz                       xpack-package-filelist.pkl
MANIFEST.overrides  aclocal.m4      configure.ac  src                            sysdata-overrides-0.1-1.fc14.noarch.rpm  xpack-sbuild.stamp
Makefile            autom4te.cache  install-sh    sysdata-0.1-1.fc14.noarch.rpm  sysdata.spec                             xpack-setup.stamp
Makefile.am         config.log      missing       sysdata-0.1-1.fc14.src.rpm     xpack-build.stamp
Makefile.in         config.status   rpm           sysdata-0.1.tar.bz2            xpack-configure.stamp
$ rpm -qlp 0/sysdata-0.1/sysdata-0.1-1.fc14.noarch.rpm
/etc/resolv.conf
/usr/share/doc/sysdata-0.1
/usr/share/doc/sysdata-0.1/MANIFEST
/usr/share/doc/sysdata-0.1/README
$ rpm -qlp 0/sysdata-0.1/sysdata-overrides-0.1-1.fc14.noarch.rpm
/etc/auto.master
/etc/auto.misc
/etc/auto.net
/etc/auto.smb
/etc/httpd/conf.d
/etc/modprobe.d/blacklist-visor.conf
/etc/modprobe.d/blacklist.conf
/etc/modprobe.d/dist-alsa.conf
/etc/modprobe.d/dist-oss.conf
/etc/modprobe.d/dist.conf
/etc/modprobe.d/libmlx4.conf
/etc/modprobe.d/poulsbo.conf
/etc/system-release
/etc/yum.repos.d/fedora.repo
/usr/share/doc/sysdata-overrides-0.1
/usr/share/doc/sysdata-overrides-0.1/MANIFEST.overrides
$

If you're interested in it and want to see how it works and what can be done with it, take a look at the output of `xpack.py --show-examples` also.

The idea behind this script is that the system should be consist of static data ('packages') and 'procedual' setup process (such as creating and editing /etc/httpd/conf.d/foo.conf, recovering dot files in users' dirs from backup data, etc.) be removed at a maximum.

What is more, I want to remove most manual and 'procedual' configuration steps need human interaction except for installation of some additional packages to setup our systems.

This script will help packaging configuration files modified by users manually and user data, so to install these packages finishes the system setup almost.

Link | Leave a comment | Share

custom rpm specs for fedora/rhel/etc.

Dec. 30th, 2010 | 01:46 am

I don't have time to become a package maintainer of fedora project for a while but have some rpm specs for fedora in several git repositories: https://github.com/ssato/misc, https://github.com/ssato/misc/tree/master/trac-macros and https://github.com/ssato/misc/tree/master/trac-plugins for example. I think some of them are useful for others, e.g. the rpm spec for python-xlwt. Does anyone interested in taking over these?

Link | Leave a comment | Share