2013年3月25日月曜日

gentooのJuicyPixelsのebuildを作りました

JuicyPixelsで画像をオイタしてみた

JuicyPixelsとは、png、jpg、gif、などの画像を色々いたずらできるhaskellのパッケージで、お勉強をかねて画像をいたずらしてみました、でついでにgentooのebuildも作って見ましたので良かったら使って下さい

JuicyPixelsのインストール

laymanリポジトリにebuildを作っておいたのでそちらをもってきて、maskを外してください。

iichiko ~ # layman -a karky7
...
...
iichiko ~ # emerge -s juicypixels
Searching...    
[ Results for search key : juicypixels ]
[ Applications found : 1 ]

*  dev-haskell/juicypixels [ Masked ]
      Latest version available: 3.0
      Latest version installed: [ Not Installed ]
      Size of files: 58 kB
      Homepage:      https://github.com/Twinside/Juicy.Pixels
      Description:   This library can load and store images in PNG,Bitmap, Jpeg, Radiance and read Gif images.
      License:       BSD3
...
iichiko ~ # emerge -pv juicypixels
 * Last emerge --sync was 33d 4h 29m 37s ago.

These are the packages that would be merged, in order:

Calculating dependencies... done!
[ebuild     U ~] dev-haskell/primitive-0.5.0.1:0/0.5.0.1::gentoo-haskell [0.4.1:0/0::gentoo-haskell] USE="doc hoogle -hscolour -profile" 11 kB
[ebuild     U ~] dev-haskell/vector-0.10.0.1:0/0.10.0.1::gentoo-haskell [0.9.1:0/0::gentoo-haskell] USE="doc hoogle -hscolour -profile" 101 kB
[ebuild  N    ~] dev-haskell/juicypixels-3.0:0/3.0::karky7  USE="doc -hscolour -profile" 59 kB

Total: 3 packages (2 upgrades, 1 new), Size of downloads: 170 kB

 * IMPORTANT: 10 news items need reading for repository 'gentoo'.
 * Use eselect news to read news items.

iichiko ~ # emerge dev-haskell/juicypixels
binaryパッケージが最新過ぎるとバージョンの依存関係でエラーになるので、その時はbinary-0.6.*あたりをインストールしてみて下さい。

AKIRAの金田をpngからjpgにしてみる


png画像をjpg画像へそのまま変換してファイルに保存するサンプルコード、初めに適当なpngファイルを用意して下さい。

「大覚 アキラ様」の金田.pngをjpgに変換する



import Codec.Picture

img :: IO (Either String DynamicImage)
img = readImage "akira.png"

main :: IO()
main = do
  img >>= (\(Right dynamicImage) -> return dynamicImage) >>=
    (\dynamicImage -> saveJpgImage 100 "akira.jpg" dynamicImage)

同一ディレクトリにjpgが保存される、まぁ同じ画像でおもろくないが...でもhaskellたのしい、では

2013年3月18日月曜日

gentooでudevのUpdateにはご注意下さい...

最近のアップデートでudevが上がったらしく、ちょっとbootできなくなったのでその辺の修理方法をちょっと載せておきます。

ちなみにudevのバージョンはsys-fs/udev-197-r8です

udevとは?


udevとはいろいろなデバイスを接続したタイミングで、自動で使えるようにしてくれる便利な機能。 これが無いといちいちmkmodとかデバイスのメジャー番号とか指定してやらなくてはならないしとにかく面倒、で、これを酔うてるうちにUpdateしてしまい、窮地に追い込まれた始末。

まずい状態のx220


こんな感じでbootができない



修理方法


カーネルの設定が合わないらしく、udevの機能を利用してカーネルがデバイスをマウントできないらしいので再設定しなおす。 ここでOSを起動する環境が無い方は、Gentooのbootディスクを使ったり、KNOPPIXでbootしたりすればOK、自分はGentooのbootディスクでCDからbootしました
bootしましたら、HDDの環境へchrootします、実際のデバイスは自分の環境ですので読み替えてお願いします
karky7 ~ # mount /dev/sda5 /mnt/gentoo
karky7 ~ # mount -t proc none /mnt/gentoo/proc
karky7 ~ # mount -o bind /dev /mnt/gentoo/dev
karky7 ~ # chroot /mnt/gentoo /bin/bash

以下、chroot環境です
 ~ # env-update
 ~ # source /etc/profile

カーネルの再設定


今までの設定が不完全だったらしく、udevまわりの設定を再度見直し、以下のカーネル設定を修正
General setup  --->
  [ ] Enable deprecated sysfs features to support old userspace tools
  [*] Enable signalfd() system call
-*- Networking support  ---> 
  Networking options  --->
    <*> Unix domain sockets

Device Drivers  --->
  Generic Driver Options  --->
    [*] Maintain a devtmpfs filesystem to mount at /dev
    [*]   Automount devtmpfs at /dev, after the kernel mounted the rootfs
  < > ATA/ATAPI/MFM/RLL support (DEPRECATED)  --->

File systems  --->
  [*] Inotify support for userspace
  [*] /proc file system support 
  -*- sysfs file system support
設定が完了したらカーネルを再ビルドしてください
# make && make modules && make modules_install && make install
# reboot
これで起動することができました、皆さんシステムをupdateするときは、飲酒は止めましょう...笑