[20170104]rpm相关细节.txt
--redhat linux相关的包基本都是rpm安装包,一般生产系统的服务器我都是选择安装rpm的安装包,很少选择tar包来安装.
--前天别人问的问题,问一下转换的问题,我仅仅知道有1个包alien可以实现rpm包的转换deb,tar等格式.
--遇到一些问题,还是花一点点时间学习.
1.rpm包里面自带一个rpm2cpio可以转换cpio格式:
--好多东西不用有点忘记了.
# mount -o loop /data/centos/CentOS-6.2-x86_64-bin-DVD1.iso /mnt/1005/
# cd /mnt/1005/Packages
# cp crontabs-1.10-33.el6.noarch.rpm /data
# cd /data
# rpm2cpio crontabs-1.10-33.el6.noarch.rpm > crontab.cpio
# file crontabs.cpio
crontabs.cpio: data
--//奇怪,文件类型是data,不可能出现file不能识别的情况.我拷贝到其他服务器测试.(这台机器太老了,rh4.3的).
# file crontabs.cpio
crontabs.cpio: xz compressed data
--很明显使用xz压缩格式.也就是一些安装包在外包一层xz压缩模式.
# mv crontabs.cpio crontabs.cpio.xz
# unxz crontabs.cpio.xz
# file crontabs.cpio
crontabs.cpio: ASCII cpio archive (SVR4 with no CRC)
# cpio -itmv < crontabs.cpio
drwxr-xr-x 2 root root 0 Sep 27 2011 ./etc/cron.daily
drwxr-xr-x 2 root root 0 Sep 27 2011 ./etc/cron.hourly
drwxr-xr-x 2 root root 0 Sep 27 2011 ./etc/cron.monthly
drwxr-xr-x 2 root root 0 Sep 27 2011 ./etc/cron.weekly
-rw-r--r-- 1 root root 457 Sep 27 2011 ./etc/crontab
-rwxr-xr-x 1 root root 1411 Sep 27 2011 ./usr/bin/run-parts
-rw-r--r-- 1 root root 627 Sep 27 2011 ./usr/share/man/man4/crontabs.4.gz
7 blocks
# cpio -idtmv < crontabs.cpio
drwxr-xr-x 2 root root 0 Sep 27 2011 ./etc/cron.daily
drwxr-xr-x 2 root root 0 Sep 27 2011 ./etc/cron.hourly
drwxr-xr-x 2 root root 0 Sep 27 2011 ./etc/cron.monthly
drwxr-xr-x 2 root root 0 Sep 27 2011 ./etc/cron.weekly
-rw-r--r-- 1 root root 457 Sep 27 2011 ./etc/crontab
-rwxr-xr-x 1 root root 1411 Sep 27 2011 ./usr/bin/run-parts
-rw-r--r-- 1 root root 627 Sep 27 2011 ./usr/share/man/man4/crontabs.4.gz
7 blocks
--//-t参数是显示.我不想解压出来.
--//也就是要使用rpm2cpio看包里面内容:
# rpm2cpio crontabs-1.10-33.el6.noarch.rpm | xz -d | cpio -itdvm
drwxr-xr-x 2 root root 0 Sep 27 2011 ./etc/cron.daily
drwxr-xr-x 2 root root 0 Sep 27 2011 ./etc/cron.hourly
drwxr-xr-x 2 root root 0 Sep 27 2011 ./etc/cron.monthly
drwxr-xr-x 2 root root 0 Sep 27 2011 ./etc/cron.weekly
-rw-r--r-- 1 root root 457 Sep 27 2011 ./etc/crontab
-rwxr-xr-x 1 root root 1411 Sep 27 2011 ./usr/bin/run-parts
-rw-r--r-- 1 root root 627 Sep 27 2011 ./usr/share/man/man4/crontabs.4.gz
7 blocks
--当然rpm也可以看,执行:rpm -qilp crontabs-1.10-33.el6.noarch.rpm
# rpm -qilp crontabs-1.10-33.el6.noarch.rpm
warning: crontabs-1.10-33.el6.noarch.rpm: Header V3 RSA/SHA1 signature: NOKEY, key ID c105b9de
Name : crontabs Relocations: (not relocatable)
Version : 1.10 Vendor: CentOS
Release : 33.el6 Build Date: Tue 27 Sep 2011 09:33:08 AM CST
Install Date: (not installed) Build Host: c6b6.bsys.dev.centos.org
Group : System Environment/Base Source RPM: crontabs-1.10-33.el6.src.rpm
Size : 2495 License: Public Domain and GPLv2
Signature : RSA/SHA1, Wed 28 Sep 2011 08:33:55 AM CST, Key ID 0946fca2c105b9de
Packager : CentOS BuildSystem <http://bugs.centos.org>
Summary : Root crontab files used to schedule the execution of programs.
Description :
The crontabs package contains root crontab files. Crontab is the
program used to install, uninstall or list the tables used to drive the
cron daemon. The cron daemon checks the crontab files to see when
particular commands are scheduled to be executed. If commands are
scheduled, it executes them.
Crontabs handles a basic system function, so it should be installed on
your system.
/etc/cron.daily
/etc/cron.hourly
/etc/cron.monthly
/etc/cron.weekly
/etc/crontab
/usr/bin/run-parts
/usr/share/man/man4/crontabs.4.gz
2.一些包在安装前必须检查他会执行调用一些脚本命令,卸载也一样,例子:
# rpm --scripts -qip initscripts-9.03.27-1.el6.centos.x86_64.rpm
warning: initscripts-9.03.27-1.el6.centos.x86_64.rpm: V3 RSA/MD5 signature: NOKEY, key ID c105b9de
preinstall scriptlet (using /bin/sh):
/usr/sbin/groupadd -g 22 -r -f utmp
postinstall scriptlet (using /bin/sh):
touch /var/log/wtmp /var/run/utmp /var/log/btmp
chown root:utmp /var/log/wtmp /var/run/utmp /var/log/btmp
chmod 664 /var/log/wtmp /var/run/utmp
chmod 600 /var/log/btmp
/sbin/chkconfig --add netfs
/sbin/chkconfig --add network
/sbin/chkconfig --add netconsole
preuninstall scriptlet (using /bin/sh):
if [ $1 = 0 ]; then
/sbin/chkconfig --del netfs
/sbin/chkconfig --del network
/sbin/chkconfig --del netconsole
fi
Name : initscripts Relocations: (not relocatable)
Version : 9.03.27 Vendor: CentOS
Release : 1.el6.centos Build Date: Fri 09 Dec 2011 02:39:30 AM CST
Install Date: (not installed) Build Host: c6b18n2.bsys.dev.centos.org
Group : System Environment/Base Source RPM: initscripts-9.03.27-1.el6.centos.src.rpm
Size : 5712572 License: GPLv2 and GPLv2+
Signature : RSA/SHA1, Fri 09 Dec 2011 04:09:15 AM CST, Key ID 0946fca2c105b9de
Packager : CentOS BuildSystem <http://bugs.centos.org>
URL : http://fedorahosted.org/releases/i/n/initscripts/
Summary : The inittab file and the /etc/init.d scripts.
Description :
The initscripts package contains the basic system scripts used to boot
your Red Hat system, change runlevels, and shut the system down
cleanly. Initscripts also contains the scripts that activate and
deactivate most network interfaces.
--在安装前最好检查看看执行的内容.
3.我以前使用过alien,感觉这个更加好用.