2 |
|
|
3 |
# get configuration |
# get configuration |
4 |
BUILDSERVER_CONFIG_DIR="/etc/mage-buildserver" |
BUILDSERVER_CONFIG_DIR="/etc/mage-buildserver" |
5 |
|
BUILDSERVER_CACHE_DIR="/var/cache/mage-buildserver" |
6 |
source ${BUILDSERVER_CONFIG_DIR}/buildserver.conf |
source ${BUILDSERVER_CONFIG_DIR}/buildserver.conf |
7 |
|
|
8 |
source ${BUILDSERVER_LIB_DIR}/buildserver-functions.sh |
source ${BUILDSERVER_LIB_DIR}/buildserver-functions.sh |
9 |
|
|
|
# override |
|
|
#BUILDROOT="/mnt/test-buildroot" |
|
|
#BUILD_ARCH=( x86_64 i686 ) |
|
|
#BUILDROOT_PROFILE="R11" |
|
|
#SMAGE_SVN_REPO="svn://cvs.magellan-linux.de/smage/trunk" |
|
|
#MAGE_SVN_REPO="svn://cvs.magellan-linux.de/mage/trunk" |
|
|
|
|
10 |
SMAGEFILE="$1" |
SMAGEFILE="$1" |
11 |
|
|
12 |
if [[ -z ${SMAGEFILE} ]] |
if [[ -z ${SMAGEFILE} ]] |
46 |
fi |
fi |
47 |
done |
done |
48 |
|
|
|
|
|
49 |
# create src package tarball |
# create src package tarball |
50 |
runarch src smage2 --create-src-tarball /var/cache/mage/smage/${SMAGEFILE} || die "src creating src-tarball" |
runarch src smage2 --create-src-tarball /var/cache/mage/smage/${SMAGEFILE} || die "src creating src-tarball" |
51 |
|
|
52 |
for arch in ${BUILD_ARCH[*]} |
for arch in $(enum-build-arch-types) |
53 |
do |
do |
54 |
echo "SMAGEFILE=\"${SMAGEFILE}\"" > ${BUILDROOT}/${arch}/.runrc |
echo "SMAGEFILE=\"${SMAGEFILE}\"" > ${BUILDROOT}/${arch}/.runrc |
55 |
cat >> ${BUILDROOT}/${arch}/.runrc << "EOF" |
echo "BUILDSERVER_LIB_DIR=\"${BUILDSERVER_LIB_DIR}\"" >> ${BUILDROOT}/${arch}/.runrc |
56 |
env-rebuild |
cat >> ${BUILDROOT}/${arch}/.runrc << 'EOF' |
|
source /etc/profile |
|
|
|
|
|
if [ -f /etc/rc.d/init.d/functions ] |
|
|
then |
|
|
source /etc/rc.d/init.d/functions |
|
|
else |
|
|
die "/etc/rc.d/init.d/functions not found" |
|
|
fi |
|
|
if [ -f /etc/mage.rc.global ] |
|
|
then |
|
|
source /etc/mage.rc.global |
|
|
else |
|
|
die "/etc/mage.rc.global not found" |
|
|
fi |
|
|
if [ -f /etc/mage.rc ] |
|
|
then |
|
|
source /etc/mage.rc |
|
|
else |
|
|
die "/etc/mage.rc not found" |
|
|
fi |
|
|
if [ -f ${MLIBDIR}/mage4.functions.sh ] |
|
|
then |
|
|
source ${MLIBDIR}/mage4.functions.sh |
|
|
else |
|
|
die "${MLIBDIR}/mage4.functions.sh not found" |
|
|
fi |
|
|
if [ -f ${MLIBDIR}/smage2.functions.sh ] |
|
|
then |
|
|
source ${MLIBDIR}/smage2.functions.sh |
|
|
else |
|
|
die "${MLIBDIR}/smage2.functions.sh not found" |
|
|
fi |
|
|
|
|
|
# override die function |
|
|
die() |
|
|
{ |
|
|
echo "ERROR: $@" |
|
|
return 1 |
|
|
} |
|
|
|
|
|
is_split_target_magefile() |
|
|
{ |
|
|
local mage="$1" |
|
|
|
|
|
for target_mage in ${MY_SPLIT_TARGET_MAGEFILES} |
|
|
do |
|
|
if [[ ${mage} = ${target_mage} ]] |
|
|
then |
|
|
return 0 |
|
|
fi |
|
|
done |
|
|
|
|
|
return 1 |
|
|
} |
|
|
|
|
|
load_mage_features |
|
|
mage_setup |
|
|
|
|
|
if [ -f /var/cache/mage/smage/${SMAGEFILE} ] |
|
|
then |
|
|
smagesource /var/cache/mage/smage/${SMAGEFILE} |
|
|
else |
|
|
die "smagefile '/var/cache/mage/smage/${SMAGEFILE}' not found." |
|
|
fi |
|
|
|
|
|
# save STATE, gets deleted by regen_mage_tree |
|
|
BUILDSERVER_SAVED_STATE="${STATE}" |
|
|
|
|
|
#regen_mage_tree # do this after dep install |
|
|
TARGET_MAGEFILE="${MAGEDIR}/${PCAT}/${PNAME}/${PNAME}-${PVER}-${PBUILD}.${MAGESUFFIX}" |
|
|
TARGET_SRC_TARBALL="/var/cache/mage/src-packages/${PNAME}-${PVER}-${PBUILD}.${SRCPKGSUFFIX}" |
|
|
|
|
|
if [ ! -f ${TARGET_SRC_TARBALL} ] |
|
|
then |
|
|
die "${TARGET_SRC_TARBALL} is missing" |
|
|
fi |
|
|
|
|
|
if is_installed ${PCAT}/${PNAME}-${PVER}-${PBUILD} |
|
|
then |
|
|
echo -en "Package " |
|
|
echo -en "${COLRED}${PCAT}/${PNAME}-${PVER}-${PBUILD}${COLDEFAULT}" |
|
|
echo -e " already installed. try a revup." |
|
|
exit 3 |
|
|
fi |
|
|
|
|
|
# get all dependencies of this package |
|
|
echo |
|
|
echo -n "Calculating dependencies ... " |
|
|
INSTALL_DEPS="$(${MLIBDIR}/depwalker.sh \ |
|
|
--method install-build-prerequisites \ |
|
|
--smage /var/cache/mage/smage/${SMAGEFILE})" |
|
|
|
|
|
# honor split packages |
|
|
if [[ -n ${SPLIT_PACKAGES} ]] |
|
|
then |
|
|
split_save_variables |
|
|
for subpackage in ${SPLIT_PACKAGES} |
|
|
do |
|
|
# get the right variables for the split |
|
|
export PNAME="${subpackage}" |
|
|
split_info_${PNAME} |
|
|
|
|
|
if [[ -z ${SRC_INSTALL_DEPS} ]] |
|
|
then |
|
|
SRC_INSTALL_DEPS="${MAGEDIR}/${PCAT}/${PNAME}/${PNAME}-${PVER}-${PBUILD}.${MAGESUFFIX}" |
|
|
else |
|
|
SRC_INSTALL_DEPS+=" ${MAGEDIR}/${PCAT}/${PNAME}/${PNAME}-${PVER}-${PBUILD}.${MAGESUFFIX}" |
|
|
fi |
|
|
# restore smage environment |
|
|
split_restore_variables |
|
|
done |
|
|
# unset all saved smage variables |
|
|
split_unset_variables |
|
|
else |
|
|
SRC_INSTALL_DEPS="${TARGET_MAGEFILE}" |
|
|
fi |
|
|
echo "done" |
|
|
|
|
|
echo |
|
|
echo "---- environment -----" |
|
|
echo "MROOT: ${FAKE_MROOT}" |
|
|
echo "PKGDIR: ${PKGDIR}" |
|
|
echo "BUILDDIR: ${BUILDDIR}" |
|
|
echo "BINDIR: ${BINDIR}" |
|
|
echo "$(mprintfeatures)" |
|
|
echo "----------------------" |
|
|
echo |
|
|
echo "---- dependencies ----" |
|
|
echo "INSTALL_DEPS:" |
|
|
for i in ${INSTALL_DEPS} |
|
|
do |
|
|
echo " * ${i}" |
|
|
done |
|
|
echo "SRC_INSTALL_DEPS:" |
|
|
for i in ${SRC_INSTALL_DEPS} |
|
|
do |
|
|
echo " * ${i}" |
|
|
done |
|
|
echo "----------------------" |
|
|
|
|
|
echo "DEBUG: paused"; read |
|
|
|
|
|
# override packages path |
|
|
SAVED_PKGDIR="${PKGDIR}" |
|
|
PKGDIR="/var/cache/mage/tmp-packages" |
|
|
install -d "${PKGDIR}" |
|
|
|
|
|
# now install the packages (no srcinstall, when the user not explcitly want this) |
|
|
fetch_packages ${INSTALL_DEPS} || die "fetching packages" |
|
|
md5sum_packages ${INSTALL_DEPS} || die "md5 sum packages" |
|
|
unpack_packages ${INSTALL_DEPS} || die "unpacking packages" |
|
|
install_packages ${INSTALL_DEPS} || die "installing packages" |
|
|
cleanpkg |
|
|
# restore packages path |
|
|
PKGDIR="${SAVED_PKGDIR}" |
|
|
|
|
|
## always run auto etc-update |
|
|
echo "running etc-update" |
|
|
echo "-5" | etc-update |
|
|
|
|
|
#### building target package from src-pkg tarball#### |
|
|
if smage2 --src-tarball ${TARGET_SRC_TARBALL} |
|
|
then |
|
57 |
build_retval=0 |
build_retval=0 |
58 |
echo "Build successfull!" |
${BUILDSERVER_LIB_DIR}/buildserver-build-depends.sh ${SMAGEFILE} || exit 1 |
59 |
regen_mage_tree |
${BUILDSERVER_LIB_DIR}/buildserver-build-install-prerequisites.sh ${SMAGEFILE} |
60 |
if install_packages ${SRC_INSTALL_DEPS} || die "installing packages" |
${BUILDSERVER_LIB_DIR}/buildserver-build.sh ${SMAGEFILE} || build_retval=1 |
61 |
then |
${BUILDSERVER_LIB_DIR}/buildserver-build-uninstall-prerequisites.sh ${SMAGEFILE} |
|
install_retval=0 |
|
|
echo "Install successfull!" |
|
|
else |
|
|
install_retval=1 |
|
|
echo "Installation *not* successfull!" |
|
|
fi |
|
|
else |
|
|
build_retval=1 |
|
|
echo "Build failed" |
|
|
fi |
|
|
|
|
|
## always run auto etc-update |
|
|
echo "running etc-update" |
|
|
echo "-5" | etc-update |
|
|
|
|
|
#reverse dep order |
|
|
unset REV_INSTALL_DEPS |
|
|
for dep in ${INSTALL_DEPS} |
|
|
do |
|
|
if [[ -z ${REV_INSTALL_DEPS} ]] |
|
|
then |
|
|
REV_INSTALL_DEPS="${dep}" |
|
|
else |
|
|
REV_INSTALL_DEPS="${dep} ${REV_INSTALL_DEPS}" |
|
|
fi |
|
|
done |
|
|
|
|
|
# remove all previously installed packages |
|
|
echo |
|
|
echo "Cleaning buildroot - removing previously installed packages in reversed order:" |
|
|
echo "---- dependencies ----" |
|
|
echo "SRC_INSTALL_DEPS:" |
|
|
for i in ${SRC_INSTALL_DEPS} |
|
|
do |
|
|
echo " * ${i}" |
|
|
done |
|
|
echo "INSTALL_DEPS:" |
|
|
for i in ${REV_INSTALL_DEPS} |
|
|
do |
|
|
echo " * ${i}" |
|
|
done |
|
|
echo "----------------------" |
|
|
|
|
|
for pkg in ${SRC_INSTALL_DEPS} ${REV_INSTALL_DEPS} |
|
|
do |
|
|
uninstall_list="" |
|
|
pname="$(magename2pname ${pkg})" |
|
|
pcat="$(magename2pcat ${pkg})" |
|
|
pver="$(magename2pver ${pkg})" |
|
|
pbuild="$(magename2pbuild ${pkg})" |
|
|
if is_installed ${pcat}/${pname}-${pver}-${pbuild} |
|
|
then |
|
|
if [[ -z ${uninstall_list} ]] |
|
|
then |
|
|
uninstall_list="${pcat}/${pname}-${pver}-${pbuild}" |
|
|
else |
|
|
uninstall_list="${uninstall_list} ${pcat}/${pname}-${pver}-${pbuild}" |
|
|
fi |
|
|
else |
|
|
echo "'${pcat}/${pname}-${pver}-${pbuild}' not installed - ignoring" |
|
|
fi |
|
|
if [[ -n ${uninstall_list} ]] |
|
|
then |
|
|
uninstall_packages "${uninstall_list}" || die "cleaning buildroot: ${pkg}" |
|
|
else |
|
|
echo "uninstall_list is empty for pkg '${pcat}/${pname}-${pver}-${pbuild}' - doing nothing" |
|
|
fi |
|
|
done |
|
62 |
|
|
63 |
exit ${build_retval} |
exit ${build_retval} |
64 |
EOF |
EOF |
65 |
runarch-script ${arch} .runrc || die "${arch} package build failed" |
runarch-script ${arch} .runrc || die "${arch} package build failed" |
66 |
if [ -f ${BUILDROOT}/${arch}/.runrc ] |
if [ -f ${BUILDROOT}/${arch}/.runrc ] |