Blob Blame History Raw
#!/bin/bash

#################################################################################
# 
# Name :  CentOS 6 Live Media [CD,DVD] build script 
# Function : Builds the CD,DVD media from the last current C6 tree
# How to call it : see usage()
# Author : Fabian Arrotin (arrfab@centos.org)
#
#################################################################################

usage() {

cat <<  EOF

You need to call the script like this : $0 -arguments

        -a : define the arch (required, default:none, values : [i386,x86_64])   
        -p : define the repo path (required, default:none)
	-m : define the media type (required, default:none, values : [cd,dvd])
        -h : display this help

EOF

}

varcheck() {
if [ -z "$1" ] ; then
        usage
        exit 1
fi

}


while getopts “ha:p:m:” OPTION
do
     case $OPTION in
         h)
             usage
             exit 1
             ;;
         a)
             arch=$OPTARG
             ;;
         m)
             media=$(echo $OPTARG|tr [:lower:] [:upper:])
             ;;
         p)
             repopath=$OPTARG
             ;;
         ?)
             usage
             exit
             ;;
     esac
done

varcheck $arch
varcheck $media
varcheck $repopath

if [ `id -u` -ne "0" ]; then
	echo "you must call this script as root or with proper sudo permissions !"
	exit 1
fi

# Checking that we have the proper build tools installed
for package in livecd-tools python-imgcreate;
do
	rpm -q $package >/dev/null 2>&1 
	if [ $? -ne 0 ];then
		echo "Package $package not installed and needed for the $0 script to run !"
		exit 1
	fi
done

cd `dirname $0`
setenforce 0
/bin/cp ks/centos6-live${media}-desktop.cfg /tmp/
sed -i s#REPOPATH#$repopath#g /tmp/centos6-live${media}-desktop.cfg
setarch $arch livecd-creator -c /tmp/centos6-live${media}-desktop.cfg -f "CentOS-6-${arch}-Live${media}" 
setenforce 1