1. 下载对应的依赖包

# yumdownloader --downloadonly --downloaddir=. xxx
# 提取包内容
# rpm2cpio *.rpm | cpio -div

2. install.sh

#!/bin/bash -
##########################################################
# wcg-deps-install.sh
# version:1.0
# update:20181120
##########################################################
DIR="/home/wcg/WCG-deps"

function wcg_deps() {
    for dir in curl fcgi gsoap lksctp lrzsz vconfig tftp redis spawn-fcgi keepalived openssh nginx net-tools libevent
    do
        cd $DIR/$dir && rpm -Uvh *.rpm --force --nodeps &
    done
}

function segw_deps() {
    for dir in segw
    do
        cd $DIR/$dir && rpm -Uvh *.rpm --force --nodeps &
    done
}

function kernel_deps() {
    for dir in kernel
	do
        cd $DIR/$dir && rpm -Uvh *.rpm --force --nodeps &
    done
}

#if [[ $# -lt 1 ]];then
    #echo "USAGE:`basename $0` [-a] [-b value] [-c]"
	#$(pwd)/$(basename $0) -h
	#$(dirname $0)/$(basename $0) -h
    #$0 -h
#fi

function help_info() {
    echo "usage:"
    echo "  -h  --help                  list help information"
    echo "  -v  --version               list the released version"
    echo "  -k  --kernel                install kernel depends"
    echo "  -w  --wcg                   install wcg depends"
    echo "  -s  --segw                  install segw depends"
}

ARGS=`getopt -o hvkws --long help,version,kernel,wcg,segw -- "$@"`
if [ $? != 0  ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
eval set -- "$ARGS"
while true
do
    case "$1" in
        -h|--help)
        help_info
        shift
        break;;
        -v|--version)
        echo "version: 1.0"
        shift
        break;;
        -k|--kernel)
        kernel_deps
        shift;;
        -w|--wcg)
        wcg_deps
        shift;;
        -s|--segw)
        segw_deps
        shift;;
        --)
        help_info
        shift
        break;;
        *)
        echo "unknown:{$1}"
        exit 1;;
    esac
done


3. 使用fpm打包

# yum install epel-release
# yum install gcc
# yum install ruby rubygems ruby-devel
# gem sources --list
# gem sources --add http://mirrors.aliyun.com/rubygems/
# gem sources --remove https://rubygems.org/
# gem install fpm

[root@localhost wcg-deps]# tree
.
├── baicells-wcg-deps-1.0.0-1.x86_64.rpm
├── build.sh
└── source
    └── WCG-deps
        ├── curl
        │   ├── curl-7.29.0-46.el7.x86_64.rpm
        │   └── libcurl-7.29.0-46.el7.x86_64.rpm
        ├── fcgi
        │   └── fcgi-2.4.0-25.el7.x86_64.rpm
        ├── gsoap
        │   └── gsoap-2.8.16-10.el7.x86_64.rpm
        ├── keepalived
        │   ├── ipset-libs-6.29-1.el7.x86_64.rpm
        │   ├── keepalived-1.3.5-6.el7.x86_64.rpm
        │   ├── libnl-1.1.4-3.el7.x86_64.rpm
        │   ├── libnl3-3.2.28-4.el7.x86_64.rpm
        │   ├── lm_sensors-libs-3.4.0-4.20160601gitf9185e5.el7.x86_64.rpm
        │   ├── net-snmp-agent-libs-5.7.2-32.el7.x86_64.rpm
        │   └── net-snmp-libs-5.7.2-32.el7.x86_64.rpm
        ├── kernel
        │   ├── kmod-20-21.el7.x86_64.rpm
        │   ├── kmod-libs-20-21.el7.x86_64.rpm
        │   ├── linux-firmware-20180220-62.git6d51311.el7.noarch.rpm
        │   └── xfsprogs-4.5.0-15.el7.x86_64.rpm
        ├── libevent
        │   └── libevent-2.0.21-4.el7.x86_64.rpm
        ├── lksctp
        │   └── lksctp-tools-1.0.17-2.el7.x86_64.rpm
        ├── lrzsz
        │   └── lrzsz-0.12.20-36.el7.x86_64.rpm
        ├── net-tools
        │   └── net-tools-2.0-0.25.20131004git.el7.x86_64.rpm
        ├── nginx
        │   ├── fontconfig-2.10.95-11.el7.x86_64.rpm
        │   ├── fontpackages-filesystem-1.44-8.el7.noarch.rpm
        │   ├── gd-2.0.35-26.el7.x86_64.rpm
        │   ├── GeoIP-1.5.0-11.el7.x86_64.rpm
        │   ├── gperftools-libs-2.6.1-1.el7.x86_64.rpm
        │   ├── libjpeg-turbo-1.2.90-5.el7.x86_64.rpm
        │   ├── libpng-1.5.13-7.el7_2.x86_64.rpm
        │   ├── libX11-1.6.5-1.el7.x86_64.rpm
        │   ├── libX11-common-1.6.5-1.el7.noarch.rpm
        │   ├── libXau-1.0.8-2.1.el7.x86_64.rpm
        │   ├── libxcb-1.12-1.el7.x86_64.rpm
        │   ├── libXpm-3.5.12-1.el7.x86_64.rpm
        │   ├── libxslt-1.1.28-5.el7.x86_64.rpm
        │   ├── lyx-fonts-2.2.3-1.el7.noarch.rpm
        │   ├── nginx-1.12.2-2.el7.x86_64.rpm
        │   ├── nginx-all-modules-1.12.2-2.el7.noarch.rpm
        │   ├── nginx-filesystem-1.12.2-2.el7.noarch.rpm
        │   ├── nginx-mod-http-geoip-1.12.2-2.el7.x86_64.rpm
        │   ├── nginx-mod-http-image-filter-1.12.2-2.el7.x86_64.rpm
        │   ├── nginx-mod-http-perl-1.12.2-2.el7.x86_64.rpm
        │   ├── nginx-mod-http-xslt-filter-1.12.2-2.el7.x86_64.rpm
        │   ├── nginx-mod-mail-1.12.2-2.el7.x86_64.rpm
        │   ├── nginx-mod-stream-1.12.2-2.el7.x86_64.rpm
        │   ├── openssl-1.0.2k-8.el7.x86_64.rpm
        │   ├── openssl-libs-1.0.2k-8.el7.x86_64.rpm
        │   ├── perl-5.16.3-292.el7.x86_64.rpm
        │   ├── perl-Carp-1.26-244.el7.noarch.rpm
        │   ├── perl-constant-1.27-2.el7.noarch.rpm
        │   ├── perl-Encode-2.51-7.el7.x86_64.rpm
        │   ├── perl-Exporter-5.68-3.el7.noarch.rpm
        │   ├── perl-File-Path-2.09-2.el7.noarch.rpm
        │   ├── perl-File-Temp-0.23.01-3.el7.noarch.rpm
        │   ├── perl-Filter-1.49-3.el7.x86_64.rpm
        │   ├── perl-Getopt-Long-2.40-3.el7.noarch.rpm
        │   ├── perl-HTTP-Tiny-0.033-3.el7.noarch.rpm
        │   ├── perl-libs-5.16.3-292.el7.x86_64.rpm
        │   ├── perl-macros-5.16.3-292.el7.x86_64.rpm
        │   ├── perl-parent-0.225-244.el7.noarch.rpm
        │   ├── perl-PathTools-3.40-5.el7.x86_64.rpm
        │   ├── perl-Pod-Escapes-1.04-292.el7.noarch.rpm
        │   ├── perl-podlators-2.5.1-3.el7.noarch.rpm
        │   ├── perl-Pod-Perldoc-3.20-4.el7.noarch.rpm
        │   ├── perl-Pod-Simple-3.28-4.el7.noarch.rpm
        │   ├── perl-Pod-Usage-1.63-3.el7.noarch.rpm
        │   ├── perl-Scalar-List-Utils-1.27-248.el7.x86_64.rpm
        │   ├── perl-Socket-2.010-4.el7.x86_64.rpm
        │   ├── perl-Storable-2.45-3.el7.x86_64.rpm
        │   ├── perl-Text-ParseWords-3.29-4.el7.noarch.rpm
        │   ├── perl-threads-1.87-4.el7.x86_64.rpm
        │   ├── perl-threads-shared-1.43-6.el7.x86_64.rpm
        │   ├── perl-Time-HiRes-1.9725-3.el7.x86_64.rpm
        │   ├── perl-Time-Local-1.2300-2.el7.noarch.rpm
        │   └── stix-fonts-1.1.0-5.el7.noarch.rpm
        ├── openssh
        │   ├── openssh-7.4p1-16.el7.x86_64.rpm
        │   ├── openssh-clients-7.4p1-16.el7.x86_64.rpm
        │   └── openssh-server-7.4p1-16.el7.x86_64.rpm
        ├── redis
        │   ├── hiredis-0.12.1-1.el7.x86_64.rpm
        │   ├── jemalloc-3.6.0-1.el7.x86_64.rpm
        │   └── redis-3.2.10-2.el7.x86_64.rpm
        ├── segw
        │   ├── gmp-6.0.0-15.el7.x86_64.rpm
        │   └── gmp-devel-6.0.0-15.el7.x86_64.rpm
        ├── spawn-fcgi
        │   └── spawn-fcgi-1.6.3-5.el7.x86_64.rpm
        ├── tftp
        │   ├── tftp-5.2-22.el7.x86_64.rpm
        │   ├── tftp-server-5.2-22.el7.x86_64.rpm
        │   └── xinetd-2.3.15-13.el7.x86_64.rpm
        ├── vconfig
        │   └── vconfig-1.9-16.el7.x86_64.rpm
        └── wcg-deps-install.sh

18 directories, 88 files

[root@localhost wcg-deps]# cat build.sh 
#!/bin/bash -

install_path=/home/wcg

function build_wcg_deps() {
	VERSION=$1
	RELEASE=$2
	fpm -f -s dir -t rpm -n "baicells-wcg-deps" -v "$VERSION" --iteration "$RELEASE" -C "source" -p . \
		--verbose \
		--description "BAICELLS-WCG-DEPS" \
		--maintainer "dongfeng@baicells.com" \
		--vendor "baicells" \
		WCG-deps=$install_path/	
};build_wcg_deps 1.0.0 1

4. 使用方法

  • 安装打包好的rpm

  • 在/home/wcg/WCG-deps路径下执行install.sh脚本