调整目录结构,参数化部分关键脚本变量,支持多种设备固件编译。
This commit is contained in:
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
build/
|
||||||
|
.vscode
|
||||||
51
Makefile
Normal file
51
Makefile
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# Copyright (C) 2020 Lu Qiuwen <luqiuwen@geedgenetworks.com>
|
||||||
|
# SPDX-License-Identifier: GPL-2.0
|
||||||
|
#
|
||||||
|
# Builds the TSG-OS (Tiango Security Gateway OS) install images
|
||||||
|
|
||||||
|
# Don't move this, it must be in FRONT of any included makefiles
|
||||||
|
|
||||||
|
|
||||||
|
THIS_MAKEFILE = $(realpath $(firstword $(MAKEFILE_LIST)))
|
||||||
|
SHELL = bash
|
||||||
|
|
||||||
|
V ?= 0
|
||||||
|
Q = @
|
||||||
|
ifneq ($V,0)
|
||||||
|
Q =
|
||||||
|
endif
|
||||||
|
|
||||||
|
PATCHDIR = $(realpath ./patches)
|
||||||
|
UPSTREAMDIR = $(realpath ./upstream)
|
||||||
|
CONFDIR = $(realpath ./conf)
|
||||||
|
TOOLSDIR = $(realpath ./tools)
|
||||||
|
INSTALLERDIR = $(realpath ./installer)
|
||||||
|
|
||||||
|
PROJECTDIR = $(abspath )
|
||||||
|
BUILDDIR_BASE = $(abspath ./build)
|
||||||
|
IMAGEDIR_BASE = $(BUILDDIR)/images
|
||||||
|
|
||||||
|
OS_RELEASE_VER = 20.04.1
|
||||||
|
|
||||||
|
ifndef PROFILE_LIST
|
||||||
|
PROFILE_LIST := 9000NPBP01R01
|
||||||
|
endif
|
||||||
|
|
||||||
|
export TOOLSDIR
|
||||||
|
export CONFDIR
|
||||||
|
export INSTALLERDIR
|
||||||
|
export PROJECTDIR
|
||||||
|
export BUILDDIR_BASE
|
||||||
|
export IMAGEDIR_BASE
|
||||||
|
export OS_RELEASE_VER
|
||||||
|
|
||||||
|
.PHONY: all clean $(PROFILE_LIST)
|
||||||
|
|
||||||
|
all: $(PROFILE_LIST)
|
||||||
|
$(Q) echo "=== Building $< $(OS_RELEASE_VER) ==="
|
||||||
|
$(Q) $(MAKE) -f make/Makefile.$< all
|
||||||
|
|
||||||
|
clean: $(PROFILE_LIST)
|
||||||
|
$(Q) echo "=== Finished making $@ for $(PLATFORM) ==="
|
||||||
47
conf/yum.conf
Normal file
47
conf/yum.conf
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
[main]
|
||||||
|
cachedir=/var/cache/yum/x86_64/7
|
||||||
|
keepcache=0
|
||||||
|
debuglevel=2
|
||||||
|
logfile=/var/log/yum.log
|
||||||
|
exactarch=1
|
||||||
|
obsoletes=1
|
||||||
|
gpgcheck=1
|
||||||
|
plugins=1
|
||||||
|
installonly_limit=5
|
||||||
|
distroverpkg=centos-release
|
||||||
|
reposdir=./
|
||||||
|
|
||||||
|
[base]
|
||||||
|
name=CentOS-7 - Base - mirrors.aliyun.com
|
||||||
|
failovermethod=priority
|
||||||
|
baseurl=http://mirrors.aliyun.com/centos/7/os/x86_64/
|
||||||
|
http://mirrors.aliyuncs.com/centos/7/os/x86_64/
|
||||||
|
http://mirrors.cloud.aliyuncs.com/centos/7/os/x86_64/
|
||||||
|
gpgcheck=1
|
||||||
|
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
|
||||||
|
|
||||||
|
[updates]
|
||||||
|
name=CentOS-7 - Updates - mirrors.aliyun.com
|
||||||
|
failovermethod=priority
|
||||||
|
baseurl=http://mirrors.aliyun.com/centos/7/updates/x86_64/
|
||||||
|
http://mirrors.aliyuncs.com/centos/7/updates/x86_64/
|
||||||
|
http://mirrors.cloud.aliyuncs.com/centos/7/updates/x86_64/
|
||||||
|
gpgcheck=1
|
||||||
|
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
|
||||||
|
|
||||||
|
[extras]
|
||||||
|
name=CentOS-7 - Extras - mirrors.aliyun.com
|
||||||
|
failovermethod=priority
|
||||||
|
baseurl=http://mirrors.aliyun.com/centos/7/extras/x86_64/
|
||||||
|
http://mirrors.aliyuncs.com/centos/7/extras/x86_64/
|
||||||
|
http://mirrors.cloud.aliyuncs.com/centos/7/extras/x86_64/
|
||||||
|
gpgcheck=1
|
||||||
|
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
|
||||||
|
|
||||||
|
[epel]
|
||||||
|
name=Extra Packages for Enterprise Linux 7 - x86_64
|
||||||
|
baseurl=https://mirrors.tuna.tsinghua.edu.cn/epel/7/x86_64
|
||||||
|
failovermethod=priority
|
||||||
|
enabled=1
|
||||||
|
gpgcheck=1
|
||||||
|
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
|
||||||
88
cook-bits.sh
88
cook-bits.sh
@@ -1,88 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
#
|
|
||||||
# Copyright (C) 2017 Rajendra Dendukuri <rajendra.dendukuri@broadcom.com>
|
|
||||||
#
|
|
||||||
# SPDX-License-Identifier: GPL-2.0
|
|
||||||
#
|
|
||||||
|
|
||||||
# Make an ONIE installer using CentOS 7 chroot environment
|
|
||||||
#
|
|
||||||
# inputs: cento7 chroot package
|
|
||||||
# output: ONIE compatible OS installer image
|
|
||||||
#
|
|
||||||
# Comments: This script expects that yumbootsstrap is installed on
|
|
||||||
# on the Linux host where it is executed.
|
|
||||||
|
|
||||||
#!/bin/sh
|
|
||||||
|
|
||||||
set -e
|
|
||||||
|
|
||||||
IN=./input
|
|
||||||
OUT=./output
|
|
||||||
rm -rf $OUT
|
|
||||||
mkdir -p $OUT
|
|
||||||
|
|
||||||
INSTALLER_TEMPLATE_DIR=./installer
|
|
||||||
WORKDIR=./work
|
|
||||||
EXTRACTDIR="$WORKDIR/extract"
|
|
||||||
INSTALLDIR="$WORKDIR/installer"
|
|
||||||
|
|
||||||
# Create a centos-7 chroot package if not done already
|
|
||||||
DISTR0_VER="21.04.1"
|
|
||||||
MACHINE_ID="9140NPCP01R01"
|
|
||||||
|
|
||||||
CHROOT_PKG="tsg-os-${DISTR0_VER}-${MACHINE_ID}-chroot.tar.bz2"
|
|
||||||
output_file="${OUT}/tsg-os-${DISTR0_VER}-${MACHINE_ID}-ONIE.bin"
|
|
||||||
|
|
||||||
echo -n "Creating $output_file: ."
|
|
||||||
|
|
||||||
# prepare workspace
|
|
||||||
[ -d $EXTRACTDIR ] && chmod +w -R $EXTRACTDIR
|
|
||||||
rm -rf $WORKDIR
|
|
||||||
mkdir -p $EXTRACTDIR
|
|
||||||
mkdir -p $INSTALLDIR
|
|
||||||
|
|
||||||
# Copy distro package
|
|
||||||
cp -f ${IN}/${CHROOT_PKG} $INSTALLDIR
|
|
||||||
|
|
||||||
# Create custom install.sh script
|
|
||||||
cp $INSTALLER_TEMPLATE_DIR/install.sh $INSTALLDIR/install.sh
|
|
||||||
chmod +x $INSTALLDIR/install.sh
|
|
||||||
sed -i -e "s/%%DISTR0_VER%%/$DISTR0_VER/" $INSTALLDIR/install.sh
|
|
||||||
sed -i -e "s/%%MACHINE_ID%%/$MACHINE_ID/" $INSTALLDIR/install.sh
|
|
||||||
sed -i -e "s/%%CHROOT_PKG%%/$CHROOT_PKG/" $INSTALLDIR/install.sh
|
|
||||||
|
|
||||||
# Create o/s setup script
|
|
||||||
cp $INSTALLER_TEMPLATE_DIR/distro-setup.sh $INSTALLDIR/distro-setup.sh
|
|
||||||
chmod +x $INSTALLDIR/distro-setup.sh
|
|
||||||
|
|
||||||
echo -n "."
|
|
||||||
|
|
||||||
# Repackage $INSTALLDIR into a self-extracting installer image
|
|
||||||
sharch="$WORKDIR/sharch.tar"
|
|
||||||
tar -C $WORKDIR -cf $sharch installer || {
|
|
||||||
echo "Error: Problems creating $sharch archive"
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
[ -f "$sharch" ] || {
|
|
||||||
echo "Error: $sharch not found"
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
echo -n "."
|
|
||||||
|
|
||||||
sha1=$(cat $sharch | sha1sum | awk '{print $1}')
|
|
||||||
echo -n "."
|
|
||||||
|
|
||||||
cp sharch_body.sh $output_file || {
|
|
||||||
echo "Error: Problems copying sharch_body.sh"
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
# Replace variables in the sharch template
|
|
||||||
sed -i -e "s/%%IMAGE_SHA1%%/$sha1/" $output_file
|
|
||||||
echo -n "."
|
|
||||||
cat $sharch >> $output_file
|
|
||||||
rm -rf $tmp_dir
|
|
||||||
echo " Done."
|
|
||||||
@@ -7,19 +7,19 @@ distro_part=3
|
|||||||
distro_dev="${blk_dev}${distro_part}"
|
distro_dev="${blk_dev}${distro_part}"
|
||||||
distro_mnt=/mnt/distro
|
distro_mnt=/mnt/distro
|
||||||
onie_root_dir=/mnt/onie-boot/onie
|
onie_root_dir=/mnt/onie-boot/onie
|
||||||
kernel_args="console=ttyS0,115200n8 intel_iommu=on iommu=pt pci=realloc,assign-busses isolcpus=1,14-27,42-55"
|
|
||||||
grub_serial_command=""
|
|
||||||
|
|
||||||
|
kernel_args="%%KERNAL_ARGS%%"
|
||||||
|
grub_serial_command="%%GRUB_SERIAL_COMMAND%%"
|
||||||
DISTR0_VER="%%DISTR0_VER%%"
|
DISTR0_VER="%%DISTR0_VER%%"
|
||||||
MACHINE_ID="%%MACHINE_ID%%"
|
MACHINE_ID="%%MACHINE_ID%%"
|
||||||
CHROOT_PKG="%%CHROOT_PKG%%"
|
CHROOT_PKG="%%CHROOT_PKG%%"
|
||||||
|
size_part_tsg_os_sysroot="%%SIZE_PART_SYSROOT%%"
|
||||||
|
size_part_tsg_os_data="%%SIZE_PART_DATA%%"
|
||||||
|
|
||||||
vol_label_tsg_os_sysroot="TSG-OS-SYSROOT"
|
vol_label_tsg_os_sysroot="TSG-OS-SYSROOT"
|
||||||
vol_label_tsg_os_data="TSG-OS-DATA"
|
vol_label_tsg_os_data="TSG-OS-DATA"
|
||||||
exp_part_tsg_os_sysroot=3
|
exp_part_tsg_os_sysroot=3
|
||||||
exp_part_tsg_os_data=4
|
exp_part_tsg_os_data=4
|
||||||
size_part_tsg_os_sysroot="6096M"
|
|
||||||
size_part_tsg_os_data="128M"
|
|
||||||
dev_part_tsg_os_sysroot="/dev/sda${exp_part_tsg_os_sysroot}"
|
dev_part_tsg_os_sysroot="/dev/sda${exp_part_tsg_os_sysroot}"
|
||||||
dev_part_tsg_os_data="/dev/sda${exp_part_tsg_os_data}"
|
dev_part_tsg_os_data="/dev/sda${exp_part_tsg_os_data}"
|
||||||
tsg_os_efi_prefix="TSG-OS"
|
tsg_os_efi_prefix="TSG-OS"
|
||||||
|
|||||||
59
make/Makefile.9000NPBP01R01
Normal file
59
make/Makefile.9000NPBP01R01
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
|
||||||
|
PROFILE_ID := 9000-NPB-P01R01
|
||||||
|
SUPPORTED_MACHINE_ID := 9000-NPB-P01R01
|
||||||
|
CHROOT_PKG := tsg-os-${OS_RELEASE_VER}-${PROFILE_ID}-chroot.tar.bz2
|
||||||
|
CHROOT_BIN := tsg-os-${OS_RELEASE_VER}-${PROFILE_ID}-ONIE.bin
|
||||||
|
|
||||||
|
TARGET_BUILD_DIR := $(BUILDDIR_BASE)/$(PROFILE_ID)
|
||||||
|
TARGET_INSTALLER_DIR := $(TARGET_BUILD_DIR)/installer
|
||||||
|
TARGET_SYSROOT_DIR := $(TARGET_BUILD_DIR)/sysroot
|
||||||
|
|
||||||
|
KERNEL_ARGS := console=ttyS0,115200n8 intel_iommu=on iommu=pt pci=realloc,assign-busses isolcpus=1,14-27,42-55
|
||||||
|
GRUB_SERIAL_COMMAND :=
|
||||||
|
SIZE_PART_SYSROOT := 7000M
|
||||||
|
SIZE_PART_DATA := 128M
|
||||||
|
|
||||||
|
.PHONY: all builddir installer sysroot-base sysroot-ansible sysroot-cleanup sysroot-archive sysroot-binary clean
|
||||||
|
|
||||||
|
all: sysroot-binary
|
||||||
|
|
||||||
|
builddir:
|
||||||
|
mkdir -p $(TARGET_BUILD_DIR)
|
||||||
|
|
||||||
|
installer: builddir
|
||||||
|
mkdir -p $(TARGET_INSTALLER_DIR)
|
||||||
|
cp $(INSTALLERDIR)/install.sh $(TARGET_INSTALLER_DIR)/install.sh
|
||||||
|
cp $(INSTALLERDIR)/distro-setup.sh $(TARGET_INSTALLER_DIR)/distro-setup.sh
|
||||||
|
chmod +x $(TARGET_INSTALLER_DIR)/install.sh
|
||||||
|
chmod +x $(TARGET_INSTALLER_DIR)/distro-setup.sh
|
||||||
|
|
||||||
|
sed -i -e "s/%%DISTR0_VER%%/$(OS_RELEASE_VER)/" $(TARGET_INSTALLER_DIR)/install.sh
|
||||||
|
sed -i -e "s/%%MACHINE_ID%%/$(SUPPORTED_MACHINE_ID)/" $(TARGET_INSTALLER_DIR)/install.sh
|
||||||
|
sed -i -e "s/%%CHROOT_PKG%%/$(CHROOT_PKG)/" $(TARGET_INSTALLER_DIR)/install.sh
|
||||||
|
sed -i -e "s/%%KERNAL_ARGS%%/$(KERNEL_ARGS)/" $(TARGET_INSTALLER_DIR)/install.sh
|
||||||
|
sed -i -e "s/%%GRUB_SERIAL_COMMAND%%/$(GRUB_SERIAL_COMMAND)/" $(TARGET_INSTALLER_DIR)/install.sh
|
||||||
|
sed -i -e "s/%%SIZE_PART_SYSROOT%%/$(SIZE_PART_SYSROOT)/" $(TARGET_INSTALLER_DIR)/install.sh
|
||||||
|
sed -i -e "s/%%SIZE_PART_DATA%%/$(SIZE_PART_DATA)/" $(TARGET_INSTALLER_DIR)/install.sh
|
||||||
|
|
||||||
|
sysroot-base: builddir
|
||||||
|
$(TOOLSDIR)/mk-base-image $(CONFDIR)/yum.conf $(TARGET_SYSROOT_DIR)
|
||||||
|
|
||||||
|
sysroot-ansible: sysroot-base
|
||||||
|
|
||||||
|
sysroot-cleanup:
|
||||||
|
rm -rf $(TARGET_SYSROOT_DIR)/tmp/*
|
||||||
|
rm -rf $(TARGET_SYSROOT_DIR)/dev/*
|
||||||
|
|
||||||
|
sysroot-archive: installer sysroot-ansible sysroot-cleanup
|
||||||
|
tar --exclude=*~ --exclude-backups --owner=root --group=root -c -C $(TARGET_SYSROOT_DIR) . | pbzip2 > $(TARGET_INSTALLER_DIR)/$(CHROOT_PKG)
|
||||||
|
|
||||||
|
INPUT_DIR=$1
|
||||||
|
WORK_DIR=$2
|
||||||
|
TARGET_BINARY=$3
|
||||||
|
|
||||||
|
sysroot-binary: sysroot-archive
|
||||||
|
mkdir -p $(TARGET_BUILD_DIR)/cook-bits
|
||||||
|
$(TOOLSDIR)/cook-bits $(TARGET_BUILD_DIR) $(TARGET_BUILD_DIR)/cook-bits $(TARGET_BUILD_DIR)/$(CHROOT_BIN)
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -rf $(TARGET_BUILD_DIR)
|
||||||
110
mkimage-yum.sh
110
mkimage-yum.sh
@@ -1,110 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
#
|
|
||||||
# Create a base CentOS Docker image.
|
|
||||||
#
|
|
||||||
# This script is useful on systems with yum installed (e.g., building
|
|
||||||
# a CentOS image on CentOS). See contrib/mkimage-rinse.sh for a way
|
|
||||||
# to build CentOS images on other systems.
|
|
||||||
|
|
||||||
usage() {
|
|
||||||
cat <<EOOPTS
|
|
||||||
$(basename $0) [OPTIONS] <name>
|
|
||||||
OPTIONS:
|
|
||||||
-y <yumconf> The path to the yum config to install packages from. The
|
|
||||||
default is /etc/yum.conf.
|
|
||||||
EOOPTS
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
# option defaults
|
|
||||||
yum_config=/etc/yum.conf
|
|
||||||
while getopts ":y:h" opt; do
|
|
||||||
case $opt in
|
|
||||||
y)
|
|
||||||
yum_config=$OPTARG
|
|
||||||
;;
|
|
||||||
h)
|
|
||||||
usage
|
|
||||||
;;
|
|
||||||
\?)
|
|
||||||
echo "Invalid option: -$OPTARG"
|
|
||||||
usage
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
shift $((OPTIND - 1))
|
|
||||||
name=$1
|
|
||||||
|
|
||||||
if [[ -z $name ]]; then
|
|
||||||
usage
|
|
||||||
fi
|
|
||||||
|
|
||||||
#--------------------
|
|
||||||
|
|
||||||
#target=$(mktemp -d --tmpdir $(basename $0).XXXXXX)
|
|
||||||
target=$PWD/centos_mkroot
|
|
||||||
|
|
||||||
set -x
|
|
||||||
|
|
||||||
for dev in console null zero urandom; do
|
|
||||||
/sbin/MAKEDEV -d "$target"/dev -x $dev
|
|
||||||
done
|
|
||||||
|
|
||||||
package_to_install="@base @core @debugging @directory-client @guest-agents
|
|
||||||
@hardware-monitoring @network-file-system-client @performance @remote-system-management
|
|
||||||
grub2 kernel kernel-devel epel-release ansible"
|
|
||||||
|
|
||||||
setopt="group_package_types=mandatory,default,optional"
|
|
||||||
|
|
||||||
enabled_repos="base,extras,updates"
|
|
||||||
|
|
||||||
yum -c "$yum_config" --installroot="$target" -y --setopt=$setopt install $package_to_install
|
|
||||||
|
|
||||||
cat > "$target"/etc/sysconfig/network <<EOF
|
|
||||||
NETWORKING=yes
|
|
||||||
HOSTNAME=localhost.localdomain
|
|
||||||
EOF
|
|
||||||
|
|
||||||
# effectively: febootstrap-minimize --keep-zoneinfo --keep-rpmdb
|
|
||||||
# --keep-services "$target". Stolen from mkimage-rinse.sh
|
|
||||||
# locales
|
|
||||||
# rm -rf "$target"/usr/{{lib,share}/locale,{lib,lib64}/gconv,bin/localedef,sbin/build-locale-archive}
|
|
||||||
# docs
|
|
||||||
# rm -rf "$target"/usr/share/{man,doc,info,gnome/help}
|
|
||||||
# cracklib
|
|
||||||
# rm -rf "$target"/usr/share/cracklib
|
|
||||||
# i18n
|
|
||||||
# rm -rf "$target"/usr/share/i18n
|
|
||||||
# sln
|
|
||||||
# rm -rf "$target"/sbin/sln
|
|
||||||
|
|
||||||
# ldconfig
|
|
||||||
rm -rf "$target"/etc/ld.so.cache
|
|
||||||
rm -rf "$target"/var/cache/ldconfig/*
|
|
||||||
|
|
||||||
cd $target/boot
|
|
||||||
ln -sf $(ls -1 vmlinuz-* | tail -1) vmlinuz
|
|
||||||
ln -sf $(ls -1 initramfs-* | tail -1) initrd.img
|
|
||||||
cd -
|
|
||||||
|
|
||||||
version=
|
|
||||||
if [ -r "$target"/etc/redhat-release ]; then
|
|
||||||
version="$(sed 's/^[^0-9\]*\([0-9.]\+\).*$/\1/' /etc/redhat-release)"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -z "$version" ]; then
|
|
||||||
echo >&2 "warning: cannot autodetect OS version, using '$name' as tag"
|
|
||||||
version=$name
|
|
||||||
fi
|
|
||||||
|
|
||||||
#tar --numeric-owner -c -C "$target" . | docker import - $name:$version
|
|
||||||
#docker run -i -t $name:$version echo success
|
|
||||||
cp -a /dev/urandom centos_mkroot/dev/
|
|
||||||
cp -a /dev/random centos_mkroot/dev/
|
|
||||||
#tar zcvf centos_mkroot.tar.gz centos_mkroot/
|
|
||||||
ansible-playbook -i tsg-9140-scripts/install_config/tsg_9140_host tsg-9140-scripts/tsg_9140_deploy.yml
|
|
||||||
yum -c "$yum_config" --installroot="$target" -y --setopt=$setopt clean all
|
|
||||||
rm -rf centos_mkroot/tmp/*
|
|
||||||
tar --numeric-owner -c -C centos_mkroot/ . | pbzip2 -p9 > input/centos-7-chroot.tar.bz2
|
|
||||||
|
|
||||||
#rm -rf "$target"
|
|
||||||
54
tools/cook-bits
Executable file
54
tools/cook-bits
Executable file
@@ -0,0 +1,54 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
#
|
||||||
|
# Copyright (C) 2017 Rajendra Dendukuri <rajendra.dendukuri@broadcom.com>
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: GPL-2.0
|
||||||
|
#
|
||||||
|
|
||||||
|
# Make an ONIE installer using CentOS 7 chroot environment
|
||||||
|
#
|
||||||
|
# inputs: cento7 chroot package
|
||||||
|
# output: ONIE compatible OS installer image
|
||||||
|
#
|
||||||
|
# Comments: This script expects that yumbootsstrap is installed on
|
||||||
|
# on the Linux host where it is executed.
|
||||||
|
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
|
||||||
|
INPUT_DIR=$1
|
||||||
|
WORK_DIR=$2
|
||||||
|
TARGET_BINARY=$3
|
||||||
|
|
||||||
|
echo -n "Creating $TARGET_BINARY: ."
|
||||||
|
|
||||||
|
# Repackage $INSTALLDIR into a self-extracting installer image
|
||||||
|
sharch="$WORK_DIR/sharch.tar"
|
||||||
|
tar --exclude=*~ --exclude-backups --owner=root --group=root -C $INPUT_DIR -cf $sharch installer || {
|
||||||
|
echo "Error: Problems creating $sharch archive"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
[ -f "$sharch" ] || {
|
||||||
|
echo "Error: $sharch not found"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
echo -n "."
|
||||||
|
|
||||||
|
sha1=$(cat $sharch | sha1sum | awk '{print $1}')
|
||||||
|
echo -n "."
|
||||||
|
|
||||||
|
cp $SCRIPT_DIR/sharch_body.sh $TARGET_BINARY || {
|
||||||
|
echo "Error: Problems copying sharch_body.sh"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# Replace variables in the sharch template
|
||||||
|
sed -i -e "s/%%IMAGE_SHA1%%/$sha1/" $TARGET_BINARY
|
||||||
|
echo -n "."
|
||||||
|
cat $sharch >> $TARGET_BINARY
|
||||||
|
echo " Done."
|
||||||
61
tools/mk-base-image
Executable file
61
tools/mk-base-image
Executable file
@@ -0,0 +1,61 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
# Create a base CentOS Docker image.
|
||||||
|
#
|
||||||
|
# This script is useful on systems with yum installed (e.g., building
|
||||||
|
# a CentOS image on CentOS). See contrib/mkimage-rinse.sh for a way
|
||||||
|
# to build CentOS images on other systems.
|
||||||
|
|
||||||
|
yum_config=$1
|
||||||
|
target=$2
|
||||||
|
|
||||||
|
set -ex
|
||||||
|
|
||||||
|
package_to_install="@base @core @debugging @directory-client @guest-agents
|
||||||
|
@hardware-monitoring @network-file-system-client @performance @remote-system-management
|
||||||
|
grub2 kernel kernel-devel epel-release ansible"
|
||||||
|
|
||||||
|
setopt="group_package_types=mandatory,default,optional"
|
||||||
|
yum -c "$yum_config" --installroot="$target" -y --setopt=$setopt install $package_to_install
|
||||||
|
|
||||||
|
cat > "$target"/etc/sysconfig/network <<EOF
|
||||||
|
NETWORKING=yes
|
||||||
|
HOSTNAME=localhost.localdomain
|
||||||
|
EOF
|
||||||
|
|
||||||
|
# effectively: febootstrap-minimize --keep-zoneinfo --keep-rpmdb
|
||||||
|
# --keep-services "$target". Stolen from mkimage-rinse.sh
|
||||||
|
# locales
|
||||||
|
# rm -rf "$target"/usr/{{lib,share}/locale,{lib,lib64}/gconv,bin/localedef,sbin/build-locale-archive}
|
||||||
|
# docs
|
||||||
|
# rm -rf "$target"/usr/share/{man,doc,info,gnome/help}
|
||||||
|
# cracklib
|
||||||
|
# rm -rf "$target"/usr/share/cracklib
|
||||||
|
# i18n
|
||||||
|
# rm -rf "$target"/usr/share/i18n
|
||||||
|
# sln
|
||||||
|
# rm -rf "$target"/sbin/sln
|
||||||
|
|
||||||
|
# ldconfig
|
||||||
|
rm -rf "$target"/etc/ld.so.cache
|
||||||
|
rm -rf "$target"/var/cache/ldconfig/*
|
||||||
|
|
||||||
|
cd $target/boot
|
||||||
|
ln -sf $(ls -1 vmlinuz-* | tail -1) vmlinuz
|
||||||
|
ln -sf $(ls -1 initramfs-* | tail -1) initrd.img
|
||||||
|
cd -
|
||||||
|
|
||||||
|
cp -a /dev/console $target/dev/
|
||||||
|
cp -a /dev/null $target/dev/
|
||||||
|
cp -a /dev/zero $target/dev/
|
||||||
|
cp -a /dev/urandom $target/dev/
|
||||||
|
cp -a /dev/random $target/dev/
|
||||||
|
|
||||||
|
# ansible-playbook -i tsg-9140-scripts/install_config/tsg_9140_host tsg-9140-scripts/tsg_9140_deploy.yml
|
||||||
|
yum -c "$yum_config" --installroot="$target" -y --setopt=$setopt clean all
|
||||||
|
|
||||||
|
rm -rf $target/tmp/*
|
||||||
|
|
||||||
|
# tar --numeric-owner -c -C centos_mkroot/ . | pbzip2 -p9 > input/centos-7-chroot.tar.bz2
|
||||||
|
|
||||||
|
#rm -rf "$target"
|
||||||
Reference in New Issue
Block a user