2011年1月26日 星期三

tar: --xform

Using --xform to add prefix folder to the files.

Init test:

$ rm test abc* -rf;
$ mkdir test/1 -p;
$ touch test/1/1;
$ ln -s 1 test/1/2;



$ tar c -C test 1 --xform 's/^/abc\//' | tar xv
abc\\/1/
abc\\/1/1
abc\\/1/2
There are additional // exist which we don't want.

Use , as the delimiter:
$ tar c -C test 1 --xform 's,^,abc/,' | tar xv
abc/1/
abc/1/1
abc/1/2
$ ls abc/1/ -al
total 8
drwxr-xr-x 2 test test 4096 2011-01-27 09:04 .
drwxr-xr-x 3 test test 4096 2011-01-27 09:06 ..
-rw-r--r-- 1 test test 0 2011-01-27 09:04 1
lrwxrwxrwx 1 test test 5 2011-01-27 09:06 2 -> abc/1
This is ok, but prefix abc is added to link as well, which is certainly not what we want

Add S:
$ tar c -C test 1 --xform 's,^,abc/,S' | tar xv
abc/1/
abc/1/1
abc/1/2
test@cavm-release:~$ ls abc/1/ -al
total 8
drwxr-xr-x 2 test test 4096 2011-01-27 09:04 .
drwxr-xr-x 3 test test 4096 2011-01-27 09:06 ..
-rw-r--r-- 1 test test 0 2011-01-27 09:04 1
lrwxrwxrwx 1 test test 1 2011-01-27 09:07 2 -> 1
This is what we want.

TAR: 6.7 Modifying File and Member Names
http://www.gnu.org/software/tar/manual/html_section/transform.html
Any delimiter can be used in lieu of ‘/’, the only requirement being that it be used consistently throughout the expression. For example, the following two expressions are equivalent:


s/one/two/
s,one,two,

Changing delimiters is often useful when the regex contains slashes. For example, it is more convenient to write s,/,-, than s/\//-/.

(.......................)

Using the expression ‘s,^,/usr/local/,’ would mean adding ‘/usr/local’ to both regular archive members and to link targets. In this case, ‘/lib/libc.so.6’ would become:


/usr/local/lib/libc.so.6 -> /usr/local/libc-2.3.2.so

This is definitely not desired. To avoid this, the ‘S’ flag is used, which excludes symbolic link targets from filename transformations

Fedora14

Minimum Installation

dhclient eth0
yum install make gcc flex bison yum-utils kernel-devel-`uname -r` git




Download FC14 kernel source
yum install kernel-devel-`uname -r`

Fedora: Update/Rebuild Linux Kernel
http://scottshulinux.blogspot.com/2010/08/fedora-re-build-linux-kernel.html
yum install yum-utils
yumdownloader --source kernel
yum install kernel-headers
rpm -ivh kernel-2.6.32.16-150.fc12.src.rpm

2011年1月25日 星期二

加快linux開機速度

ELC-E 2010: The Right Approach to Minimal Boot Times
http://www.slideshare.net/andrewmurraympc/elce-the

加快linux開機速度
http://blog.roodo.com/thinkingmore/archives/14947055.html

* 使用 Arjan van de Ven 對 kernel aync 的 patch
* 把不重要的 module 改成 loadable
* 修改init/do_mounts.c以提早mount root
* 修改init/main.c裡的init_post,看了以後,我想應該是避免掉open /dev/console還有移掉不必要的步驟以提速。
* improve memcpy (這我不知道是哪裡的,要再查看看)
* reduce kernel size:這可以加快 u-boot 載入時間。一般手段就移掉不必要的driver/module。
* reduce u-boot delay time:u-boot 預設有 delay time,這可以改掉
* kernel 壓縮或不壓縮:用zImage的話可以減少kernel大小,可是要評估解壓縮時間跟載入時間的平衡來決定壓縮或不壓縮。
* 利用 gcc 的 --finstrument-functions --function-sections 去 profile function 的時間 (簡報說加了這兩個 argument,就可以在 __cyg_profile_func_enter/__cyg_profile_func_exit 裡放 code,這個要鑽研 gcc 試試看。)
* 利用ubootchart/bootchart.org工具來測時間。

Finding a branch point with Git



For complicated branches, there might be more than one boundary. It's suggested to add a "tail -n 1" to get the last boundary.
git rev-list --boundary HEAD...master | grep ^- | cut -c2- | tail -n 1
(This command was found incorrect in some case, multiple boundary found, but the last boundary wasn't the desired one, but the second last.)

Determining if a Git repository contains a particular commit - Stack Overflow
http://stackoverflow.com/questions/3506082/determining-if-a-git-repository-contains-a-particular-commit

if [ "$(git rev-parse $commitA)" == "$(git merge-base $commitA $commitB)" ]; then ...; else ...; fi
"git merge-base" will also get the result of finding the branch point, for merge-base is the branch point of the two branches.
git merge-base $commitA $commitB

http://stackoverflow.com/questions/1527234/finding-a-branch-point-with-git
git rev-list --boundary branch-a...master | grep ^- | cut -c2-

or add it to aliases in ~/.gitconfig :
[alias]
diverges = !sh -c 'git rev-list --boundary $1...$2 | grep ^- | cut -c2-'

so I can call it as:
git diverges branch-a master

2011年1月9日 星期日

專業的定義

http://www.youtube.com/watch?v=yKWwrxaOxsY&feature=player_embedded

病看不好, 還是得還醫生錢.
官司打輸也得還律師費.
我們和他們一樣, 都是專業的.
專業的意思就是 工照做, 盡量做, 不包好, 錢照收 => 這個就是"專業".
我....不專業.....

http://plog.longwin.com.tw/news-life-joke/2011/01/05/sadness-of-plan-rd-design-2010

2011年1月2日 星期日

git - out of memory (OOM)

If you just cannot get over with the issue, e.g. clone-ing or fetch-ing, just transfer the .git directly.

Disable auto gc by:

git config --global gc.auto 0


git clone ....
remote: fatal: Out of memory, malloc failed (tried to allocate 272691112 bytes)
Fixed by:
git repack -adf --window-memory=256m


Re: git gc - out of memory
http://lists-archives.org/git/705379-git-gc-out-of-memory.html
http://lists-archives.org/git/705471-git-gc-out-of-memory.html
git repack -adf --window=memory
--window-memory=[memory]


Git clone fails with out of memory error - "fatal: out of memory, malloc failed (tried to allocate 905574791 bytes) / fatal: index-pack failed" - Stack Overflow
http://stackoverflow.com/questions/7607970/git-clone-fails-with-out-of-memory-error-fatal-out-of-memory-malloc-failed
git config pack.windowMemory 10m
git config pack.packSizeLimit 20m
git repack -a -d

(......)

git clone will not look at your pack.packSizeLimit setting, it'll anyway transfer everything in a single pack - unless it changed since the last time I looked.


git - Large pack causes git clone failures ... what to do?
http://git.661346.n2.nabble.com/Large-pack-causes-git-clone-failures-what-to-do-td5481488.html
A clone doesn't split its pack. It stores the entire project
as a single pack file. If your filesystem cannot do that, the
clone fails.


git-repack(1) - Linux man page
http://linux.die.net/man/1/git-repack

git gc: Out of memory, malloc failed
http://blog.richliu.com/2011/04/22/1050/