aboutsummaryrefslogtreecommitdiffstats
path: root/build
diff options
context:
space:
mode:
authorbaigk <baiguoku@huawei.com>2015-09-15 16:01:00 +0800
committerbaigk <baiguoku@huawei.com>2015-09-17 10:59:21 +0800
commit4265a1ec3817d137332f6a771bbbef0eaee5879c (patch)
treed298d91d26da5c8e4d46faa9bce151681e9d62a5 /build
parent80bf7f3ca6be838b3ebd09f45e96d71e5a361d8b (diff)
Add parameter allows users to add their own package or scripts of making package to ISO file
JIRA: COMPASS-55 Change-Id: I2ef6539ebf73fe57fb2a5dcb01ff5d8c4727dc1f Signed-off-by: baigk <baiguoku@huawei.com>
Diffstat (limited to 'build')
-rw-r--r--build/gen_ins_pkg_script.py14
-rwxr-xr-xbuild/make_repo.sh67
-rw-r--r--build/os/centos/rhel6/compass/Dockerfile.tmpl5
-rw-r--r--build/os/centos/rhel7/juno/Dockerfile.tmpl5
-rw-r--r--build/os/ubuntu/trusty/juno/Dockerfile.tmpl5
-rw-r--r--build/os/ubuntu/trusty/kilo/Dockerfile.tmpl5
-rw-r--r--build/templates/RedHat_juno.tmpl2
7 files changed, 65 insertions, 38 deletions
diff --git a/build/gen_ins_pkg_script.py b/build/gen_ins_pkg_script.py
index 0f756d07..c3c55cfc 100644
--- a/build/gen_ins_pkg_script.py
+++ b/build/gen_ins_pkg_script.py
@@ -34,7 +34,8 @@ def get_packages_name_list(file_list, special_packages):
return package_name_list
-def generate_download_script(root, arch, tmpl, docker_tmpl, default_packages, special_packages, special_packages_dir):
+def generate_download_script(root="", arch="", tmpl="", docker_tmpl="", default_packages="",
+ special_packages="", special_packages_script_dir="", special_packages_dir=""):
package_name_list = get_packages_name_list(get_file_list(root, arch), special_packages) if root else []
tmpl = Template(file=tmpl, searchList={'packages':package_name_list, 'default_packages':default_packages})
@@ -44,12 +45,15 @@ def generate_download_script(root, arch, tmpl, docker_tmpl, default_packages, sp
make_script = []
for i in special_packages:
name = 'make_' + i + '.sh'
- if os.path.exists(os.path.join('.', arch, name)):
+ if os.path.exists(os.path.join(special_packages_script_dir, name)):
make_script.append(name)
- searchList = {'dir':os.path.join('.', arch), 'scripts':make_script}
+ searchList = {'scripts':make_script}
if os.path.exists(special_packages_dir):
- special_packages_names = [i for i in os.listdir(special_packages_dir) if os.path.isfile(i)]
+ special_packages_names=[]
+ for i in os.listdir(special_packages_dir):
+ if os.path.isfile(os.path.join(special_packages_dir, i)):
+ special_packages_names.append(i)
searchList.update({'spcial_packages':special_packages_names})
Dockerfile=os.path.basename(docker_tmpl).split('.')[0]
@@ -60,5 +64,5 @@ def generate_download_script(root, arch, tmpl, docker_tmpl, default_packages, sp
if __name__=='__main__':
# generate_download_script('ansible', 'Debian', 'Debian.tmpl')
generate_download_script(sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4],
- sys.argv[5].split(' '), sys.argv[6].split(' '), sys.argv[7])
+ sys.argv[5].split(' '), sys.argv[6].split(' '), sys.argv[7], sys.argv[8])
diff --git a/build/make_repo.sh b/build/make_repo.sh
index 8ef3c448..6d5faab7 100755
--- a/build/make_repo.sh
+++ b/build/make_repo.sh
@@ -32,7 +32,11 @@ function make_repo()
rm -f ${WORK_PATH}/work/repo/install_packages.sh
rm -f ${WORK_PATH}/work/repo/Dockerfile
- TEMP=`getopt -o h -l os-ver:,package-tag:,tmpl:,default-package:,special-package:,ansible-dir: -n 'make_repo.sh' -- "$@"`
+ option=`echo "os-ver:,package-tag:,tmpl:,default-package:, \
+ special-package:,special-package-script-dir:, \
+ special-package-dir:,ansible-dir:,special-package-dir" | sed 's/ //g'`
+
+ TEMP=`getopt -o h -l $option -n 'make_repo.sh' -- "$@"`
if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
@@ -43,6 +47,7 @@ function make_repo()
tmpl=""
default_package=""
special_package=""
+ special_package_script_dir=""
special_package_dir=""
ansible_dir=""
while :; do
@@ -52,19 +57,20 @@ function make_repo()
--tmpl) tmpl=$2; shift 2;;
--default-package) default_package=$2; shift 2;;
--special-package) special_package=$2; shift 2;;
+ --special-package-script-dir) special_package_script_dir=$2; shift 2;;
--special-package-dir) special_package_dir=$2; shift 2;;
--ansible-dir) ansible_dir=$2; shift 2;;
--) shift; break;;
- *) echo "Internal error!" ; exit 1 ;;
+ *) echo "Internal error! $1" ; exit 1 ;;
esac
done
- if [[ ! -z ${package_tag} && ${package_tag} == "pip" ]]; then
+ if [[ -n ${package_tag} && ${package_tag} == "pip" ]]; then
make_pip_repo
return
fi
- if [[ -z ${os_ver} || -z ${tmpl} || -z ${package_tag} ]]; then
+ if [[ -z ${os_ver} || -z ${package_tag} ]]; then
echo "parameter is wrong"
exit 1
fi
@@ -79,25 +85,50 @@ function make_repo()
os_name=centos
fi
+ if [[ -z $arch ]]; then
+ echo "unsupported ${os_ver} os"
+ exit 1
+ fi
+
dockerfile=Dockerfile
docker_tmpl=${BUILD_PATH}/os/${os_name}/${os_ver}/${package_tag}/${dockerfile}".tmpl"
docker_tag="${os_ver}/${package_tag}"
- python ${BUILD_PATH}/gen_ins_pkg_script.py "${ansible_dir}" "${arch}" "${BUILD_PATH}/templates/${tmpl}" \
- "${docker_tmpl}" "${default_package}" "${special_package}" "${special_package_dir}"
+ if [[ -z ${tmpl} ]]; then
+ tmpl=${BUILD_PATH}/templates/${arch}_${package_tag}.tmpl
+ fi
+
+ python ${BUILD_PATH}/gen_ins_pkg_script.py "${ansible_dir}" "${arch}" "${tmpl}" \
+ "${docker_tmpl}" "${default_package}" "${special_package}" \
+ "${WORK_PATH}/work/repo/$arch/script/" \
+ "${WORK_PATH}/work/repo/$arch/packages/"
+
+ rm -rf ${WORK_PATH}/work/repo/$arch
+ mkdir -p ${WORK_PATH}/work/repo/$arch/{script,packages}
+
+ # copy default package script to wokr dir
+ if [[ -d ${WORK_PATH}/build/arch/$arch ]]; then
+ cp -rf ${WORK_PATH}/build/arch/$arch/* ${WORK_PATH}/work/repo/$arch/script/
+ fi
+
+ # copy make package script to work dir
+ if [[ -n $special_package_script_dir && -d $special_package_script_dir ]]; then
+ cp -rf $special_package_script_dir/* ${WORK_PATH}/work/repo/$arch/script/
+ fi
- # copy make package script to work/repo dir
- if [[ -n $arch && -d ${WORK_PATH}/build/templates/$arch ]]; then
- rm -rf ${WORK_PATH}/work/repo/$arch
- cp -rf ${WORK_PATH}/build/templates/$arch ${WORK_PATH}/work/repo/
+ # copy special package to work dir
+ if [[ -n $special_package_dir && -d $special_package_dir ]]; then
+ cp -rf $special_package_dir/* ${WORK_PATH}/work/repo/$arch/packages/
fi
+ # copy docker file to work dir
if [[ -n $os_ver && -d ${WORK_PATH}/build/os/$os_name/$os_ver ]]; then
rm -rf ${WORK_PATH}/work/repo/$os_ver
cp -rf ${WORK_PATH}/build/os/$os_name/$os_ver ${WORK_PATH}/work/repo
fi
- if [[ -f ${WORK_PATH}/build/os/$os_name/comps.xml ]]; then
+ # copy centos comps.xml to work dir
+ if [[ $arch == RedHat && -f ${WORK_PATH}/build/os/$os_name/comps.xml ]]; then
cp -rf ${WORK_PATH}/build/os/$os_name/comps.xml ${WORK_PATH}/work/repo
fi
@@ -127,29 +158,25 @@ function make_pip_repo()
function make_all_repo()
{
- make_pip_repo
+ make_repo --package-tag pip
make_repo --os-ver rhel6 --package-tag compass \
- --tmpl compass_core.tmpl \
+ --tmpl "${WORK_PATH}/build/templates/compass_core.tmpl" \
--default-package "epel-release python-yaml python-jinja2 python-paramiko"
make_repo --os-ver trusty --package-tag juno \
--ansible-dir $WORK_PATH/deploy/adapters/ansible \
- --tmpl Debian_juno.tmpl \
--default-package "openssh-server" \
- --special-package "openvswitch-datapath-dkms openvswitch-switch"
+ --special-package "openvswitch-datapath-dkms openvswitch-switch" \
make_repo --os-ver trusty --package-tag kilo \
--ansible-dir $WORK_PATH/deploy/adapters/ansible \
- --tmpl Debian_kilo.tmpl \
--default-package "openssh-server" \
- --special-package "openvswitch-datapath-dkms openvswitch-switch"
+ --special-package "openvswitch-datapath-dkms openvswitch-switch" \
make_repo --os-ver rhel7 --package-tag juno \
--ansible-dir $WORK_PATH/deploy/adapters/ansible \
- --tmpl RedHat_juno.tmpl \
- --default-package "rsyslog strace net-tools wget vim openssh-server dracut-config-rescue dracut-network" \
- --special-package ""
+ --default-package "rsyslog strace net-tools wget vim openssh-server dracut-config-rescue dracut-network"
}
function main()
diff --git a/build/os/centos/rhel6/compass/Dockerfile.tmpl b/build/os/centos/rhel6/compass/Dockerfile.tmpl
index 6740dc41..29c05426 100644
--- a/build/os/centos/rhel6/compass/Dockerfile.tmpl
+++ b/build/os/centos/rhel6/compass/Dockerfile.tmpl
@@ -11,12 +11,11 @@ RUN yum update -y
RUN sed -i 's/keepcache=0/keepcache=1/g' /etc/yum.conf
#set packages = $getVar('spcial_packages', [])
#for package in $packages
-ADD $packages /var/cache/yum/x86_64/7/base/packages/
+ADD ./RedHat/packages/$package /var/cache/yum/x86_64/6/base/packages/
#end for
#set scripts = $getVar('scripts', [])
-#set dir = $getVar('dir', ".")
#for script in $scripts
-ADD $dir/$script /tmp/chigang/$script
+ADD ./RedHat/script/$script /tmp/chigang/$script
RUN chmod +x /tmp/chigang/$script
RUN /tmp/chigang/$script
#end for
diff --git a/build/os/centos/rhel7/juno/Dockerfile.tmpl b/build/os/centos/rhel7/juno/Dockerfile.tmpl
index df5f41b4..d0d45ae4 100644
--- a/build/os/centos/rhel7/juno/Dockerfile.tmpl
+++ b/build/os/centos/rhel7/juno/Dockerfile.tmpl
@@ -8,12 +8,11 @@ MAINTAINER Chigang(Justin) <chigang@huawei.com>
RUN sed -i 's/keepcache=0/keepcache=1/g' /etc/yum.conf
#set packages = $getVar('spcial_packages', [])
#for package in $packages
-ADD $packages /var/cache/yum/x86_64/7/base/packages/
+ADD ./RedHat/packages/$package /var/cache/yum/x86_64/7/base/packages/
#end for
#set scripts = $getVar('scripts', [])
-#set dir = $getVar('dir', ".")
#for script in $scripts
-ADD $dir/$script /tmp/chigang/$script
+ADD ./RedHat/script/$script /tmp/chigang/$script
RUN chmod +x /tmp/chigang/$script
RUN /tmp/chigang/$script
#end for
diff --git a/build/os/ubuntu/trusty/juno/Dockerfile.tmpl b/build/os/ubuntu/trusty/juno/Dockerfile.tmpl
index 944fb154..d723b6e7 100644
--- a/build/os/ubuntu/trusty/juno/Dockerfile.tmpl
+++ b/build/os/ubuntu/trusty/juno/Dockerfile.tmpl
@@ -9,12 +9,11 @@ RUN sed -i 's/archive.ubuntu.com/mirrors.163.com/g' /etc/apt/sources.list
RUN rm -f /etc/apt/apt.conf.d/docker-clean
#set packages = $getVar('spcial_packages', [])
#for package in $packages
-ADD $packages /var/cache/apt/archives/
+ADD ./Debian/packages/$package /var/cache/apt/archives/
#end for
#set scripts = $getVar('scripts', [])
-#set dir = $getVar('dir', ".")
#for script in $scripts
-ADD $dir/$script /tmp/chigang/$script
+ADD ./Debian/script/$script /tmp/chigang/$script
RUN chmod +x /tmp/chigang/$script
RUN /tmp/chigang/$script
#end for
diff --git a/build/os/ubuntu/trusty/kilo/Dockerfile.tmpl b/build/os/ubuntu/trusty/kilo/Dockerfile.tmpl
index 944fb154..d723b6e7 100644
--- a/build/os/ubuntu/trusty/kilo/Dockerfile.tmpl
+++ b/build/os/ubuntu/trusty/kilo/Dockerfile.tmpl
@@ -9,12 +9,11 @@ RUN sed -i 's/archive.ubuntu.com/mirrors.163.com/g' /etc/apt/sources.list
RUN rm -f /etc/apt/apt.conf.d/docker-clean
#set packages = $getVar('spcial_packages', [])
#for package in $packages
-ADD $packages /var/cache/apt/archives/
+ADD ./Debian/packages/$package /var/cache/apt/archives/
#end for
#set scripts = $getVar('scripts', [])
-#set dir = $getVar('dir', ".")
#for script in $scripts
-ADD $dir/$script /tmp/chigang/$script
+ADD ./Debian/script/$script /tmp/chigang/$script
RUN chmod +x /tmp/chigang/$script
RUN /tmp/chigang/$script
#end for
diff --git a/build/templates/RedHat_juno.tmpl b/build/templates/RedHat_juno.tmpl
index 1f6873bb..9741b860 100644
--- a/build/templates/RedHat_juno.tmpl
+++ b/build/templates/RedHat_juno.tmpl
@@ -7,7 +7,7 @@ wget -O /etc/yum.repos.d/CentOS7-Base-163.repo http://mirrors.163.com/.help/Cen
yum remove wget iptables-services -y
rm -f /etc/yum.repos.d/CentOS-*.repo
yum repolist
-yum cleanall
+yum clean all
# add openstack juno repo
yum install yum-plugin-priorities -y
yum install http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm -y