2006-08-12 14:34:01 +02:00
|
|
|
|
#!/bin/bash
|
2006-07-16 12:29:37 +02:00
|
|
|
|
#
|
|
|
|
|
# $Id$
|
2006-08-12 14:34:01 +02:00
|
|
|
|
#
|
|
|
|
|
set -e
|
|
|
|
|
|
2013-10-29 16:42:03 +01:00
|
|
|
|
declare TOPDIR='..'
|
|
|
|
|
declare ATOPDIR=`cd $TOPDIR; pwd`
|
2006-08-12 14:34:01 +02:00
|
|
|
|
declare MKFILE=Makefile
|
2006-07-16 12:29:37 +02:00
|
|
|
|
declare PREV_PACKAGE=""
|
2013-10-29 16:42:03 +01:00
|
|
|
|
declare BUILD_SCRIPTS=${TOPDIR}/scripts
|
|
|
|
|
declare TRACKING_FILE=tracking-dir/instpkg.xml
|
|
|
|
|
declare XSLDIR=${TOPDIR}/xsl
|
|
|
|
|
declare PACK_FILE=${TOPDIR}/packages.xml
|
|
|
|
|
declare BUMP=${XSLDIR}/bump.xsl
|
2006-07-16 12:29:37 +02:00
|
|
|
|
|
2006-10-11 21:35:34 +02:00
|
|
|
|
HEADER="# This file is automatically generated by gen-makefile.sh
|
2006-08-12 14:34:01 +02:00
|
|
|
|
# YOU MAY NEED TO EDIT THIS FILE MANUALLY
|
|
|
|
|
#
|
|
|
|
|
# Generated on `date \"+%F %X %Z\"`"
|
|
|
|
|
|
2006-07-16 12:29:37 +02:00
|
|
|
|
|
|
|
|
|
#----------------------------------#
|
|
|
|
|
__wrt_target() { # Create target and initialize log file
|
|
|
|
|
#----------------------------------#
|
|
|
|
|
local i=$1
|
|
|
|
|
local PREV=$2
|
|
|
|
|
(
|
|
|
|
|
cat << EOF
|
|
|
|
|
|
|
|
|
|
$i: $PREV
|
|
|
|
|
@\$(call echo_message, Building)
|
2007-07-26 21:40:24 +02:00
|
|
|
|
@/bin/bash progress_bar.sh \$@ \$\$PPID &
|
2006-07-16 12:29:37 +02:00
|
|
|
|
EOF
|
|
|
|
|
) >> $MKFILE.tmp
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#----------------------------------#
|
|
|
|
|
__write_build_cmd() { #
|
|
|
|
|
#----------------------------------#
|
|
|
|
|
(
|
|
|
|
|
cat << EOF
|
2013-10-29 16:42:03 +01:00
|
|
|
|
@source ${TOPDIR}/envars.conf && ${BUILD_SCRIPTS}/\$@ >logs/\$@ 2>&1
|
2006-07-16 12:29:37 +02:00
|
|
|
|
EOF
|
|
|
|
|
) >> $MKFILE.tmp
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#----------------------------------#
|
|
|
|
|
__wrt_touch() { #
|
|
|
|
|
#----------------------------------#
|
|
|
|
|
local pkg_name=$1
|
2006-08-24 22:38:22 +02:00
|
|
|
|
|
|
|
|
|
(
|
|
|
|
|
cat << EOF
|
2013-10-29 16:42:03 +01:00
|
|
|
|
@xsltproc --stringparam packages ${PACK_FILE} \\
|
|
|
|
|
--stringparam package ${pkg_name#*-?-} \\
|
|
|
|
|
-o track.tmp \\
|
|
|
|
|
${BUMP} \$(TRACKING_FILE) && \\
|
|
|
|
|
sed -i 's@PACKDESC@${ATOPDIR}/packdesc.dtd@' track.tmp && \\
|
|
|
|
|
xmllint --format --postvalid track.tmp > \$(TRACKING_FILE) && \\
|
|
|
|
|
rm track.tmp && \\
|
|
|
|
|
touch \$@ && \\
|
2006-07-16 12:29:37 +02:00
|
|
|
|
sleep .25 && \\
|
|
|
|
|
echo -e "\n\n "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
|
|
|
|
|
echo --------------------------------------------------------------------------------\$(WHITE)
|
|
|
|
|
EOF
|
|
|
|
|
) >> $MKFILE.tmp
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#----------------------------#
|
|
|
|
|
__write_entry() { #
|
|
|
|
|
#----------------------------#
|
|
|
|
|
local script_name=$1
|
2006-08-24 22:38:22 +02:00
|
|
|
|
|
2006-07-16 12:29:37 +02:00
|
|
|
|
echo -n "${tab_}${tab_} entry for <$script_name>"
|
|
|
|
|
|
|
|
|
|
#--------------------------------------------------------------------#
|
|
|
|
|
# >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
|
|
|
|
#--------------------------------------------------------------------#
|
|
|
|
|
#
|
|
|
|
|
# Drop in the name of the target on a new line, and the previous target
|
|
|
|
|
# as a dependency. Also call the echo_message function.
|
|
|
|
|
__wrt_target "${script_name}" "$PREV_PACKAGE"
|
2006-08-12 15:19:29 +02:00
|
|
|
|
__write_build_cmd
|
2006-07-16 12:29:37 +02:00
|
|
|
|
|
|
|
|
|
# Include a touch of the target name so make can check
|
|
|
|
|
# if it's already been made.
|
2013-10-29 16:42:03 +01:00
|
|
|
|
__wrt_touch "${script_name}"
|
2006-07-16 12:29:37 +02:00
|
|
|
|
#
|
|
|
|
|
#--------------------------------------------------------------------#
|
|
|
|
|
# >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
|
|
|
|
#--------------------------------------------------------------------#
|
|
|
|
|
echo " .. OK"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#----------------------------#
|
|
|
|
|
generate_Makefile () { #
|
|
|
|
|
#----------------------------#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
echo "${tab_}Creating Makefile... ${BOLD}START${OFF}"
|
|
|
|
|
|
|
|
|
|
# Start with a clean files
|
|
|
|
|
>$MKFILE
|
|
|
|
|
>$MKFILE.tmp
|
|
|
|
|
|
2006-08-12 14:34:01 +02:00
|
|
|
|
|
2013-10-29 16:42:03 +01:00
|
|
|
|
for package_script in ${BUILD_SCRIPTS}/* ; do
|
2006-07-16 12:29:37 +02:00
|
|
|
|
this_script=`basename $package_script`
|
2006-08-24 22:38:22 +02:00
|
|
|
|
pkg_list="$pkg_list ${this_script}"
|
2013-10-29 16:42:03 +01:00
|
|
|
|
__write_entry "${this_script}"
|
2006-08-24 22:38:22 +02:00
|
|
|
|
PREV_PACKAGE=${this_script}
|
2006-07-16 12:29:37 +02:00
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
(
|
|
|
|
|
cat << EOF
|
|
|
|
|
$HEADER
|
|
|
|
|
|
2013-10-29 16:42:03 +01:00
|
|
|
|
TRACKING_FILE= $TRACKING_FILE
|
2006-07-16 12:29:37 +02:00
|
|
|
|
|
|
|
|
|
BOLD= "[0;1m"
|
|
|
|
|
RED= "[1;31m"
|
|
|
|
|
GREEN= "[0;32m"
|
|
|
|
|
ORANGE= "[0;33m"
|
|
|
|
|
BLUE= "[1;34m"
|
|
|
|
|
WHITE= "[00m"
|
|
|
|
|
|
|
|
|
|
define echo_message
|
|
|
|
|
@echo \$(BOLD)
|
|
|
|
|
@echo --------------------------------------------------------------------------------
|
|
|
|
|
@echo \$(BOLD)\$(1) target \$(BLUE)\$@\$(BOLD)
|
|
|
|
|
@echo \$(WHITE)
|
|
|
|
|
endef
|
|
|
|
|
|
|
|
|
|
|
2013-10-29 16:42:03 +01:00
|
|
|
|
define end_message
|
2006-07-16 12:29:37 +02:00
|
|
|
|
@echo \$(BOLD)
|
|
|
|
|
@echo --------------------------------------------------------------------------------
|
|
|
|
|
@echo \$(BOLD) Build complete for the package \$(BLUE)\$(PACKAGE)\$(BOLD) and its dependencies
|
|
|
|
|
@echo \$(WHITE)
|
|
|
|
|
endef
|
|
|
|
|
|
|
|
|
|
all : $pkg_list
|
2013-10-29 16:42:03 +01:00
|
|
|
|
@\$(call end_message )
|
2006-07-16 12:29:37 +02:00
|
|
|
|
EOF
|
|
|
|
|
) > $MKFILE
|
|
|
|
|
|
|
|
|
|
cat $MKFILE.tmp >> $MKFILE
|
|
|
|
|
echo "${tab_}Creating Makefile... ${BOLD}DONE${OFF}"
|
|
|
|
|
|
|
|
|
|
rm $MKFILE.tmp
|
|
|
|
|
|
|
|
|
|
}
|
2006-08-12 14:34:01 +02:00
|
|
|
|
|
2013-10-29 16:42:03 +01:00
|
|
|
|
if [[ ! -d ${BUILD_SCRIPTS} ]] ; then
|
2016-06-19 16:41:18 +02:00
|
|
|
|
echo -e "\n\tThe '${BUILD_SCRIPTS}' directory has not been found.\n"
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# Let us make a clean base, but first ensure that we are
|
|
|
|
|
# not emptying a useful directory.
|
|
|
|
|
MYDIR=$(pwd)
|
|
|
|
|
MYDIR=$(basename $MYDIR)
|
|
|
|
|
if [ "${MYDIR#work}" = "${MYDIR}" ] ; then
|
|
|
|
|
echo -e \\n\\tDirectory ${BOLD}$MYDIR${OFF} does not begin with \"work\"\\n
|
2006-10-11 21:35:34 +02:00
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
2013-10-29 16:42:03 +01:00
|
|
|
|
rm -rf *
|
2006-10-11 21:35:34 +02:00
|
|
|
|
|
2006-08-12 14:34:01 +02:00
|
|
|
|
generate_Makefile
|
|
|
|
|
|
2013-10-29 16:42:03 +01:00
|
|
|
|
cp ${TOPDIR}/progress_bar.sh .
|
2006-08-12 14:34:01 +02:00
|
|
|
|
|
|
|
|
|
mkdir -p logs
|