103 lines
2.4 KiB
Bash
103 lines
2.4 KiB
Bash
# To get a package list without version numbers from a target system
|
|
# rpm -qa --qf "%{n} " > packages.txt
|
|
# Put contents of packages.txt after "-y install \" line below
|
|
|
|
installroot="/ostemplate"
|
|
mount="$(mktemp -d --tmpdir)"
|
|
tmpyumconf=$mount/yum.conf
|
|
|
|
cat > $tmpyumconf << __YUMCONF__
|
|
[centos7]
|
|
name=centos 7 x86_64
|
|
baseurl=http://buildlogs.centos.org/centos/7/os/x86_64-20140614/
|
|
enabled=0
|
|
gpgcheck=0
|
|
__YUMCONF__
|
|
|
|
yum \
|
|
--installroot $installroot \
|
|
-c $tmpyumconf \
|
|
-y install \
|
|
openssh-clients \
|
|
openssh-server \
|
|
yum \
|
|
yum-utils \
|
|
man \
|
|
wget \
|
|
sudo \
|
|
tar \
|
|
passwd
|
|
|
|
# Remove firmware files if installed
|
|
chroot $installroot rpm -e
|
|
aic94xx-firmware \
|
|
alsa-firmware \
|
|
alsa-tools-firmware \
|
|
cronie \
|
|
efibootmgr \
|
|
ethtool \
|
|
iproute \
|
|
iptables \
|
|
iputils \
|
|
ivtv-firmware \
|
|
iwl100-firmware \
|
|
iwl105-firmware \
|
|
iwl135-firmware \
|
|
iwl1000-firmware \
|
|
iwl2000-firmware \
|
|
iwl2030-firmware \
|
|
iwl3160-firmware \
|
|
iwl3945-firmware \
|
|
iwl4965-firmware \
|
|
iwl5000-firmware \
|
|
iwl5150-firmware \
|
|
iwl6000-firmware \
|
|
iwl6000g2a-firmware \
|
|
iwl6000g2b-firmware \
|
|
iwl6050-firmware \
|
|
iwl7260-firmware \
|
|
kbd \
|
|
libertas-sd8686-firmware \
|
|
libertas-sd8787-firmware \
|
|
libertas-usb8388-firmware \
|
|
libertas-usb8388-olpc-firmware \
|
|
linux-firmware \
|
|
postfix \
|
|
policycoreutils \
|
|
selinux-policy \
|
|
selinux-policy-targeted \
|
|
sudo \
|
|
upstart \
|
|
vim-minimal \
|
|
xorg-x11-drv-ati-firmware \
|
|
zd1211-firmware
|
|
|
|
# Clean te yum configuration
|
|
yum --installroot=$installroot -c $tmpyumconf clean all
|
|
|
|
# Remove unnessary files from the build
|
|
chroot $installroot rpm -e grub2 grub2-tools grubby centos-logos plymouth plymouth-scripts
|
|
chroot $installroot rpm -e initscripts kernel
|
|
|
|
# Remove /boot, as that is not required
|
|
chroot $installroot rm -rf /boot
|
|
|
|
# Create fstab file, which is required for VZ installtions
|
|
cat > $installroot/etc/fstab << __FSTAB__
|
|
none /dev/pts devpts rw,gid=5,mode=620 0 0
|
|
none /dev/shm tmpfs defaults 0 0
|
|
__FSTAB__
|
|
|
|
# GMT to be default, but change for requirement
|
|
chroot $installroot ln -sf /usr/share/zoneinfo/GMT /etc/localtime
|
|
|
|
# Misc post stuff for VZ
|
|
ln -s /proc/mounts $installroot/etc/mtab
|
|
rm -f $installroot/dev/null
|
|
mknod -m 600 $installroot/dev/console c 5 1
|
|
|
|
# Now compress the image
|
|
cd $installroot; tar -cvzf /root/centos-7-x86_64-viayum.tar.gz . ; cd
|
|
ls -lh /root/centos-7-x86_64-viayum.tar.gz
|
|
echo "Done building OS Template. Now test it."
|