120 lines
2.6 KiB
Bash
120 lines
2.6 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-20140617/
|
|
enabled=1
|
|
gpgcheck=0
|
|
__YUMCONF__
|
|
|
|
# Install the Core group
|
|
yum \
|
|
--installroot $installroot \
|
|
-c $tmpyumconf \
|
|
-y groupinstall \
|
|
Core
|
|
|
|
# Install the necessary rpms
|
|
yum \
|
|
--installroot $installroot \
|
|
-c $tmpyumconf \
|
|
-y install \
|
|
openssh-clients \
|
|
openssh-server \
|
|
yum \
|
|
yum-utils \
|
|
man \
|
|
wget \
|
|
sudo \
|
|
tar \
|
|
passwd
|
|
|
|
# Remove firmware files if installed
|
|
yum \
|
|
--installroot $installroot \
|
|
-c $tmpyumconf \
|
|
-y remove \
|
|
aic94xx-firmware \
|
|
alsa-firmware \
|
|
alsa-tools-firmware \
|
|
efibootmgr \
|
|
ethtool \
|
|
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 \
|
|
xorg-x11-drv-ati-firmware \
|
|
zd1211-firmware
|
|
|
|
# Clean the yum configuration
|
|
yum --installroot $installroot -c $tmpyumconf clean all
|
|
|
|
# Remove unnessary files from the build, that are not required on a VZ container
|
|
yum \
|
|
--installroot $installroot \
|
|
-c $tmpyumconf \
|
|
-y remove \
|
|
grub2 \
|
|
grub2-tools \
|
|
grubby \
|
|
centos-logos \
|
|
plymouth \
|
|
plymouth-scripts \
|
|
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
|
|
|
|
# Copy the yum config to the system
|
|
cp $tmpyumconf $installroot/etc/yum.repos.d/centos.repo
|
|
|
|
# Now compress the image
|
|
cd $installroot; tar -cpzf /root/centos-7-x86_64-viayum.tar.gz . ; cd
|
|
ls -lh /root/centos-7-x86_64-viayum.tar.gz
|