2012年12月30日日曜日

GentooでPersistent-MySQLのebuildを作ってみた

Persistent-MySQLのebuildを作ってみたよ

Yesodをやっててどうも一番使いたいpersistent-mysqlのモジュールがhaskellのoverlayに無さげなので自分で作ってみました(もしあったらごめんなさい)
ghcのバージョンは7.6.1でやってますのでご注意下さい。

dev-haskell/persistent-mysqlのインストール 

手前みそのパッケージなので利用する方は自己責任でお願いします。
まず、laymanで私めのoverlayをインポートして下さい。

overlayを追加

karky7 ~ # layman -L | grep karky7
*karky7                    [Git       ] (git://github.com/karky7/karky7-ove...)

マスクを撤去

/etc/portage/package.keywordsへ以下を追加(ここは自分の設定に合わせて下さい)
#####################
# Persistent MySQL
#####################
dev-haskell/persistent-mysql ~amd64
dev-haskell/mysql ~amd64
dev-haskell/mysql-simple ~amd64
dev-haskell/pcre-light ~amd64

persistent-mysqlをemerge

karky7 ~ # emerge -pv persistent-mysql

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

Calculating dependencies... done!
[ebuild  N    ~] dev-haskell/mysql-0.1.1.4::gentoo-haskell  USE="doc hoogle -hscolour -profile" 0 kB
[ebuild  N    ~] dev-haskell/mysql-simple-0.2.2.4::gentoo-haskell  USE="doc hoogle -hscolour -profile" 0 kB
[ebuild  N    ~] dev-haskell/persistent-mysql-1.1.0:0/1.1.0::karky7  USE="doc -hscolour -profile" 0 kB
karky7 ~ # emerge persistent-mysql

Yesodから利用する

テストプロジェクトの作成、MySQLを選択する
karky7 ~ # yesod init
Welcome to the Yesod scaffolder.
I'm going to be creating a skeleton Yesod project for you.

What do you want to call your project? We'll use this for the cabal name.

Project name: pstest   
Yesod uses Persistent for its (you guessed it) persistence layer.
This tool will build in either SQLite or PostgreSQL or MongoDB support for you.
We recommend starting with SQLite: it has no dependencies.

    s      = sqlite
    p      = postgresql
    mongo  = mongodb
    mysql  = MySQL
    simple = no database, no auth
    url    = Let me specify URL containing a site (advanced)

So, what'll it be? mysql
...
...

Developでyesodを起動してみる

karky7 pstest # yesod devel
Yesod devel server. Press ENTER to quit
Configuring pstest-0.0.0...
Warning: This package indirectly depends on multiple versions of the same
package. This is highly likely to cause a compile failure.
package ghc-7.6.1 requires Cabal-1.16.0
package bin-package-db-0.0.0.0 requires Cabal-1.16.0
package yesod-1.1.7 requires Cabal-1.16.0.3
Rebuilding application... (using Cabal library)
Starting development server...

on the commandline: Warning:
    -package-confdist/package.conf.inplace is deprecated: Use -package-db instead
Starting devel application
Devel application launched: http://localhost:3000
Migrating: CREATE TABLE `user`(`id` BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY,`ident` TEXT CHARACTER SET utf8 NOT NULL,`password` TEXT CHARACTER SET utf8 NULL)
Migrating: ALTER TABLE `user` ADD CONSTRAINT `unique_user` UNIQUE(`ident`(200))
Migrating: CREATE TABLE `email`(`id` BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY,`email` TEXT CHARACTER SET utf8 NOT NULL,`user` BIGINT NULL REFERENCES `user`,`verkey` TEXT CHARACTER SET utf8 NULL)
Migrating: ALTER TABLE `email` ADD CONSTRAINT `unique_email` UNIQUE(`email`(200))
Migrating: ALTER TABLE `email` ADD CONSTRAINT `email_user_fkey` FOREIGN KEY(`user`) REFERENCES `user`(`id`)


でMySQLへ接続しているっぽい、もうチョット調べてみます

0 件のコメント:

コメントを投稿