天天看点

自定义centos

1 修改 rootfs.img

1.安装工具
[root@localhost ~]# yum install -y squashfs-tools
2.用unsuqashfs命令直接解压缩squashfs.img
[root@localhost ~]# unsquashfs squashfs.img
3.挂载文件系统
[root@localhost ~]# cd squashfs-root/LiveOS/
[root@localhost LiveOS]# mount rootfs.img /mnt/rootfs/
[root@localhost LiveOS]# ls /mnt/rootfs/
bin  boot  dev  etc  firmware  lib  lib64  lost+found  mnt  modules  proc  root  run  sbin  sys  tmp  usr  var
4.根据需要可以修改/mnt/rootfs目录下文件
5.修改后重新打包
[root@localhost ~]# mksquashfs squashfs-root/ squashfs.img -comp xz -Xbcj x86 -e boot

      
2 创建rpm包

rpmdev-setuptree
mkdir -p BUILDROOT/hequan-1.0-1.1.x86_64

[root@test SPECS]# cat temp.spec
Name: hequan
Version: 1.0
Release: 1.1
Summary: This is a hedata package


Group: he
License: Special Proprietary
BuildArch: x86_64
# BuildArch: noarch


%description
%prep
%build
%pre
%post
%preun
%postun
%files
/usr/local/hequan/
%changelog


mkdir -p /root/rpmbuild/BUILDROOT/hequan-1.0-1.1.x86_64

cp -r --parents /usr/local/hequan/*  BUILDROOT/hequan-1.0-1.1.x86_64/
cd SPECS/
rpmbuild -bb temp.spec

      
3 修改createrepo

yum -y install createrepo mkisofs isomd5sum rsync

mkdir /ISO

/usr/bin/rsync -a  /media/ /ISO/

上传包 到 Packages

cp /media/repodata/*-comps.xml  /ISO/repodata/comps.xml


vim comps.xml

增加
<group>
<id>he</id>
<name>he</name>
<default>true</default>
<uservisible>true</uservisible>
<packagelist>
  <packagereq type="default">hequan</packagereq>
</packagelist>
</group>

<grouplist>
      <groupid>core</groupid>
      <groupid>core</groupid>
      <groupid>he</groupid>
</grouplist>


cd iso/
createrepo -g repodata/comps.xml ./      

继续阅读