2010年5月18日星期二

RPM Packager学习(3)

内容目录
1.Linux一般软件的安装 1
2.Linux包类型 1
3.RPM介绍 2
3.1.例子 2
3.2格式 2
3.3rpm支持的架构 2
4.RPM使用 3
4.1RPM的运用 3
4.2YUM的运用 4
5.RPM打包 4
5.1预备工作 4
5.1.1预装软件 4
5.1.2建立文件夹树 4
5.2.创建RPM Spec文件 5
5.2.1导言 5
5.2.2 %description区段 5
5.2.3 %prep 区段 5
5.2.4 %build区段 5
5.2.5 %install区段 6
5.2.6 %clean区段 6
5.2.7 %files区段 6
5.2.8 %changelog区段 6
5.3 调用rpmbuild命令编译rpm软件包 7
6. Fedora哦也,酷毙了~ 7

1.Linux一般软件的安装
./cofigure
make && make install

2.Linux包类型
软件包简单的说就是像Windows下.exe或者.msi的样子的安装包。可以将编译好的二进制文件,源代码,文档等以特定格式压缩。使用软件包管理工具可以直接安装。
RPM ——RPM(Redhat Packager Manager),最初是Redhat公司引进在Redhat Linux上的,是以自由软件许可证发布的软件。主要使用的发行版有:RHEL,Fedora,CentOS,Mandriva,openSUSE,国内的Redflag,Qomo,还有一个值得关注的是就快出现的Meego也是用RPM的。They say they like “yum”


Deb——也有不使用RPM管理的发行版,那就是所谓的Debian系,主要是Debian,Ubuntu,Knoppix。


Portage——是Gentoo引入的,类似与FreeBSD中的一个port的一个管理。使用下载.tarball的包在本地编译。能够产生跟高效的软件,但是相当费电,费时。


3.RPM介绍
3.1.例子
我们先来看RPM软件包的几个例子:
kernel-2.4.18-3.i586.rpm
rootfiles-7.2-1.noarch.rpm
firefox-3.6.3-1.i686.rpm

3.2格式
name-version-release.architecture.rpm
name —— 软件的名字;
version——软件的版本;
release——软件包的发行版本;
architecture——架构;
rpm——不用解释了吧。

3.3rpm支持的架构

平台
包上的架构名
Intel compatible 32-bit
i386, i486, i586, i686, athlon
Intel compatible 64-bit
ia64
HPAlpha (原Compaq)
alpha, alphaev5, alphaev56, alphapca56, alphaev6, alphaev67
Sparc/Ultra Sparc (Oracle原Sun)
sparc, sparcv9, sparc64
ARM
armv3l, armv4b, armv4l
MIPS
mips, mipsel
Power PC
ppc, ppciseries, ppcpseries, ppc64
Motorola 68000 series
m68k, m68kmint
SGI MIPS
Sgi
IBM RS6000
rs6000
IBM S/390
i370, s390x, s390
平台无关
noarch


4.RPM使用
4.1RPM的运用
rpm -i 安装
rpm -U 更新
rpm -q 查询
rpm -e 移除

4.2YUM的运用
特别强大,个人感觉比apt-get好用。根本不需要另外配合GUI。请使用man yum。

5.RPM打包
5.1预备工作
5.1.1预装软件
先確定是否安裝了必須的軟件 rpmdevtools yum-utils
如果你本身使用src.rpm构建rpm那么,只需要
yumdownloader --source 软件名
yum-builddep XXX.src.rpm解决依赖性
rpm -Uvh XXX.src.rpm之后就一样了,到SPECS的目录下
5.1.2建立文件夹树
建立打包环境 rpmdev-setuptree

文件夹
用处
BUILD
rpmbuild命令将在这个文件夹建立软件
RPMS
rpmbuild将编译完的rpm包放在此处
SOURCES
软件的源代码
SPECS
.spec文件放在此处
SRPMS
Rpmbuild建立的src.rpm文件放在此处

注:红旗以及Qomo Linux使用非常不安全的形式,将建立软件包的目录树放置于/usr/src/下。这种以root形式的打包方法根本就是错误的!(这是现存最好的打包中文活指南supercyper说的,我们fedora社区的牛牛)这种形式Packager必须以root形式构建软件包,make install的步骤将不知道装到什么地方去了,可能破坏系统。

5.2.创建RPM Spec文件
5.2.1导言
Name: 软件名
Version:软件版本号
Release:包的发行号
Packager:打包的人(一般喜欢写个人邮箱)
License:使用的证书如GPLv2,BSD
URL: 官方网站
Group:用于帮助图形化安装程序将Linux软件分类分开。
Summary: 软件摘要
Source0:软件tarball的名字 %{name}-%{version}.tar.gz
Requires:软件依赖的软件
Buildrequires:编译时所依赖的软件

注:Buildrequies && Requires可以以 ncurses-devel,或者ncurses-devel >= 版本号
%define version XXX的形式可以创建宏,引用时%{version}


5.2.2 %description区段
对于软件的描述,可以持续多行

5.2.3 %prep 区段
一般使用%setup -q,%setup是一个RPM的宏,进行对tarball解压缩的工作。-q表示静默。

5.2.4 %build区段
建立软件的工作,./configure以及make

5.2.5 %install区段
一般情况可以使用%makeinstall来安装程序,这个宏以一种非常聪明的方式直接调用makefile的install目标。
这里我们看一下手工安装所有的文件的例子:
mkdir -p $RPM_BUILD_ROOT%{_bindir} 建立一个可执行文件的目录
mkdir -p $RPM_BUILD_ROOT%{_mandir} 建立一个安装手册的目录
install -m755 myapp $RPM_BUILD_ROOT%{_bindir}/myapp
install -m755 myapp.1 $RPM_BUILD_ROOT%{_mandir}/myapp.1
将文件编译到固定的文件夹,并设置访问权限

5.2.6 %clean区段
清除其他区段产生的文件
rm -rf $RPM_BUILD_ROOT

5.2.7 %files区段
这个区段将列出所有需要包括进软件包的文件。
我们继续上面那个简单的例子:
%{_bindir}/myapp
%{_mandir}/myapp.1
使用%doc标志为文档,%post用于软件包是守护进程的情况,修改系统初始化脚本启动程序。
%files 定義了需要包括進軟件包的所有文件,要求非常嚴格
%defattr(-,root,root,-)
%doc
% {_bindir}被擴展為當前二進制目錄
%{_mandir}使用手冊
%{_datadir}數據(包括圖片等)

5.2.8 %changelog区段
写出对软件包更新的情况一般如下例所示:
* Wed Sep 16 2009 Tomas Mraz
- 8.14.3-8
- Use password-auth common PAM configuration instead of system-auth

5.3 调用rpmbuild命令编译rpm软件包
选项
作用
-ba
建立一个rpm以及一个.src.rpm
-bb
只建立二进制的rpm
-bc
编译但不构建软件包,停止在%build区段
-bp
只做到%prep区段
-bi
在%install后停止
-bl
列出rpm中的文件列表
-bs
只建立src.rpm文件

如:rpmbuild -ba ***.spec
确定平台使用 --target i686


6. Fedora哦也,酷毙了~
My Page: http://scienologies.blogspot.com
http://gnudam.webgarden.com
Fedora Project Contributor -- Ambassador
https://fedoraproject.org/wiki/User:Freakrobot
_______________________________________________
Chinese mailing list
Chinese at lists.fedoraproject.org
https://admin.fedoraproject.org/mailman/listinfo/chinese

2010年5月17日星期一

分区文件系统命令操作

1.烧制Live-USB镜像
dd if=/home/freakrobot/openSUSE-11.2-KDE4-LiveCD-i686.iso of=/dev/sdb

2.调整lvm的分区大小
lvdisplay可以查看逻辑卷
lvresize 可以修改,逻辑卷大小

3.调整文件系统大小
resize2fs命令调整

扩大分区的话,2.&&3.要连续使用,不然逻辑卷变大了,文件系统并没变大~

2010年5月12日星期三

RPM Packager 學習(2)

1.先總結一下rpmbuild的目錄:
BUILD rpmbuild命令在這個目錄中建立軟件
RPMS rpmbuild 命令把她創建的二進制包放在此處
SOURCES 應用程序源代碼
SPECS .spec文件
SRPMS .src.rpm

------------------------------------------------------------

2.spec文件

Emacs果然強大,自動生成了不少東西,一一做筆記
Name: 軟件名
Version: 版本號
Release: 軟件包的版本號
Summary: 軟件摘要
Packager: 打包員名號
Group: Linux應用軟件的分類
License: guess what
URL:
Source0: 包的名字
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
定義一個用於測試安裝的目錄,定義好Buildroot後,就可以通過使用變量$RPM_BUILD_ROOT將應用軟件安裝到Buildroot定義的目錄下,
BuildRequires:
Requires:
兩種依賴包,編譯依賴和運行的依賴
%description
對軟件描述,可以持續多行。
下面主要分為4部分,%prep,%build,%configure,%install
%prep
%setup -q
準備工作,一般用%setup就可以了。

%build
%configure 相當於./configure
make %{?_smp_mflags}
絕大多數情況用make就可以了,編譯libfetion時我先用了qmake-qt4。

%install
rm -rf $RPM_BUILD_ROOT
make install DESTDIR=$RPM_BUILD_ROOT
可以使用%makeinstall安裝程序,也可以根據所用軟件帶的install.sh腳本來自己寫。

%clean
rm -rf $RPM_BUILD_ROOT


%files 定義了需要包括進軟件包的所有文件,要求非常嚴格
%defattr(-,root,root,-)
%doc
%{_bindir}被擴展為當前二進制目錄
%{_mandir}使用手冊
%{_datadir}數據(包括圖片等)

%changelog 如名日誌
* Sat May 08 2010 freakrobot
-Initial libfetion package

------------------------------------------------------------

3.最後是rpmbuild的參數使用:
-ba 同時建立二進制軟件包和源代碼軟件包
-bb 只建立二進制軟件包
-bc 只編譯不製作rpm包
-bp 為建立rpm包做準備
-bi 創建二進制軟件包並安裝
-bl 檢查RPM包的文件列表
-bs 只建立源代碼包

2010年5月10日星期一

RPM packager學習(1)

今天吃壞了,拉肚子,課也沒去上,真是悲劇。還好學了一下framebuffer,最後再整理一下打包問題的就睡覺了。
西廂計劃不怎麼好用,副產品打rpm包倒是簡單的會了,呵呵~

先补充一下包的基本术语:
name-version-release.architecture.rpm
name -- 包名
version -- 版本号
release -- 包的更新号
architecture -- 架构

支持的架构包括:


Platform

Architectures

Intel compatible 32-bit

i386, i486, i586, i686, athlon


Intel compatible 64-bit

ia64

HPAlpha (formerly Digital, Compaq)

alpha, alphaev5, alphaev56, alphapca56, alphaev6,
alphaev67

Sparc/Ultra Sparc (Sun)

sparc, sparcv9, sparc64


ARM

armv3l, armv4b, armv4l

MIPS

mips, mipsel

Power PC

ppc, ppciseries, ppcpseries, ppc64

Motorola 68000 series

m68k, m68kmint

SGI MIPS

Sgi

IBM RS6000

rs6000


IBM S/390

i370, s390x, s390

Platform independent

noarch


1.安裝:先確定是否安裝了必須的軟件 rpmdevtools yum-utils,
2.建立打包的環境,$rpmdev-setuptree
3.打包
3.1打包*.src.rpm文件
3.1.1*.src.rpm文件可以通過yumdownloader –source *.src.rpm獲取
3.1.2檢查依賴性關係yum-builddep *.src.rpm
3.1.3安裝*.src.rpm包 rpm -Uvh *.src.rpm
3.1.4進入SPECS文件夾,rpmbuild -ba *.spec就可以了
3.2打包tarball文件
3.1.1將包放到SOURCE文件夾
3.1.2自己寫spec文件
3.1.3 rpmbuild同上

想睡了,spec文件寫法跟rpmbuild參數明天繼續總結。

一个kernel进阶者的赠言

hey all.
those who want to know..i did nothing big magical. just asked people who are already working ..like many of us ask on this list only
then followed what they said.

its like one thing i learnt is ...

"Better try it once then again then again before asking it once."
as asking fetches partial may be incorrect knowledge but asking after rehearsing things
will fetch you correct information.

it requires persistence no doubt after when it seems no use of it .
i did very normal things like
studying

1)Bach -- Design of Unix OS by Maurice J Bach
2)ALP -- Advance linux Programming
http://www.advancedlinuxprogramming.com/
3)UTLK -- Understanding The Linux Kernel
4)LDD -- Linux Device Drivers

then i was still stuck to get a project in resume.

then explore open source sourceforge community ...
its difficult i accept totally.... rather it was very very difficult to get a single project from thousands lying there .
but only hope was it wasnt impossible.

and i got a few ...

that's all is reqd for getting shortlisted.

after that you are on your own .good projects just mean getting shortlisted ...that's it ..
The Complete game is still left .... to successfully clear interview is with another effort in C data structures then kernel ofcourse.

that's was all.

Nidhi

framebuffer资料整理

为了要做图形学的作业,又不想用windows,研究了一下framebuffer。大牛们的文章都很棒,我就不献丑了,整理一下资料:
Framebuffer原理、使用、测试系列文章

此文作为讲原理的文章还是相当到位的,对内核中framebuffer的结构有了一定的了解,但是这上面的代码却非常令人费解,完全没有注释。

Examples(English)

代码入门(中文版)
这个链接里面的代码注释非常棒,而且由浅入深,一下子就看懂了。

有了上面两篇文章framebuffer基本上都会用了,其他的也还不错,可以参考一下:
Framebuffer 画点,画线,画多边形,画圆
Framebuffer HOWTO

2010年5月9日星期日

First time blinking LED

I try for several days, and successful killed pre-installed WinCE in my board and blinked my LED. This was really exciting. And it should be the beginning of happiness. So I want to make a memo to remember this great time.

To make jtag work on Linux your need nothing to do. But if you want to make it work under Windows you need to install the device driver by copying the jtag.sys into the system32 dir and install it under the control panel.

The next thing need to mention is to setup the arm-linux-gcc. Just copy the whole directory of arm-linux-gcc under the /usr/arm directory. And export the environment as:
$ export PATH = $PATH:/usr/arm/gcc-3.4.5-glibc-2.3.6/bin
And change the /etc/environment file into
PATH=”/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/arm/gcc-3.4.5-glibc-2.3.6/bin”

Then I just use the example the book gived me, and write a Makefile and make.

That was easy. However, I got some problems write the program to the NAND flash on my board. Later I figure out that. I got “K9F1G08” on my board which is not support by SJF2440. So I have to switch my work to Windows. With “H-JTAG” I use the config file “hfc”, it gives me as an example. Just have to change the “K9F1208” into “K9F1G08”. The most horrible thing is the “H-JTAG” call “program” when he referred burn or download to NAND FLASH. That mislead me, and waste me a lot of time. Download it and earse it immediately. SILLY.

However still did not understand how the initscript works, waiting for answers from my Mentor now.

MBR analysis

A master boot record (MBR), or partition sector, is the 512-byte boot sector that is the first sector ("LBA Sector 0") of a partitioned data storage device such as a hard disk.
----Wikipedia

00 ~ 1BD 446byte boot code area
1BE ~ 1CD 16 byte partition 1
1CE ~ 1DD 16 byte partition 2
1DE ~ 1ED 16 byte partiion 3
1EE ~ 1FD 16 byte partition 4
1FE ~ 1FF 2 byte sigatur(55AA)

1. That's why there is only 4 physical partition.
2. The sigatur must be 55AA, otherwise the MBR is not available.

In 1BE ~ 1CD,
00~00 0x80 -- bootable 0x00 -- otherwise
01~03 CHS start address
04~04 partition type (83--linux 82--linux swap)
05~07 CHS end address
08~0B LBA start
0C~0F sector number

That's why there is only

Daemonize

a daemon (pronounced /ˈdeɪmən/ or /ˈdiːmən/)[1] is a computer program that runs in the background, rather than under the direct control of a user; they are usually initiated as background processes.
In a Unix environment, the parent process of a daemon is often (but not always) the init process (PID=1). Processes usually become daemons by forking a child process and then having their parent process immediately exit, thus causing init to adopt the child process.

Example of Daemonize
http://www.itp.uzh.ch/~dpotter/howto/daemonize

Can't create hard links as you want

In Unix like system, it's not possible for your create a hard link everywhere you like. For example, hard links cannot be created between directories. Also, they cannot be created between files in different filesystems.

That means if there is a file "/home/xxx/hello", you can't just create a hard link in /boot or /tmp, if you separate /home as a solo tree.
because that confuse the OS,


[freakrobot@acm lisp]$ ln /home/freakrobot/Code/lisp/dbmanage.lisp /boot
ln: creating hard link `/boot/dbmanage.lisp' => `/home/freakrobot/Code/lisp/dbmanage.lisp': Invalid cross-device link


reference: http://www.cyberciti.biz/tips/why-isnt-it-possible-to-create-hard-links-across-file-system-boundaries.html

Lisp learning notes1

Although Lisp is a powerful programming language with a very simple syntax. However, the ads is always said in a tricky way. Lots of functions and marcos should be remembered if you want to use lisp. I just want to make a list of functions and marcos I have met in the book to keep me remember of all this.
Here it is:















































formatmost flexible way of output
ta shorthand for the stream *standard-output*
defunfunctions define
loadload a file of expression
compile-filecompile a lisp file
listmake a list
(list :a 1 :b 2 :c 3)property list
getfchoose element by property
defvardefine a variable
pushadd items 1st to 2nd
dolistlooping from 2nd param
~aoutput format consume one argument
~10temit spaces
~%emit one more newline to put blank line
~{ and ~}loops over that list
force-output=flush in c
read-lineread a single line of text
*query-io*global variable contain input stream
orlogical operation
y-or-n-pask for y/n
looprepeat until return called
returnend loop
ifjust "if"
notlogical operation
with-open-fileopens a file
with-standard-io-syntaxensures certain variables that affect
printoutput as a lisp readable format
setfassignment operator
readread from the stream in
evenpreturn T if argument is an even number
remove-if-nottakes a predicate and a list return list match predicate
lambdaanonymous function
equalcompare strings
mapcarmap over a list
defmarcodefine a macro
reversereverse a list
popinverse operation of push
-pcheck if the param is be passed
' or `stop evaluation expression
,start evaluated
#shorthand for get function by name
functionsyntactic sugar for #'
@splices the value
&key / &rest / &optionalvary params
funcall(funcall #'foo para1 para2)call functions
apply==funcall paras be a list