Allen 2010-04-27 7420 0 0 0 0

 


按鸟哥私房菜中的教程制作,很小的一过程,搞来搞去,花费了近一个上午的时间……
最后,还是没有完全成功!自己学还真是很难搞~~

1,生成showvbird.sh,在目录/usr/src/redhat/SOURCES下
[[email protected] ~]# cd /usr/src
[[email protected] src]# ll
total 0
[[email protected] src]# vi showvbird.sh

#!/bin/bash 
# This file is just used to demo the RPM packaging. 
# the only thing is showing the hostname. 

HOST=`/bin/hostname` 
/bin/echo $HOST 

[[email protected] src]# mv showvbird.sh /usr/src/redhat/SOURCES
mv: cannot move `showvbird.sh' to `/usr/src/redhat/SOURCES': No such file or directory

[[email protected] src]# mkdir -p /usr/src/redhat/SOURCES
[[email protected] src]# mv showvbird.sh /usr/src/redhat/SOURCES
[[email protected] src]# cd redhat/SOURCES/
[[email protected] SOURCES]# ll
total 8
-rw-r--r-- 1 root root 150 Apr 26 18:37 showvbird.sh
[[email protected] SOURCES]# chmod 755 showvbird.sh
[[email protected] SOURCES]# ll
total 8
-rwxr-xr-x 1 root root 150 Apr 26 18:37 showvbird.sh
[[email protected] SOURCES]# tar -zcvf showvbird.tar.gz showvbird.sh
showvbird.sh
[[email protected] SOURCES]# ll
total 16
-rwxr-xr-x 1 root root 150 Apr 26 18:37 showvbird.sh
-rw-r--r-- 1 root root 236 Apr 26 18:40 showvbird.tar.gz

2,生成showvbird.spec,在目录/usr/src/redhat/SPECS下

[[email protected] SOURCES]# cd /usr/src/redhat/SPECS
bash: cd: /usr/src/redhat/SPECS: No such file or directory
[[email protected] SOURCES]# mkdir -p /usr/src/redhat/SPECS
[[email protected] SOURCES]# cd /usr/src/redhat/SPECS
[[email protected]ost SPECS]# vi showvbird.spec

Summary:   This is a demo RPM package. 
Name:      showvbird 
Version:   1.0 
Release:   1 
Copyright: GPL 
Group:     VBird's Home 
Source:    showvbird.tar.gz   <==这个就是刚刚建立起来的Tarball档案! 
Url:       http://linux.vbird.org 
Packager:  VBird 
%description 
This package is just a demo RPM. 
%prep 
%setup –c 
%install 
install -m 755 showvbird.sh /usr/local/bin/showvbird.sh 
%files 
/usr/local/bin/showvbird.sh

[[email protected] SPECS]# ll
total 8
-rw-r--r-- 1 root root 447 Apr 26 18:43 showvbird.spec

3,编译并打包成为RPM档案啦
[[email protected] SPECS]# rpmbuild -bb showvbird.spec
bash: rpmbuild: command not found

-->出问题了,找不到rpmbuild命令file……
--查询得知:这个命令要安装rpm-build*.rpm包……而此rpm包在安装盘里可以找到。
--又是rpm包……安装吧,这一安装又出麻烦了……
--还好最后万幸,成功了,详细见:
RPM套件rpm-build安装出错一例:NOKEY、elfutils is needed
http://blog.chinaunix.net/u3/107265/showart_2223110.html

--重新编译……
[[email protected] SPECS]# rpmbuild -bb showvbird.spec
error: Legacy syntax is unsupported: copyright
error: line 5: Unknown tag: Copyright: GPL
--又报错

--删除第5行:Copyright: GPL 重新编译
[[email protected] SPECS]# rpmbuild -bb showvbird.spec
error: License field must be present in package: (main package)

--终于找到一篇文档:http://phorum.vbird.org/viewtopic.php?f=2&t=25158&view=previous
((終於找到"Unknown tag: Copyright: GPL"解決的方法了!! 
在redhat官網看到一篇討論, 
----------------------------------------------------------------------------- 
The tag is deprecated for a long time already. You could have used 
the "License:" tag much (!) earlier already. 
----------------------------------------------------------------------------- 
需要將"Copyright:"該改成新的Tag"License:" 
後來測試卡到的Error就Pass過了~~ 
))
--修改文件,将“Copyright:”改为“License:”,重新编译
[[email protected] SPECS]# rpmbuild -bs showvbird.spec
Wrote: /usr/src/redhat/SRPMS/showvbird-1.0-1.src.rpm

--OK,大功告成……

[[email protected] SPECS]# cd /usr/src/redhat
[[email protected] redhat]# ll
total 40
drwxr-xr-x 2 root root 4096 Jan  4  2007 BUILD
drwxr-xr-x 8 root root 4096 Apr 26 19:55 RPMS
drwxr-xr-x 2 root root 4096 Jan  4  2007 SOURCES
drwxr-xr-x 2 root root 4096 Apr 26 21:13 SPECS
drwxr-xr-x 2 root root 4096 Apr 26 21:13 SRPMS
[[email protected] redhat]# ll ./BUILD/
total 0
[[email protected] redhat]# ll ./SRPMS/
total 8
-rw-r--r-- 1 root root 2083 Apr 26 21:13 showvbird-1.0-1.src.rpm
[[email protected] redhat]# rpm -ivh /usr/src/redhat/SRPMS/showvbird-1.0-1.src.rpm 
   1:showvbird              ########################################### [100%]
[[email protected] redhat]# rpm -qi showvbird
package showvbird is not installed
[[email protected] redhat]# rpm -qi showvbird
package showvbird is not installed
[[email protected] redhat]# rpm --rebuilddb
[[email protected] redhat]# rpm -qi showvbird
package showvbird is not installed
--很奇怪,竟然说没有安装……

--进入到rpm包目录中安装
[[email protected] redhat]# cd /usr/src/redhat/SRPMS
[[email protected] SRPMS]# ll
total 8
-rw-r--r-- 1 root root 2083 Apr 26 21:13 showvbird-1.0-1.src.rpm
[[email protected] SRPMS]# rpm -ivh showvbird-1.0-1.src.rpm 
   1:showvbird              ########################################### [100%]
[[email protected] SRPMS]# rpm -ql showvbird
package showvbird is not installed
 
--还是没有安装……
13:08 2010-04-27
待解决……
 

求助:http://phorum.vbird.org/viewtopic.php?f=2&t=33883

 
PS:终于找到问题了。
--原来我上面安装的都是srpm包,当然没有安装成功了……但找rpm包时,竟然没有。
--终于发现,原来问题出来在我编译的那句:rpmbuild -bs showvbird.spec
就是那个-bs参数,这个是我自作聪明改的……
  -bb                           build binary package only from <specfile>
  -bs                           build source package only from <specfile>
可以看出,这个只生成srpm……真是失败……
 
--找到问题就好说了,重新编译一下
[[email protected] SPECS]# rpmbuild -bb showvbird.spec
Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.49023
+ umask 022
+ cd /usr/src/redhat/BUILD
+ cd /usr/src/redhat/BUILD
+ rm -rf showvbird-1.0
+ tar -xvvf -
+ /bin/gzip -dc /usr/src/redhat/SOURCES/showvbird.tar.gz
-rwxr-xr-x root/root       150 2010-04-26 18:37:09 showvbird.sh
+ STATUS=0
+ '[' 0 -ne 0 ']'
+ cd showvbird-1.0
/var/tmp/rpm-tmp.49023: line 28: cd: showvbird-1.0: No such file or directory
error: Bad exit status from /var/tmp/rpm-tmp.49023 (%prep)
 
 
RPM build errors:
    Bad exit status from /var/tmp/rpm-tmp.49023 (%prep)
 
--查看错误文件 /var/tmp/rpm-tmp.49023
[[email protected] SPECS]# ll /var/tmp/rpm-tmp.49023
-rw-r--r-- 1 root root 839 Apr 26 22:34 /var/tmp/rpm-tmp.49023
[[email protected] SPECS]# vi /var/tmp/rpm-tmp.49023
--内容如下:
(((
#!/bin/sh
 
  RPM_SOURCE_DIR="/usr/src/redhat/SOURCES"
  RPM_BUILD_DIR="/usr/src/redhat/BUILD"
  RPM_OPT_FLAGS="-O2 -g -march=i386 -mcpu=i686"
  RPM_ARCH="i386"
  RPM_OS="linux"
  export RPM_SOURCE_DIR RPM_BUILD_DIR RPM_OPT_FLAGS RPM_ARCH RPM_OS
  RPM_DOC_DIR="/usr/share/doc"
  export RPM_DOC_DIR
  RPM_PACKAGE_NAME="showvbird"
  RPM_PACKAGE_VERSION="1.0"
  RPM_PACKAGE_RELEASE="1"
  export RPM_PACKAGE_NAME RPM_PACKAGE_VERSION RPM_PACKAGE_RELEASE
 
 
 
  set -x
  umask 022
  cd /usr/src/redhat/BUILD
cd /usr/src/redhat/BUILD
rm -rf showvbird-1.0
/bin/gzip -dc /usr/src/redhat/SOURCES/showvbird.tar.gz | tar -xvvf -
STATUS=$?
if [ $STATUS -ne 0 ]; then
  exit $STATUS
fi
cd showvbird-1.0
[ `/usr/bin/id -u` = '0' ] && /bin/chown -Rhf root .
[ `/usr/bin/id -u` = '0' ] && /bin/chgrp -Rhf root .
/bin/chmod -Rf a+rX,u+w,g-w,o-w .
 
exit 0
)))
 
由于shell部分还未修炼,这部分还看不懂,待解决……
13:51 2010-04-27


【版权声明】
本文为原创,遵循CC 4.0 BY-SA版权协议!转载请附上原文出处链接及本声明。
原文链接:https://tdlib.com/am.php?t=yDXzXHVGibe9
Tag: Linux Linux测试 Linux基础 TTTBLOG
我也要发一个   ·   返回首页     ·   返回[Linux]   ·    前一个  ·   下一个
未登录,
请先 [ 注册 ] or [ 登录 ]
(一分钟即可完成注册!)
返回首页     ·   返回[Linux]   ·   返回顶部