CASA/casa-yast/make_casa_yast.sh

1509 lines
40 KiB
Bash
Raw Normal View History

2006-04-14 22:38:26 +02:00
#! /bin/bash
#------------------------------------------------------------------------------
# make_casa_yast.sh
#
# Build the CASA YaST2 Configuration RPM
#------------------------------------------------------------------------------
# Comments to:
# support@Novell.com
#------------------------------------------------------------------------------
#
# Copyright (C) 2005-2006 Novell, Inc. All Rights Reserved.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; version 2.1
# of the License.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Library Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, Novell, Inc.
#
# To contact Novell about this file by physical or electronic mail,
# you may find current contact information at www.novell.com.
#
#
#------------------------------------------------------------------------------
#
# START_DIR = pwd - the current working directory
# this is the directory where this script is executed from
#
#------------------------------------------------------------------------------
VERSION=1.0
SCRIPT_NAME='make_casa_yast'
validateCommandLineParams ()
{
echo ""
echo "************************************************************"
echo "[$SCRIPT_NAME] Validating the command line parameters"
if [ $BUILD_MODE != "local" ]
then
if [ $BUILD_MODE != "clean" ]
then
echo ""
echo "[$SCRIPT_NAME] ERROR: invalid build mode [$BUILD_MODE]"
echo "[$SCRIPT_NAME] Usage: ./$SCRIPT_NAME"
echo "[$SCRIPT_NAME] Usage: [ local | clean ]"
echo "[$SCRIPT_NAME] Usage: local [ make ]"
echo "[$SCRIPT_NAME] Usage: clean"
echo ""
exit
fi
fi
if [ $BUILD_MODE == "local" ]
then
if [ $BUILD_TYPE != "make" ]
then
echo ""
echo "[$SCRIPT_NAME] ERROR: invalid build type [$BUILD_TYPE] for build mode [$BUILD_MODE]"
echo "[$SCRIPT_NAME] Usage: ./$SCRIPT_NAME"
echo "[$SCRIPT_NAME] Usage: [ local | clean ]"
echo "[$SCRIPT_NAME] Usage: local [ make ]"
echo "[$SCRIPT_NAME] Usage: clean"
echo ""
exit
fi
fi
}
validateRoot ()
{
# this function validates that the user running the script is root
ROOT_UID=0
if [ "$UID" -ne "$ROOT_UID" ]
then
echo ""
echo "************************************************************"
echo "[$SCRIPT_NAME] ERROR: you are not the root user"
echo "[$SCRIPT_NAME] To run this script sucessfully,"
echo "[$SCRIPT_NAME] you must login as the root user (su)"
echo "[$SCRIPT_NAME] and launch the script again."
echo ""
exit
fi
}
getReleaseAndVersion ()
{
# this function gets the version and release from the spec.in file
echo ""
echo "************************************************************"
echo "[$SCRIPT_NAME] Getting the version and release from the $SPEC_IN_FILE file"
cd $START_DIR
RPM_VERSION_LINE=`cat $START_DIR/$SPEC_IN_FILE |grep 'Version:'`
RPM_VERSION=${RPM_VERSION_LINE:9}
echo "[$SCRIPT_NAME] $PACKAGE_NAME version = $RPM_VERSION"
RPM_RELEASE_LINE=`cat $START_DIR/$SPEC_IN_FILE |grep 'Release:'`
RPM_RELEASE=${RPM_RELEASE_LINE:9}
echo "[$SCRIPT_NAME] $PACKAGE_NAME release = $RPM_RELEASE"
cd $START_DIR
}
deleteGeneratedFiles ()
{
# delete the generated files
echo ""
echo "************************************************************"
echo "[$SCRIPT_NAME] Deleting the genarated files:"
#
# cd $START_DIR
#
# # Yast_Config directory
# if [ -e $START_DIR/aclocal.m4 ]
# then
# echo "[$SCRIPT_NAME] - aclocal.m4"
# rm $START_DIR/aclocal.m4
# fi
# if [ -e $START_DIR/config.guess ]
# then
# echo "[$SCRIPT_NAME] - config.guess"
# rm $START_DIR/config.guess
# fi
# if [ -e $START_DIR/config.log ]
# then
# echo "[$SCRIPT_NAME] - config.log"
# rm $START_DIR/config.log
# fi
# if [ -e $START_DIR/config.status ]
# then
# echo "[$SCRIPT_NAME] - config.status"
# rm $START_DIR/config.status
# fi
# if [ -e $START_DIR/config.sub ]
# then
# echo "[$SCRIPT_NAME] - config.sub"
# rm $START_DIR/config.sub
# fi
# if [ -e $START_DIR/configure ]
# then
# echo "[$SCRIPT_NAME] - configure"
# rm $START_DIR/configure
# fi
# if [ -e $START_DIR/configure.in ]
# then
# echo "[$SCRIPT_NAME] - configure.in"
# rm $START_DIR/configure.in
# fi
# if [ -e $START_DIR/install-sh ]
# then
# echo "[$SCRIPT_NAME] - install-sh"
# rm $START_DIR/install-sh
# fi
# if [ -e $START_DIR/missing ]
# then
# echo "[$SCRIPT_NAME] - missing"
# rm $START_DIR/missing
# fi
# if [ -e $START_DIR/Makefile.am ]
# then
# echo "[$SCRIPT_NAME] - Makefile.am"
# rm $START_DIR/Makefile.am
# fi
# if [ -e $START_DIR/Makefile.am.common ]
# then
# echo "[$SCRIPT_NAME] - Makefile.am.common"
# rm $START_DIR/Makefile.am.common
# fi
# if [ -e $START_DIR/Makefile.in ]
# then
# echo "[$SCRIPT_NAME] - Makefile.in"
# rm $START_DIR/Makefile.in
# fi
#
# # Yast_Config/agents directory
# if [ -e $START_DIR/agents/Makefile.in ]
# then
# echo "[$SCRIPT_NAME] - agents/Makefile.in"
# rm $START_DIR/agents/Makefile.in
# fi
#
# # Yast_Config/autom4t3.cache directory
# if [ -d $START_DIR/autom4te.cache ]
# then
# echo "[$SCRIPT_NAME] - autom4te.cache"
# rm -rf $START_DIR/autom4te.cache
# fi
#
# # Yast_Config/doc directory
# if [ -e $START_DIR/doc/Makefile.in ]
# then
# echo "[$SCRIPT_NAME] - doc/Makefile.in"
# rm $START_DIR/doc/Makefile.in
# fi
#
# # Yast_Config/doc/autodocs directory
# if [ -e $START_DIR/doc/autodocs/Makefile.in ]
# then
# echo "[$SCRIPT_NAME] - doc/autodocs/Makefile.in"
# rm $START_DIR/doc/autodocs/Makefile.in
# fi
#
# # Yast_Config/eula directory
# if [ -e $START_DIR/eula/Makefile.in ]
# then
# echo "[$SCRIPT_NAME] - eula/Makefile.in"
# rm $START_DIR/eula/Makefile.in
# fi
#
# # Yast_Config/pofiles directory
# if [ -e $START_DIR/pofiles/Makefile.in ]
# then
# echo "[$SCRIPT_NAME] - pofiles/Makefile.in"
# rm $START_DIR/pofiles/Makefile.in
# fi
#
# # Yast_Config/src directory
# if [ -e $START_DIR/src/Makefile.in ]
# then
# echo "[$SCRIPT_NAME] - src/Makefile.in"
# rm $START_DIR/src/Makefile.in
# fi
#
# cd $START_DIR
}
deleteMakefiles ()
{
# delete the Makefiles
echo ""
echo "************************************************************"
echo "[$SCRIPT_NAME] Deleting the Makefiles:"
# cd $START_DIR
#
# if [ -e $START_DIR/Makefile ]
# then
# echo "[$SCRIPT_NAME] - Makefile"
# rm $START_DIR/Makefile
# fi
#
# # Yast_Config/agents directory
# if [ -e $START_DIR/agents/Makefile ]
# then
# echo "[$SCRIPT_NAME] - agents/Makefile"
# rm $START_DIR/agents/Makefile
# fi
#
# # Yast_Config/doc directory
# if [ -e $START_DIR/doc/Makefile ]
# then
# echo "[$SCRIPT_NAME] - doc/Makefile"
# rm $START_DIR/doc/Makefile
# fi
#
# # Yast_Config/doc/autodocs directory
# if [ -e $START_DIR/doc/autodocs/Makefile ]
# then
# echo "[$SCRIPT_NAME] - doc/autodocs/Makefile"
# rm $START_DIR/doc/autodocs/Makefile
# fi
#
# # Yast_Config/eula directory
# if [ -e $START_DIR/eula/Makefile ]
# then
# echo "[$SCRIPT_NAME] - eula/Makefile"
# rm $START_DIR/eula/Makefile
# fi
#
# # Yast_Config/pofiles directory
# if [ -e $START_DIR/pofiles/Makefile ]
# then
# echo "[$SCRIPT_NAME] - pofiles/Makefile"
# rm $START_DIR/pofiles/Makefile
# fi
#
# # Yast_Config/src directory
# if [ -e $START_DIR/src/Makefile ]
# then
# echo "[$SCRIPT_NAME] - src/Makefile"
# rm $START_DIR/src/Makefile
# fi
#
# cd $START_DIR
}
generateMakeFiles ()
{
# generate the Makefiles
echo ""
echo "************************************************************"
echo "[$SCRIPT_NAME] Generating the Makefiles"
cd $START_DIR
if [ -e $LOG_DIRECTORY/make-Makefile.log ]
then
rm $LOG_DIRECTORY/make-Makefile.log
fi
echo "[$SCRIPT_NAME] make -f Makefile.svn > $LOG_DIRECTORY/make-Makefile.log"
make -f Makefile.svn > $LOG_DIRECTORY/make-Makefile.log
if [ $? -ne 0 ]; then
echo ""
echo "[$SCRIPT_NAME] ERROR: [make -f Makefile.svn > $LOG_DIRECTORY/make-Makefile.log] failed"
echo ""
fi
cd $START_DIR
}
deleteRpmDirectory()
{
# this function deletes the rpm directory
# cd $START_DIR
#
# if [ -d $RPM_DIRECTORY ]
# then
# echo ""
# echo "************************************************************"
# echo "[$SCRIPT_NAME] deleting the rpm directory"
# echo "[$SCRIPT_NAME] $RPM_DIRECTORY"
# rm -rf $RPM_DIRECTORY
# if [ -d $RPM_DIRECTORY ]
# then
# echo ""
# echo "[$SCRIPT_NAME] ERROR: could not delete $RPM_DIRECTORY"
# echo ""
# else
# echo "[$SCRIPT_NAME] deleted $RPM_DIRECTORY"
# fi
# fi
#
cd $START_DIR
}
deleteLogDirectory()
{
# this function deletes the log directory
# cd $START_DIR
#
# if [ -d $LOG_DIRECTORY ]
# then
# echo ""
# echo "************************************************************"
# echo "[$SCRIPT_NAME] deleting the log directory"
# echo "[$SCRIPT_NAME] $LOG_DIRECTORY"
# rm -rf $LOG_DIRECTORY
# if [ -d $LOG_DIRECTORY ]
# then
# echo ""
# echo "[$SCRIPT_NAME] ERROR: could not delete $LOG_DIRECTORY"
# echo ""
# else
# echo "[$SCRIPT_NAME] deleted $LOG_DIRECTORY"
# fi
# fi
#
cd $START_DIR
}
deleteLogDirectoryContents()
{
# this function deletes the log directory contents but leaves the log directory in place
cd $START_DIR
# if [ -d $LOG_DIRECTORY ]
# then
# echo ""
# echo "************************************************************"
# echo "[$SCRIPT_NAME] delete log files in $LOG_DIRECTORY"
# if [ -e $LOG_DIRECTORY/make-Makefile.log ]
# then
# echo "[$SCRIPT_NAME] - make-Makefile.log"
# rm $LOG_DIRECTORY/make-Makefile.log
# fi
# if [ -e $LOG_DIRECTORY/make-clean-before.log ]
# then
# echo "[$SCRIPT_NAME] - make-clean-before.log"
# rm $LOG_DIRECTORY/make-clean-before.log
# fi
# if [ -e $LOG_DIRECTORY/make-install.log ]
# then
# echo "[$SCRIPT_NAME] - make-install.log"
# rm $LOG_DIRECTORY/make-install.log
# fi
# if [ -e $LOG_DIRECTORY/make-package-local.log ]
# then
# echo "[$SCRIPT_NAME] - make-package-local.log"
# rm $LOG_DIRECTORY/make-package-local.log
# fi
# if [ -e $LOG_DIRECTORY/rpmbuild.log ]
# then
# echo "[$SCRIPT_NAME] - rpmbuild.log"
# rm $LOG_DIRECTORY/rpmbuild.log
# fi
# if [ -e $LOG_DIRECTORY/make-uninstall.log ]
# then
# echo "[$SCRIPT_NAME] - make-uninstall.log"
# rm $LOG_DIRECTORY/make-uninstall.log
# fi
# if [ -e $LOG_DIRECTORY/make-clean-after.log ]
# then
# echo "[$SCRIPT_NAME] - make-clean-after.log"
# rm $LOG_DIRECTORY/make-clean-after.log
# fi
# fi
cd $START_DIR
}
deletePackageDirectory ()
{
# this function deletes the package directory
cd $START_DIR
#
# if [ -d $PACKAGE_DIRECTORY ]
# then
# echo ""
# echo "************************************************************"
# echo "[$SCRIPT_NAME] deleting the package directory"
# echo "[$SCRIPT_NAME] $PACKAGE_DIRECTORY"
# rm -rf $PACKAGE_DIRECTORY
# if [ -d $PACKAGE_DIRECTORY ]
# then
# echo ""
# echo "[$SCRIPT_NAME] ERROR: could not delete $PACKAGE_DIRECTORY"
# echo ""
# else
# echo "[$SCRIPT_NAME] deleted $PACKAGE_DIRECTORY"
# fi
# fi
#
cd $START_DIR
}
deleteTarDirectory ()
{
# this function deletes the tar directory
cd $START_DIR
#
# if [ -d $TAR_DIRECTORY ]
# then
# echo ""
# echo "************************************************************"
# echo "[$SCRIPT_NAME] deleting the tar directory"
# echo "[$SCRIPT_NAME] $TAR_DIRECTORY"
# rm -rf $TAR_DIRECTORY
# if [ -d $TAR_DIRECTORY ]
# then
# echo ""
# echo "[$SCRIPT_NAME] ERROR: could not delete $TAR_DIRECTORY"
# echo ""
# else
# echo "[$SCRIPT_NAME] deleted $TAR_DIRECTORY"
# fi
# fi
#
# cd $START_DIR
}
deleteSpecDirectory ()
{
# this function deletes the spec directory
cd $START_DIR
#
# if [ -d $SPEC_FILE_DIRECTORY ]
# then
# echo ""
# echo "************************************************************"
# echo "[$SCRIPT_NAME] deleting the spec directory"
# echo "[$SCRIPT_NAME] $SPEC_FILE_DIRECTORY"
# rm -rf $SPEC_FILE_DIRECTORY
# if [ -d $SPEC_FILE_DIRECTORY ]
# then
# echo ""
# echo "[$SCRIPT_NAME] ERROR: could not delete $SPEC_FILE_DIRECTORY"
# echo ""
# else
# echo "[$SCRIPT_NAME] deleted $SPEC_FILE_DIRECTORY"
# fi
# fi
#
# cd $START_DIR
}
deleteBuildDirectoryContents ()
{
#this function deletes the BUILD directory contents
PACKAGE_BUILD_DIR="$BUILD_ROOT_BUILD_DIR/$PACKAGE_NAME-$RPM_VERSION"
# cd $START_DIR
#
# if [ -d $PACKAGE_BUILD_DIR ]
# then
# echo ""
# echo "************************************************************"
# echo "[$SCRIPT_NAME] deleting the build directory"
# echo "[$SCRIPT_NAME] $PACKAGE_BUILD_DIR"
# rm -rf $PACKAGE_BUILD_DIR
# if [ -d $PACKAGE_BUILD_DIR ]
# then
# echo ""
# echo "[$SCRIPT_NAME] ERROR: could not delete $PACKAGE_BUILD_DIR"
# echo ""
# else
# echo "[$SCRIPT_NAME] deleted $PACKAGE_BUILD_DIR"
# fi
# fi
#
cd $START_DIR
}
deleteSourcesDirectoryContents ()
{
#this function deletes the tar file from the SOURCES directory
SOURCES_TAR_FILE="$BUILD_ROOT_SOURCES_DIR/$TAR_BZ2_FILE"
cd $START_DIR
# if [ -e $SOURCES_TAR_FILE ]
# then
# echo ""
# echo "************************************************************"
# echo "[$SCRIPT_NAME] deleting the tar file from the SOURCES directory"
# echo "[$SCRIPT_NAME] $SOURCES_TAR_FILE"
# rm -f $SOURCES_TAR_FILE
# if [ -e $SOURCES_TAR_FILE ]
# then
# echo ""
# echo "[$SCRIPT_NAME] ERROR: could not delete $SOURCES_TAR_FILE"
# echo ""
# else
# echo "[$SCRIPT_NAME] deleted $SOURCES_TAR_FILE"
# fi
# fi
#
cd $START_DIR
}
deleteSpecsDirectoryContents ()
{
#this function deletes the spec file from the SPECS directory
# SPECS_SPEC_FILE="$BUILD_ROOT_SPECS_DIR/$SPEC_FILE"
#
# cd $START_DIR
#
# if [ -e $SPECS_SPEC_FILE ]
# then
# echo ""
# echo "************************************************************"
# echo "[$SCRIPT_NAME] deleting the spec file from the SPECS directory"
# echo "[$SCRIPT_NAME] $SPECS_SPEC_FILE"
# rm -f $SPECS_SPEC_FILE
# if [ -e $SPECS_SPEC_FILE ]
# then
# echo ""
# echo "[$SCRIPT_NAME] ERROR: could not delete $SPECS_SPEC_FILE"
# echo ""
# else
# echo "[$SCRIPT_NAME] deleted $SPECS_SPEC_FILE"
# fi
# fi
cd $START_DIR
}
deleteRpmsDirectoryContents ()
{
#this function deletes the rpm from the RPMS directory
# RPMS_RPM_FILE="$BUILD_ROOT_RPMS_DIR/$ARCH/$RPM_FILE"
#
# cd $START_DIR
#
# if [ -e $RPMS_RPM_FILE ]
# then
# echo ""
# echo "************************************************************"
# echo "[$SCRIPT_NAME] deleting the rpm from the RPMS directory"
# echo "[$SCRIPT_NAME] $RPMS_RPM_FILE"
# rm -f $RPMS_RPM_FILE
# if [ -e $RPMS_RPM_FILE ]
# then
# echo ""
# echo "[$SCRIPT_NAME] ERROR: could not delete $RPMS_RPM_FILE"
# echo ""
# else
# echo "[$SCRIPT_NAME] deleted $RPMS_RPM_FILE"
# fi
# fi
cd $START_DIR
}
createTarDirectory ()
{
# this function creates the tar directory
cd $START_DIR
deleteTarDirectory
# create the tar directory
echo ""
echo "************************************************************"
echo "[$SCRIPT_NAME] creating the tar directory"
echo "[$SCRIPT_NAME] $TAR_DIRECTORY"
mkdir -p $TAR_DIRECTORY
if [ -d $TAR_DIRECTORY ]
then
echo "[$SCRIPT_NAME] created $TAR_DIRECTORY"
else
echo ""
echo "[$SCRIPT_NAME] ERROR: could not create $TAR_DIRECTORY"
echo ""
fi
cd $START_DIR
}
createSpecDirectory ()
{
# this function creates the spec directory
cd $START_DIR
deleteSpecDirectory
# create the spec directory
echo ""
echo "************************************************************"
echo "[$SCRIPT_NAME] creating the spec directory"
echo "[$SCRIPT_NAME] $SPEC_FILE_DIRECTORY"
mkdir -p $SPEC_FILE_DIRECTORY
if [ -d $SPEC_FILE_DIRECTORY ]
then
echo "[$SCRIPT_NAME] created $SPEC_FILE_DIRECTORY"
else
echo ""
echo "[$SCRIPT_NAME] ERROR: could not create $SPEC_FILE_DIRECTORY"
echo ""
fi
cd $START_DIR
}
createRpmDirectory ()
{
#this function creates the rpm directory
cd $START_DIR
# delete the rpm directory
deleteRpmDirectory
# create the rpm directory
echo ""
echo "************************************************************"
echo "[$SCRIPT_NAME] creating the rpm directory"
echo "[$SCRIPT_NAME] $RPM_DIRECTORY"
mkdir -p $RPM_DIRECTORY
if [ -d $RPM_DIRECTORY ]
then
echo "[$SCRIPT_NAME] created $RPM_DIRECTORY"
else
echo ""
echo "[$SCRIPT_NAME] ERROR: could not create $RPM_DIRECTORY"
echo ""
fi
cd $START_DIR
}
createLogDirectory ()
{
#this function creates the log directory
cd $START_DIR
# delete the log directory
deleteLogDirectory
# create the log directory
echo ""
echo "************************************************************"
echo "[$SCRIPT_NAME] creating the log directory"
echo "[$SCRIPT_NAME] $LOG_DIRECTORY"
mkdir -p $LOG_DIRECTORY
if [ -d $LOG_DIRECTORY ]
then
echo "[$SCRIPT_NAME] created $LOG_DIRECTORY"
else
echo ""
echo "[$SCRIPT_NAME] ERROR: could not create $LOG_DIRECTORY"
echo ""
fi
cd $START_DIR
}
createPackageDirectory ()
{
#this function creates the package directory
cd $START_DIR
# delete the package directory
deletePackageDirectory
# create the package directory
echo ""
echo "************************************************************"
echo "[$SCRIPT_NAME] creating the package directory"
echo "[$SCRIPT_NAME] $PACKAGE_DIRECTORY"
mkdir -p $PACKAGE_DIRECTORY
if [ -d $PACKAGE_DIRECTORY ]
then
echo "[$SCRIPT_NAME] created $PACKAGE_DIRECTORY"
else
echo ""
echo "[$SCRIPT_NAME] ERROR: could not create $PACKAGE_DIRECTORY"
echo ""
exit
fi
cd $START_DIR
}
executeMakeClean ()
{
# this function runs the make clean command
echo ""
echo "************************************************************"
echo "[$SCRIPT_NAME] Executing make clean"
cd $START_DIR
if [ -e $LOG_DIRECTORY/make-clean.log ]
then
rm $LOG_DIRECTORY/make-clean.log
fi
echo "[$SCRIPT_NAME] make clean > $LOG_DIRECTORY/make-clean.log"
make clean > $LOG_DIRECTORY/make-clean.log
if [ $? -ne 0 ]; then
echo ""
echo "[$SCRIPT_NAME] ERROR: [make clean > $LOG_DIRECTORY/make-clean.log} failed"
echo ""
exit
fi
cd $START_DIR
}
executeMakeCleanBefore ()
{
# this function runs the make clean command
echo ""
echo "************************************************************"
echo "[$SCRIPT_NAME] Executing make clean"
cd $START_DIR
if [ -e $LOG_DIRECTORY/make-clean-before.log ]
then
rm $LOG_DIRECTORY/make-clean-before.log
fi
echo "[$SCRIPT_NAME] make clean > $LOG_DIRECTORY/make-clean-before.log"
make clean > $LOG_DIRECTORY/make-clean-before.log
if [ $? -ne 0 ]; then
echo ""
echo "[$SCRIPT_NAME] ERROR: [make clean > $LOG_DIRECTORY/make-clean-before.log} failed"
echo ""
exit
fi
cd $START_DIR
}
executeMakeCleanAfter ()
{
# this function runs the make clean command
echo ""
echo "************************************************************"
echo "[$SCRIPT_NAME] Executing make clean"
cd $START_DIR
if [ -e $LOG_DIRECTORY/make-clean-after.log ]
then
rm $LOG_DIRECTORY/make-clean-after.log
fi
echo "[$SCRIPT_NAME] make clean > $LOG_DIRECTORY/make-clean-after.log"
make clean > $LOG_DIRECTORY/make-clean-after.log
if [ $? -ne 0 ]; then
echo ""
echo "[$SCRIPT_NAME] ERROR: [make clean > $LOG_DIRECTORY/make-clean-after.log} failed"
echo ""
exit
fi
cd $START_DIR
}
executeMakeUninstall ()
{
# this function runs the make uninstall command
echo ""
echo "************************************************************"
echo "[$SCRIPT_NAME] Executing make uninstall"
cd $START_DIR
if [ -e $LOG_DIRECTORY/make-uninstall.log ]
then
rm $LOG_DIRECTORY/make-uninstall.log
fi
echo "[$SCRIPT_NAME] make uninstall > $LOG_DIRECTORY/make-uninstall.log"
make uninstall > $LOG_DIRECTORY/make-uninstall.log
if [ $? -ne 0 ]; then
echo ""
echo "[$SCRIPT_NAME] ERROR: [make uninstall > $LOG_DIRECTORY/make-uninstall.log] failed"
echo ""
exit
fi
cd $START_DIR
}
executeMakeInstall ()
{
# this function runs the make install command
echo ""
echo "************************************************************"
echo "[$SCRIPT_NAME] Executing make install"
cd $START_DIR
if [ -e $LOG_DIRECTORY/make-install.log ]
then
rm $LOG_DIRECTORY/make-install.log
fi
echo "[$SCRIPT_NAME] make install > $LOG_DIRECTORY/make-install.log"
make install > $LOG_DIRECTORY/make-install.log
if [ $? -ne 0 ]; then
echo ""
echo "[$SCRIPT_NAME] ERROR: [make install > $LOG_DIRECTORY/make-install.log] failed"
echo ""
exit
fi
cd $START_DIR
}
executeMakePackageLocal ()
{
# make the package components
# this creates the tarball in the package directory
echo ""
echo "************************************************************"
echo "[$SCRIPT_NAME] Executing make package-local"
cd $START_DIR
createPackageDirectory
if [ -e $LOG_DIRECTORY/make-package-local.log ]
then
rm $LOG_DIRECTORY/make-package-local.log
fi
echo ""
echo "[$SCRIPT_NAME] make package-local > $LOG_DIRECTORY/make-package-local.log"
make package-local > $LOG_DIRECTORY/make-package-local.log
if [ $? -ne 0 ]; then
echo ""
echo "[$SCRIPT_NAME] ERROR: [make package-local > $LOG_DIRECTORY/make-package-local.log] failed"
echo ""
exit
fi
cd $START_DIR
}
rpmBuild ()
{
# this function builds the rpm locally
cd $START_DIR
echo ""
echo "************************************************************"
echo "[$SCRIPT_NAME] running rpmBuild()"
# delete the yast2-CASA build directory
2006-04-14 22:38:26 +02:00
deleteBuildDirectoryContents
# delete the rpm directory
deleteRpmDirectory
# clean the po, pot and mo files
cleanPOFile
cleanPOTFile
cleanMOFiles
# create the *.mo files
# createMOFiles
# create the log directory
createLogDirectory
# generate the Makefiles that will be used in the next steps
generateMakeFiles
# run make clean
executeMakeCleanBefore
# run make install
executeMakeInstall
# make the package components
# this creates the tarball in the package directory
executeMakePackageLocal
# create the CASA.po file
2006-04-14 22:38:26 +02:00
#createPOFile
# delete the yast2-CASA directory in the SOURCES directory
2006-04-14 22:38:26 +02:00
deleteSourcesDirectoryContents
# delete the spec file in the SPECS directory
deleteSpecsDirectoryContents
# delete the rpm in the RPMS directory
deleteRpmsDirectoryContents
# change to the package directory
echo ""
echo "************************************************************"
echo "[$SCRIPT_NAME] changing to the $PACKAGE_DIRECTORY directory"
cd $PACKAGE_DIRECTORY
pwd
ls
# copy tar file and spec file to /usr/src/packages
echo ""
echo "************************************************************"
echo "[$SCRIPT_NAME] copying files to $BUILD_ROOT"
echo "[$SCRIPT_NAME] Copying $TAR_BZ2_FILE"
echo "[$SCRIPT_NAME] to $BUILD_ROOT_SOURCES_DIR"
cp $TAR_BZ2_FILE $BUILD_ROOT_SOURCES_DIR
if [ $? -ne 0 ]; then
echo ""
echo "[$SCRIPT_NAME] ERROR: Failed to copy $TAR_BZ2_FILE to $BUILD_ROOT_SOURCES_DIR"
echo ""
exit
fi
echo "[$SCRIPT_NAME] Copying $SPEC_FILE"
echo "[$SCRIPT_NAME] to $BUILD_ROOT_SPECS_DIR"
cp $SPEC_FILE $BUILD_ROOT_SPECS_DIR
if [ $? -ne 0 ]; then
echo "[$SCRIPT_NAME] Failed to copy $SPEC_FILE to $BUILD_ROOT_SPECS_DIR"
exit
fi
# cd to the SPECS directory
echo ""
echo "************************************************************"
echo "[$SCRIPT_NAME] changing to the $BUILD_ROOT_SPECS_DIR directory"
cd $BUILD_ROOT_SPECS_DIR
pwd
# build the RPM
echo ""
echo "************************************************************"
echo "[$SCRIPT_NAME] building the RPM using $SPEC_FILE"
if [ -e $LOG_DIRECTORY/rpmbuild.log ]
then
rm $LOG_DIRECTORY/rpmbuild.log
fi
echo "[$SCRIPT_NAME] rpmbuild -bb $SPEC_FILE > $LOG_DIRECTORY/rpmbuild.log"
rpmbuild -bb $SPEC_FILE > $LOG_DIRECTORY/rpmbuild.log
if [ $? -ne 0 ]; then
echo ""
echo "[$SCRIPT_NAME] ERROR: [rpmbuild -bb $SPEC_FILE > $LOG_DIRECTORY/rpmbuild.log] failed"
echo ""
exit
else
echo "[$SCRIPT_NAME] [rpmbuild -bb $SPEC_FILE > $LOG_DIRECTORY/rpmbuild.log] succeeded"
fi
# cd to the START_DIR
echo ""
echo "************************************************************"
echo "[$SCRIPT_NAME] changing back to the original directory"
cd $START_DIR
pwd
# copy the RPM to the rpm directory
createRpmDirectory
echo ""
echo "************************************************************"
echo "[$SCRIPT_NAME] copying $RPM_FILE"
echo "[$SCRIPT_NAME] to $RPM_DIRECTORY"
cp $BUILD_ROOT_RPMS_DIR/$ARCH/$RPM_FILE $RPM_DIRECTORY/.
if [ $? -ne 0 ]; then
echo ""
echo "[$SCRIPT_NAME] ERROR: [cp $BUILD_ROOT_RPMS_DIR/$ARCH/$RPM_FILE $RPM_DIRECTORY/.] failed"
echo ""
exit
fi
echo ""
ls $RPM_DIRECTORY
# delete the package directory
deletePackageDirectory
# delete the yast2-CASA directory in the SOURCES directory
2006-04-14 22:38:26 +02:00
deleteSourcesDirectoryContents
# delete the spec file in the SPECS directory
deleteSpecsDirectoryContents
# delete the rpm in the RPMS directory
deleteRpmsDirectoryContents
# run make uninstall
executeMakeUninstall
# run make clean
executeMakeCleanAfter
# delete the files generated in the make process
deleteMakefiles
deleteGeneratedFiles
# clean the pot and mo files
cleanPOTFile
# delete the yast2-CASA build directory
2006-04-14 22:38:26 +02:00
deleteBuildDirectoryContents
}
createTarBall ()
{
# this function creates the tar file
cd $START_DIR
echo ""
echo "************************************************************"
echo "[$SCRIPT_NAME] running createTarBall()"
# delete the tar directory
deleteTarDirectory
# clean the mo files
cleanMOFiles
# create the *.mo files
createMOFiles
# create the log directory
createLogDirectory
# generate the Makefiles that will be used in the next steps
generateMakeFiles
# run make clean
executeMakeCleanBefore
# run make install
executeMakeInstall
# make the package components
# this creates the tarball in the package directory
executeMakePackageLocal
# create the tar directory and the spec directory
createTarDirectory
createSpecDirectory
# change to the package directory
echo ""
echo "************************************************************"
echo "[$SCRIPT_NAME] changing to the $PACKAGE_DIRECTORY directory"
cd $PACKAGE_DIRECTORY
pwd
ls
# copy tar file to tar directory
echo ""
echo "************************************************************"
echo "[$SCRIPT_NAME] copying $TAR_BZ2_FILE"
echo "[$SCRIPT_NAME] to $TAR_DIRECTORY"
cp $TAR_BZ2_FILE $TAR_DIRECTORY
if [ $? -ne 0 ]; then
echo ""
echo "[$SCRIPT_NAME] ERROR: Failed to copy $TAR_BZ2_FILE to $TAR_DIRECTORY"
echo ""
exit
fi
# copy spec file to spec directory
echo ""
echo "************************************************************"
echo "[$SCRIPT_NAME] copying $SPEC_FILE"
echo "[$SCRIPT_NAME] to $SPEC_FILE_DIRECTORY"
cp $SPEC_FILE $SPEC_FILE_DIRECTORY
if [ $? -ne 0 ]; then
echo ""
echo "[$SCRIPT_NAME] ERROR: Failed to copy $SPEC_FILE to $SPEC_FILE_DIRECTORY"
echo ""
exit
fi
# cd to the START_DIR
echo ""
echo "************************************************************"
echo "[$SCRIPT_NAME] changing back to the original directory"
cd $START_DIR
pwd
# delete the package directory
deletePackageDirectory
# run make uninstall
executeMakeUninstall
# run make clean
executeMakeCleanAfter
# delete the files generated in the make process
deleteMakefiles
deleteGeneratedFiles
# clean the mo files
cleanMOFiles
cd $START_DIR
}
createPOFile ()
{
# use the CASA.pot file to create the CASA.po which is given to localization
2006-04-14 22:38:26 +02:00
cd $START_DIR
echo ""
echo "************************************************************"
echo "[$SCRIPT_NAME] running createPOFile()"
if [ ! -e $START_DIR/$POT_FILE ]
then
echo ""
echo "[$SCRIPT_NAME] ERROR: $START_DIR/$POT_FILE is missing."
echo ""
exit
else
msginit --input=$START_DIR/$POT_FILE --output-file=$START_DIR/$PO_FILE --no-wrap
if [ $? -ne 0 ]; then
echo ""
echo "[$SCRIPT_NAME] ERROR: Failed to create $START_DIR/$PO_FILE"
echo ""
exit
else
echo "[$SCRIPT_NAME] $START_DIR/$PO_FILE created successfully"
fi
fi
cd $START_DIR
}
createMOFiles ()
{
# use the CASA.po files from localization to create the CASA.mo files
2006-04-14 22:38:26 +02:00
cd $START_DIR
PO_DIRS="$START_DIR/pofiles/cs
$START_DIR/pofiles/de
$START_DIR/pofiles/en_US
$START_DIR/pofiles/es
$START_DIR/pofiles/fr
$START_DIR/pofiles/hu
$START_DIR/pofiles/it
$START_DIR/pofiles/ja
$START_DIR/pofiles/pl
$START_DIR/pofiles/pt_BR
$START_DIR/pofiles/ru
$START_DIR/pofiles/sk
$START_DIR/pofiles/sv
$START_DIR/pofiles/zh_CN
$START_DIR/pofiles/zh_TW"
echo ""
echo "************************************************************"
echo "[$SCRIPT_NAME] running createMOFiles()"
for PO_DIR in $PO_DIRS
do
echo "[$SCRIPT_NAME] $PO_DIR"
if [ ! -e $PO_DIR/$PO_FILE ]
then
echo ""
echo "[$SCRIPT_NAME] ERROR: $PO_DIR/$PO_FILE is missing."
echo ""
exit
else
msgfmt $PO_DIR/$PO_FILE --output-file=$PO_DIR/$MO_FILE
if [ $? -ne 0 ]; then
echo ""
echo "[$SCRIPT_NAME] ERROR: Failed to create $PO_DIR/$MO_FILE"
echo ""
exit
else
echo "[$SCRIPT_NAME] $PO_DIR/$MO_FILE created successfully"
fi
fi
done
}
clean ()
{
cd $START_DIR
echo ""
echo "************************************************************"
echo "[$SCRIPT_NAME] running clean()"
# from rpmBuild ()
# delete the package directory
deletePackageDirectory
# delete the yast2-CASA directory in the SOURCES directory
2006-04-14 22:38:26 +02:00
deleteSourcesDirectoryContents
# delete the spec file in the SPECS directory
deleteSpecsDirectoryContents
# delete the rpm in the RPMS directory
deleteRpmsDirectoryContents
# create the log directory
createLogDirectory
# genereate the make files
generateMakeFiles
# run make uninstall
executeMakeUninstall
# run make clean
executeMakeClean
# delete the files generated in the make process
deleteMakefiles
deleteGeneratedFiles
# clean the pot and mo files
cleanPOTFile
cleanMOFiles
# delete the yast2-CASA build directory
2006-04-14 22:38:26 +02:00
deleteBuildDirectoryContents
# from rpmBuild ()
# delete the tar directory
deleteTarDirectory
# delete the spec directory
deleteSpecDirectory
# delete the po file
cleanPOFile
# delete the rpm directory
deleteRpmDirectory
cd $START_DIR
}
cleanPOFile ()
{
# delete the CASA.po file
2006-04-14 22:38:26 +02:00
cd $START_DIR
if [ -e $START_DIR/$PO_FILE ]
then
echo ""
echo "************************************************************"
echo "[$SCRIPT_NAME] deleting $PO_FILE"
rm $START_DIR/$PO_FILE
fi
cd $START_DIR
}
cleanPOTFile ()
{
# delete the CASA.pot file
2006-04-14 22:38:26 +02:00
cd $START_DIR
if [ -e $START_DIR/$POT_FILE ]
then
echo ""
echo "************************************************************"
echo "[$SCRIPT_NAME] deleting $POT_FILE"
rm $START_DIR/$POT_FILE
fi
cd $START_DIR
}
cleanMOFiles ()
{
# delete the CASA.mo file
2006-04-14 22:38:26 +02:00
cd $START_DIR
echo ""
echo "************************************************************"
echo "[$SCRIPT_NAME] deleting the *.mo files"
MO_FILES="$START_DIR/pofiles/cs/$MO_FILE
$START_DIR/pofiles/de/$MO_FILE
$START_DIR/pofiles/en_US/$MO_FILE
$START_DIR/pofiles/es/$MO_FILE
$START_DIR/pofiles/fr/$MO_FILE
$START_DIR/pofiles/hu/$MO_FILE
$START_DIR/pofiles/it/$MO_FILE
$START_DIR/pofiles/ja/$MO_FILE
$START_DIR/pofiles/pl/$MO_FILE
$START_DIR/pofiles/pt_BR/$MO_FILE
$START_DIR/pofiles/ru/$MO_FILE
$START_DIR/pofiles/sk/$MO_FILE
$START_DIR/pofiles/sv/$MO_FILE
$START_DIR/pofiles/zh_CN/$MO_FILE
$START_DIR/pofiles/zh_TW/$MO_FILE"
for MO_PATH_AND_FILE in $MO_FILES
do
if [ -e $MO_PATH_AND_FILE ]
then
echo "[$SCRIPT_NAME] deleting $MO_PATH_AND_FILE"
rm $MO_PATH_AND_FILE
fi
done
cd $START_DIR
}
copyBuildRPMs ()
{
# this funciton copies the rpms to the rpm directory
RPM_FULL_NAME="$PACKAGE_NAME-$RPM_VERSION-$RPM_RELEASE.$ARCH.rpm"
SOURCE_RPM_FULL_NAME="$PACKAGE_NAME-$RPM_VERSION-$RPM_RELEASE.src.rpm"
echo ""
echo "************************************************************"
echo "[$SCRIPT_NAME] running copyBuildRPMs()"
cd $START_DIR
createRpmDirectory
if [ -e $TEMPORARY_BUILD_ROOT$BUILD_ROOT_RPMS_DIR/$ARCH/$RPM_FULL_NAME ]
then
echo "[$SCRIPT_NAME] copying $TEMPORARY_BUILD_ROOT$BUILD_ROOT_RPMS_DIR/$ARCH/$RPM_FULL_NAME"
echo "[$SCRIPT_NAME] to $RPM_DIRECTORY"
cp $TEMPORARY_BUILD_ROOT$BUILD_ROOT_RPMS_DIR/$ARCH/$RPM_FULL_NAME $RPM_DIRECTORY/$RPM_FULL_NAME
if [ -e $RPM_DIRECTORY/$RPM_FULL_NAME ]
then
echo "[$SCRIPT_NAME] copied $TEMPORARY_BUILD_ROOT$BUILD_ROOT_RPMS_DIR/$ARCH/$RPM_FULL_NAME"
echo "[$SCRIPT_NAME] to $RPM_DIRECTORY/$RPM_FULL_NAME"
else
echo ""
echo "[$SCRIPT_NAME] ERROR: failed to copy $TEMPORARY_BUILD_ROOT$BUILD_ROOT_RPMS_DIR/$ARCH/$RPM_FULL_NAME to $RPM_DIRECTORY/$RPM_FULL_NAME"
echo ""
fi
else
echo ""
echo "[$SCRIPT_NAME] ERROR: unable to find $TEMPORARY_BUILD_ROOT$BUILD_ROOT_RPMS_DIR/$ARCH/$RPM_FULL_NAME"
echo ""
fi
if [ -e $TEMPORARY_BUILD_ROOT$BUILD_ROOT_SRPMS_DIR/$SOURCE_RPM_FULL_NAME ]
then
echo "[$SCRIPT_NAME] copying $TEMPORARY_BUILD_ROOT$BUILD_ROOT_SRPMS_DIR/$SOURCE_RPM_FULL_NAME"
echo "[$SCRIPT_NAME] to $RPM_DIRECTORY"
cp $TEMPORARY_BUILD_ROOT$BUILD_ROOT_SRPMS_DIR/$SOURCE_RPM_FULL_NAME $RPM_DIRECTORY/$SOURCE_RPM_FULL_NAME
if [ -e $RPM_DIRECTORY/$SOURCE_RPM_FULL_NAME ]
then
echo "[$SCRIPT_NAME] copied $TEMPORARY_BUILD_ROOT$BUILD_ROOT_SRPMS_DIR/$SOURCE_RPM_FULL_NAME"
echo "[$SCRIPT_NAME] to $RPM_DIRECTORY/$SOURCE_RPM_FULL_NAME"
else
echo ""
echo "[$SCRIPT_NAME] ERROR: failed to copy $TEMPORARY_BUILD_ROOT$BUILD_ROOT_SRPMS_DIR/$SOURCE_RPM_FULL_NAME to $RPM_DIRECTORY/$SOURCE_RPM_FULL_NAME"
echo ""
fi
else
echo ""
echo "[$SCRIPT_NAME] ERROR: unable to find $TEMPORARY_BUILD_ROOT$BUILD_ROOT_SRPMS_DIR/$SOURCE_RPM_FULL_NAME"
echo ""
fi
echo ""
ls $RPM_DIRECTORY
cd $START_DIR
}
#----------------------------------------------------------------------------
# the MAIN routine
#---------------------------------------------------------------------------
START_DIR=`pwd`
if [ -z "$1" ]; then
# default BUILD_MODE
BUILD_MODE="local"
BUILD_TYPE="make"
else
BUILD_MODE=$1
if [ -z "$2" ]; then
# default BUILD_TYPE
if [ $BUILD_MODE == "local" ]; then
BUILD_TYPE="make"
fi
else
BUILD_TYPE=$2
fi
fi
echo ""
echo ""
echo ""
echo "************************************************************"
echo "[$SCRIPT_NAME] v$VERSION started"
echo "[$SCRIPT_NAME] running from: $START_DIR"
echo "[$SCRIPT_NAME] build mode = $BUILD_MODE"
echo "[$SCRIPT_NAME] build type = $BUILD_TYPE"
echo ""
# get $BUILD_ROOT environment variable
if [ "$BUILD_ROOT" == "" ]; then
BUILD_ROOT="/usr/src/packages"
fi
HOST_ARCH=`uname -a | grep -c x86_64`
if [ $HOST_ARCH -gt 0 ]
then ARCH=x86_64
else
ARCH=i586
fi
PACKAGE_NAME="yast2-CASA"
2006-04-14 22:38:26 +02:00
BUILD_ROOT_SPECS_DIR="$BUILD_ROOT/SPECS"
BUILD_ROOT_RPMS_DIR="$BUILD_ROOT/RPMS"
BUILD_ROOT_SRPMS_DIR="$BUILD_ROOT/SRPMS"
BUILD_ROOT_SOURCES_DIR="$BUILD_ROOT/SOURCES"
BUILD_ROOT_BUILD_DIR="$BUILD_ROOT/BUILD"
RPM_VERSION="1.6.0"
RPM_RELEASE="0"
RPM_DIRECTORY="$START_DIR/rpm"
TAR_DIRECTORY="$START_DIR/tar" w
LOG_DIRECTORY="$START_DIR/log"
PACKAGE_DIRECTORY="$START_DIR/package"
SPEC_FILE_DIRECTORY="$START_DIR/spec"
SPEC_FILE="$PACKAGE_NAME.spec"
SPEC_IN_FILE="$PACKAGE_NAME.spec.in"
POT_FILE="CASA.pot"
PO_FILE="CASA.po"
MO_FILE="CASA.mo"
2006-04-14 22:38:26 +02:00
validateCommandLineParams
validateRoot
getReleaseAndVersion
RPM_FILE="$PACKAGE_NAME-$RPM_VERSION-$RPM_RELEASE.$ARCH.rpm"
TAR_BZ2_FILE="$PACKAGE_NAME-$RPM_VERSION.tar.bz2"
if [ $BUILD_MODE == "local" ]
then
if [ $BUILD_TYPE == "make" ]
then
rpmBuild
else
echo ""
echo "[$SCRIPT_NAME] ERROR: invalud build type [$BUILD_TYPE] for build mode [$BUILD_MODE]"
echo ""
fi
fi
if [ $BUILD_MODE == "clean" ]
then
clean
fi
cd $START_DIR
echo ""
echo "************************************************************"
echo "[$SCRIPT_NAME] finished"
echo ""
exit