Skip to content
Permalink
43cbac1d0b
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
1119 lines (887 sloc) 30.5 KB
#!/bin/bash
#
# beesh - bee-file interpreter - the main brain
#
# Copyright (C) 2009-2016
# Marius Tolzmann <m@rius.berlin>
# Matthias Ruester <matthias.ruester@gmail.com>
# Tobias Dreyer <dreyer@molgen.mpg.de>
# and other bee developers
#
# This file is part of bee.
#
# bee is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
set -e
#architecture
ARCH=$(uname -m)
# Version
BEE_VERSION="@BEE_VERSION@"
VERSION=${BEE_VERSION}
: ${BEE_SYSCONFDIR:=@SYSCONFDIR@}
: ${BEE_DEFCONFDIR:=@DEFCONFDIR@}
: ${BEE_DATADIR:=@DATADIR@}
: ${BEE_LIBDIR:=@LIBDIR@}
: ${BEE_LIBEXECDIR:=@LIBEXECDIR@}
: ${BEE_BINDIR:=@BINDIR@}
: ${BEEFIND:=${BEE_BINDIR}/beefind}
: ${BEEVERSION:=${BEE_BINDIR}/beeversion}
: ${BEESORT:=${BEE_BINDIR}/beesort}
# load libs
. ${BEE_LIBEXECDIR}/bee/beelib.config.sh
umask 022
function bee-cache() {
${BEE_LIBEXECDIR}/bee/bee.d/bee-cache "${@}"
}
function bee-install() {
${BEE_LIBEXECDIR}/bee/bee.d/bee-install "${@}"
}
###############################################################################
###############################################################################
###############################################################################
function log_enter() {
print_info "=> entering ${@} .."
}
function log_leave() {
print_info "<= leaving ${@} .."
}
function start_cmd() {
print_info "${COLOR_CYAN}${@}"
"${@}"
}
###############################################################################
###############################################################################
###############################################################################
#### create_meta() ############################################################
function create_meta() {
echo >> "${D}/META" "BEEMETAFORMAT=2"
echo >> "${D}/META" "BEEPKG='${PKGALLPKG}'"
for var in prefix eprefix bindir sbindir libexecdir sysconfdir \
sharedstatedir localstatedir libdir includedir \
datarootdir datadir infodir localedir mandir docdir ; do
eval eval echo PKG_${var^^}=\${${var^^}} >> "${D}/META"
done
}
#### show_help() ##############################################################
function show_help() {
cat <<-EOF
beesh v${VERSION} 2009-2016
by Marius Tolzmann <m@rius.berlin>
Matthias Ruester <matthias.ruester@gmail.com>
Tobias Dreyer <dreyer@molgen.mpg.de>
Usage: beesh [options] <pkg>.bee
Options:
-c, --cleanup may be used to clean up <pkg>-related
directory tree before build process is started
-i, --install after build process is successful and <pkg> is
built, <pkg>.tgz is installed by bee_install
-f, --force-install same as -i; bee_install is invoked with --force
-h, --help display this help
--no-archive-build do not archive the build directory
--check run mee_check, mee_check_pre and mee_check_post
EOF
}
function disable_autoexclusion() {
unset BEE_AUTO_EXCLUDE
}
function require_version() {
if "${BEE_BINDIR}/beeversion" "${VERSION}" -lt "${1}" ; then
print_error "this bee-file requires at least bee v${1} .."
exit 1;
fi
}
function check_rebuild() {
local beefile=${1}
local beepkgallpkg=${2}
local error=0
if [ -f "${BEE_PKGDIR}/${beepkgallpkg}.bee.tar.bz2" ] ; then
print_warning "package already exists: ${BEE_PKGDIR}/${beepkgallpkg}.bee.tar.bz2"
error=1
fi
if [ -f "${BEE_BEEDIR}/${beefile##*/}" ] ; then
print_warning "bee-file already exists: ${BEE_BEEDIR}/${beefile##*/}"
error=1
fi
if [ "${error}" = "0" ] ; then
return 0
fi
print_warning "please increase revision number"
eval $(${BEEVERSION} "${beefile}")
beefile_pattern="${PKGFULLNAME}-${PKGFULLVERSION}"
shopt -s extglob
beefile_max=$( ls "${beefile%/*}/${beefile_pattern}"-+([0-9]).bee "${BEE_BEEDIR}/${beefile_pattern}"-+([0-9]).bee 2>/dev/null | ${BEESORT} | tail -1)
eval $(${BEEVERSION} ${beefile_max})
print_warning "cp ${beefile} ${PWD}/${PKGFULLNAME}-${PKGFULLVERSION}-$((PKGREVISION + 1)).bee"
exit 1
}
function check_repositories() {
r=0
print_info "==> checking repositories .."
mkdir -pv "${BEE_BEEDIR}"
mkdir -pv "${BEE_PKGDIR}"
mkdir -pv "${BEE_BUILDARCHIVEDIR}"
if [ ! -w "${BEE_BEEDIR}" ] ; then
print_error " !! ${BEE_BEEDIR} not writable"
r=1
fi
if [ ! -w "${BEE_PKGDIR}" ] ; then
print_error " !! ${BEE_PKGDIR} not writable"
r=1
fi
if [ ! -w "${BEE_BUILDARCHIVEDIR}" ] ; then
print_error " !! ${BEE_BUILDARCHIVEDIR} not writable"
r=1
fi
if [ "$r" != "0" ] ; then
exit 1
fi
}
function build_in_sourcedir() {
B=${S}
}
function add_sourcesubdir() {
print_warning "WARNING: add_sourcesubdir is deprecated in favor of sourcesubdir_append"
sourcesubdir_append "${@}"
}
function sourcesubdir_set() {
BEE_SOURCESUBDIR="${1}"
}
function sourcesubdir_prepend() {
BEE_SOURCESUBDIR="${1}${BEE_SOURCESUBDIR:+/${BEE_SOURCESUBDIR}}"
}
function sourcesubdir_append() {
BEE_SOURCESUBDIR="${BEE_SOURCESUBDIR:+${BEE_SOURCESUBDIR}/}${1}"
}
#### bee_init_builddir() ######################################################
function bee_init_builddir() {
print_info "==> initializing build environment .."
if [ -d "${BEEWORKDIR}" ] ; then
if [ "${OPT_CLEANUP}" = "yes" ] ; then
print_info " -> cleaning work dir ${BEEWORKDIR} .."
rm -fr "${BEEWORKDIR}"
else
print_error "error initializing build-dir ${BEEWORKDIR}"
print_error "please use -c to force a cleanup."
exit 1
fi
fi
print_info " -> creating source dir ${S}"
mkdir -p "${S}"
print_info " -> creating image dir ${D}"
mkdir -p "${D}"
}
function bee_init_buildinsourcedir() {
if [ "${B}" == "${S}" ] ; then
link=${BEEWORKDIR}/build
print_info " -> B=S linking build dir ${link} to source dir"
ln -s "${S#${BEEWORKDIR}/}" "${link}"
else
print_info " -> creating build dir ${B}"
mkdir -p "${B}"
fi
}
#### bee_getsources() #########################################################
# fetch_one_file <url> [filename]
function fetch_one_file() {
local url="${1}"
local file="${2}"
local guessed_filename="${url##*/}"
guessed_filename=${guessed_filename%%\?*}
guessed_filename=${guessed_filename%%#*}
guessed_filename=${guessed_filename%/}
: ${file:=${guessed_filename}}
if [ "${url:0:8}" = "file:///" ] ; then
url=${url:7}
fi
if [ "${url:0:1}" = "/" ] ; then
print_info "copying file ${url}"
cp --no-preserve=mode -v "${url}" "${F}/${file}"
else
if [ "${url:0:5}" == "https" ] ; then
nocheck="--no-check-certificate"
else
nocheck=""
fi
if [ ! -s "${F}/${file}" ] ; then
rm -vf "${F}/${file}"
fi
trap "rm -f ${F}/${file}" EXIT
print_info "fetching $url"
wget \
${nocheck} \
--output-document="${F}/${file}" \
--no-clobber \
--timeout=60 \
--tries=1 \
"${url}" || true
trap - EXIT
ls -ld "${F}/${file}"
fi
bee_FETCHED_FILE="${F}/${file}"
bee_FETCHED_FILES=( ${bee_FETCHED_FILES[@]} "${F}/${file}" )
}
function fetch_one_archive() {
fetch_one_file "$@"
bee_SOURCEFILES=( ${bee_SOURCEFILES[@]} ${bee_FETCHED_FILE} )
}
function fetch_one_patch() {
fetch_one_file "$@"
if [ "${bee_FETCHED_FILE: -3:3}" = ".gz" ] ; then
if gunzip "${bee_FETCHED_FILE}" -c >"${bee_FETCHED_FILE%.gz}" ; then
bee_FETCHED_FILE=${bee_FETCHED_FILE%.gz}
print_info "patch (compressed by gzip) was uncompressed and saved as ${bee_FETCHED_FILE}"
fi
elif [ "${bee_FETCHED_FILE: -4:4}" = ".bz2" ] ; then
if bunzip2 "${bee_FETCHED_FILE}" -c >"${bee_FETCHED_FILE%.bz2}" ; then
bee_FETCHED_FILE=${bee_FETCHED_FILE%.bz2}
print_info "patch (compressed by bzip2) was uncompressed and saved as ${bee_FETCHED_FILE}"
fi
elif [ "${bee_FETCHED_FILE: -3:3}" = ".xz" ] ; then
if unxz "${bee_FETCHED_FILE}" -c >"${bee_FETCHED_FILE%.xz}" ; then
bee_FETCHED_FILE=${bee_FETCHED_FILE%.xz}
print_info "patch (compressed by xz) was uncompressed and saved as ${bee_FETCHED_FILE}"
fi
fi
bee_PATCHFILES=( ${bee_PATCHFILES[@]} ${bee_FETCHED_FILE} )
}
function bee_getsrcurl() {
local -a archives=( "${@}" )
local url filename
for a in "${archives[@]}" ; do
read -r url filename <<< "${a}"
fetch_one_archive "${url}" "${filename}"
done
}
function bee_getpatchurl() {
local -a patches=( "${@}" )
local url filename
for p in "${patches[@]}" ; do
read -r url filename <<< "${p}"
fetch_one_patch "${url}" "${filename}"
done
}
# bee_getsources
# SRCURL[] = "<url> [filename]"
# e.g.:
# SRCURL=("<url> [filename]" "<url> [filename]")
# SRCURL="<url> [filename]"
# SRCURL[0]="<url> [filename]"
# SRCURL[1]="<url> [filename]"
function bee_getsources() {
mkdir -p "${F}"
if [ -z "${SRCURL}" ] ; then
unset SRCURL
fi
bee_getsrcurl "${SRCURL[@]}"
if [ -z "${PATCHURL}" ] ; then
unset PATCHURL
fi
if [ -z "${PATCHES}" ] ; then
unset PATCHES
fi
if [ -z "${PATCHURL}" ] && [ -n "${PATCHES}" ] ; then
print_error 'warning .. you are using deprecated variable ${PATCHES} .. please use ${PATCHURL} instead'
PATCHURL=( "${PATCHES[@]}" )
fi
bee_getpatchurl "${PATCHURL[@]}"
}
#### bee_extract() #############################################################
function bee_extract_do_zip() {
local file="${1}"
local dest="${2}"
local -a list
shift 2
start_cmd unzip -q -o "${file}" -d "${dest}" "${@}"
readarray -t list < <(ls -a "${dest}" | grep -vE '^\.(\.|)$' | head -2)
if [ "${#list[@]}" = "1" ] ; then
sourcesubdir_prepend "${list[0]}"
fi
}
function bee_extract_do_tar() {
local file="${1}"
local dest="${2}"
shift 2
start_cmd tar xof "${file}" -C "${dest}" "${@}"
}
function bee_extract_do_tar0() {
bee_extract_do_tar "${@}" --strip-components "${BEE_EXTRACT_STRIP}"
}
function get_or_guess_mimetype() {
local file="${1}"
local mimetype=""
if ! mimetype=$(file --mime --brief "${file}" 2>/dev/null) ; then
if [ "${file: -4}" = ".zip" ] ; then
mimetype="application/zip"
fi
fi
echo ${mimetype%%;*}
}
function bee_extract_do() {
local file="${1}"
local dest="${2}"
local mode="${3}"
local mimetype=""
shift 3
mimetype=$(get_or_guess_mimetype "${file}")
if [ "${mimetype}" = "application/zip" ] ; then
bee_extract_do_zip "${file}" "${dest}"
return
fi
if [ "${mode}" = "primary" ] ; then
bee_extract_do_tar0 "${file}" "${dest}"
else
bee_extract_do_tar "${file}" "${dest}"
fi
}
function bee_extract() {
local bee_S
bee_S=( "$@" )
: ${BEE_EXTRACT_STRIP:=1}
if is_func mee_unpack ; then
print_error "#BEE-WARNING# function 'mee_unpack()' is deprecated .. use 'mee_extract()' instead .." >&2
mee_unpack "${@}"
return
fi
if [ -z "${bee_S[0]}" ] ; then
return
fi
# get first source archive and remove it from source archive array
s=${bee_S[0]}
unset bee_S[0]
print_info " -> extracting main source ${s} .."
bee_extract_do "${s}" "${S}" "primary"
for s in "${bee_S[@]}" ; do
print_info " -> extracting additional source ${s} .."
bee_extract_do "${s}" "${S}" "secondary"
done
print_info " -> all sources extracted to: ${S} .."
}
#### bee_patch() ##############################################################
function bee_patch() {
local bee_P
bee_P=( "$@" )
if [ "${#bee_P[@]}" == "0" ] ; then
bee_P=( ${bee_PATCHFILES[@]} )
fi
for p in "${bee_P[@]}" ; do
striplevel=1
for i in 1 0 2 3 4 5 6 7 8 9 ; do
if patch --dry-run -N -p$i -i "${p}" >/dev/null 2>&1 ; then
striplevel=$i
print_info "bee_patch(): ${p##*/}: guessed patch striplevel of ${striplevel} .."
break
fi
done
start_cmd patch -N -p${striplevel} -i "${p}"
done
}
function bee_dummy() {
info=( $(caller 0) )
if [ ! -z "${@}" ] ; then
print_error "ERROR: ${info[1]} is empty but is used with arguments in bee-file."
exit 1
else
print_info "action '${info[1]}' is not defined: skipping.."
fi
}
#### bee_configure() ##########################################################
function bee_configure() {
bee_dummy "${@}"
}
#### bee_build() ##############################################################
function bee_build() {
bee_dummy "${@}"
}
#### bee_install() ############################################################
function bee_install() {
bee_dummy "${@}"
}
#### bee_crosscheck() #########################################################
function bee_crosscheck() {
directories=( $(find "${D}" -type d -printf "/%P\n") )
for d in ${directories[@]} ; do
if [ ! -e "${d}" -o -d "${d}" -a ! -L "${d}" ] ; then
# its ok
continue
fi
print_warning "WARNING: system and image files named '${d}' differ"
print_warning " image : $(file -b "${D}${d}")"
print_warning " system: $(file -b "${d}")"
done
links=( $(find "${D}" -type l -printf "%p\n") )
for imagefilename in "${links[@]}" ; do
target="$(readlink "${imagefilename}")"
if [ "${target#${D}}" != "${target}" ] ; then
print_warning "WARNING: image: target of ${imagefilename#${D}} contains path to image directory"
imagetarget="${target}"
elif [ "${target:0:1}" = "/" ] ; then
imagetarget="${D}${target}"
else
imagetarget="${imagefilename%/*}/${target}"
fi
if [ ! -d "${imagetarget}" ] ; then
# dont care
continue
fi
systemfilename="${imagefilename#${D}}"
if [ ! -e "${systemfilename}" ] ; then
# its ok
continue
fi
if [ -L "${systemfilename}" ] ; then
target="$(readlink "${systemfilename}")"
if [ "${target:0:1}" = "/" ] ; then
systemtarget=${target}
else
systemtarget="${systemfilename%/*}/${target}"
fi
if [ -d "${systemtarget}" -a "${imagetarget#${D}}" = "${systemtarget}" ] ; then
#its ok
continue
fi
fi
print_warning "WARNING: system and image files named '${systemfilename}' differ"
print_warning " image : $(file -b "${imagefilename}")"
print_warning " system: $(file -b "${systemfilename}")"
done
}
#### bee_pkg_pack() ###########################################################
# $EXCLUDE is read from .bee file
# $BEE_SKIPLIST is found in $BEEFAULTS
function bee_pkg_pack() {
${BEEFIND} --exclude='^/CONTENT$' \
--exclude-list=<(
if [ -n "${BEE_SKIPLIST}" ] ; then
cat "${BEE_SKIPLIST}"
fi
for pattern in "${EXCLUDE[@]}" "${BEE_AUTO_EXCLUDE[@]}" ; do
echo "${pattern}"
done ) \
--cutroot \
"${D}" | \
"${BEE_LIBEXECDIR}/bee/filelist2content" --root "${D}" > "${D}/CONTENT"
if [ ! -s "${D}/CONTENT" ]; then
print_error "ERROR: empty image directory"
exit 1
fi
cp --no-preserve=mode "${BEE}" "${D}/BUILD"
create_meta
if [ -n "${bee_PATCHFILES[0]}" ] ; then
mkdir -pv "${D}/PATCHES"
fi
for p in "${bee_PATCHFILES[@]}" ; do
cp --no-preserve=mode "${p}" "${D}/PATCHES"
done
if [ ! -d "${BEE_PKGDIR}" ] ; then
mkdir -pv "${BEE_PKGDIR}"
fi
pkgname=${PKGALLPKG}.bee.tar.bz2
pkgfile=${BEE_PKGDIR}/${pkgname}
print_info " -> creating package ${pkgname} .."
print_info "${COLOR_CYAN}${pkgfile}"
rm -f "${pkgfile}.tmp"
tar cjvvf "${pkgfile}.tmp" \
--transform="s,${D},," \
--show-transformed-names \
--sparse \
--absolute-names \
--no-recursion \
--transform="s,^/CONTENT$,CONTENT," \
--transform="s,^/BUILD$,BUILD," \
--transform="s,^/META$,META," \
--transform="s,^/PATCHES,PATCHES," \
${D}/{CONTENT,BUILD,META} \
${bee_PATCHFILES:+${D}/PATCHES} \
${bee_PATCHFILES:+${D}/PATCHES/*} \
-T <( "${BEE_LIBEXECDIR}/bee/content2filelist" \
--prepend="${D}" \
"${D}/CONTENT" )
mv "${pkgfile}.tmp" "${pkgfile}"
beefilename=${BEE##*/}
beefiledest=${BEE_BEEDIR}/${PKGFULLPKG}.bee
print_info "-> saving bee-file ${beefilename} .."
print_info "${COLOR_CYAN}${beefiledest}"
if [ ! -d "${BEE_BEEDIR}" ] ; then
mkdir -pv "${BEE_BEEDIR}"
fi
cp --no-preserve=mode -v "${BEE}" "${beefiledest}"
}
function bee_archivebuild() {
[ "${OPT_ARCHIVE_BUILD}" != "yes" ] && return
if [ ! -d "${BEE_BUILDARCHIVEDIR}" ] ; then
mkdir -pv "${BEE_BUILDARCHIVEDIR}"
fi
archive="${BEE_BUILDARCHIVEDIR}/${PKGALLPKG}.beebuild.tar.bz2"
print_info " -> saving build environment.."
print_info "${COLOR_CYAN}${archive}"
if [ "${B}" = "${S}" ] ; then
B=${BEEWORKDIR}/build
fi
tar -cjf ${archive} \
--show-transformed-names \
--sparse \
--absolute-names \
"${S}" "${B}" \
"${bee_FETCHED_FILES[@]}" \
"${BEE_BEEDIR}/${PKGFULLPKG}.bee" \
--transform="s,^${BEEWORKDIR},${PKGALLPKG}," \
--transform="s,^${F},${PKGALLPKG}/files," \
--transform="s,^${BEE_BEEDIR},${PKGALLPKG}/files,"
}
function load_buildmagic() {
local oIFS=${IFS}
local IFS=":${IFS}"
local magic=$1
if [ ! -z "${BEE_BUILDTYPE_DETECTED}" ] ; then
return
fi
for dir in ${XDG_CONFIG_HOME} ${XDG_CONFIG_DIRS} ${BEE_LIBEXECDIR} ; do
local IFS=${oIFS}
xdgmagic="${dir}/bee/beesh.d/${magic}.sh"
if [ -r "${xdgmagic}" ] ; then
. "${xdgmagic}"
if [ ! -z "${BEE_BUILDTYPE_DETECTED}" ] ; then
break
fi
fi
done
if [ "${BEE_BUILDTYPE_DETECTED}" == "${magic}" ] ; then
print_info "using magic buildtype '${BEE_BUILDTYPE_DETECTED}' from '${xdgmagic}' .."
fi
}
function save_current_package_variables() {
oPKGNAME=${PKGNAME}
oPKGEXTRANAME=${PKGEXTRANAME}
oPKGFULLNAME=${PKGFULLNAME}
oPKGVERSION=${PKGVERSION}
oPKGEXTRAVERSION=${PKGEXTRAVERSION}
oPKGFULLVERSION=${PKGFULLVERSION}
oPKGREVISION=${PKGREVISION}
}
function verify_new_package_variables() {
nPKGFULLNAME="${PKGNAME}${PKGEXTRANAME:+_${PKGEXTRANAME}}"
if [ "${oPKGFULLNAME}" != "${PKGFULLNAME}" ] ; then
if [ "${oPKGFULLNAME}" != "${nPKGFULLNAME}" ] ; then
print_error "${BEE##*/}: Changing PKGFULLNAME and one of PKGNAME or PKGEXTRANAME is not supported."
exit 1
fi
PKGNAME=${PKGFULLNAME//_*}
if [ "$PKGNAME" = "$PKGFULLNAME" ] ; then
PKGEXTRANAME=""
else
PKGEXTRANAME=${PKGFULLNAME#*_}
fi
fi
PKGFULLNAME="${PKGNAME}${PKGEXTRANAME:+_${PKGEXTRANAME}}"
nPKGFULLVERSION="${PKGVERSION}${PKGEXTRAVERSION:+_${PKGEXTRAVERSION}}"
if [ "${oPKGFULLVERSION}" != "${PKGFULLVERSION}" ] ; then
if [ "${oPKGFULLVERSION}" != "${nPKGFULLVERSION}" ] ; then
print_error "${BEE##*/}: Changing PKGFULLVERSION and one of PKGVERSION or PKGEXTRAVERSION is not supported."
exit 1
fi
PKGVERSION=${PKGFULLVERSION//_*}
if [ "$PKGVERSION" = "$PKGFULLVERSION" ] ; then
PKGEXTRAVERSION=""
else
PKGEXTRAVERSION=${PKGFULLVERSION#*_}
fi
fi
PKGFULLVERSION="${PKGVERSION}${PKGEXTRAVERSION:+_${PKGEXTRAVERSION}}"
}
function extract_new_package_variables() {
if [ "${PKGNAME}" != "${oPKGNAME}" ] ; then
# pkgname changed! we allow prefixing 'anything-' to the packagename
if [ "${PKGNAME}" != "${PKGNAME/-${oPKGNAME}}-${oPKGNAME}" ] ; then
print_error "${BEE##*/}: Invalid change in PKGNAME(${PKGNAME}) detected. Only prefixing 'something-' is supported."
exit 1
fi
print_info "${COLOR_YELLOW}PKGNAME changed from '${oPKGNAME}' to '${PKGNAME}'"
fi
if [ "${PKGEXTRANAME}" != "${oPKGEXTRANAME}" ] ; then
if [ ! -z "${oPKGEXTRANAME}" -a "${PKGEXTRANAME}" != "${oPKGEXTRANAME}_${PKGEXTRANAME#${oPKGEXTRANAME}_}" ] ; then
print_error "${BEE##*/}: Invalid change in PKGEXTRANAME(${PKGEXTRANAME}) detected. Only appending '_something' is supported."
exit 1
fi
print_info "${COLOR_YELLOW}PKGEXTRANAME changed from '${oPKGEXTRANAME}' to '${PKGEXTRANAME}'"
fi
if [ "${PKGVERSION}" != "${oPKGVERSION}" ] ; then
print_error "${BEE##*/}: Invalid change in PKGVERSION(${PKGVERSION}) detected. Changing PKGVERSION is not supported."
exit 1
fi
if [ "${PKGEXTRAVERSION}" != "${oPKGEXTRAVERSION}" ] ; then
if [ ! -z "${oPKGEXTRAVERSION}" -a "${PKGEXTRAVERSION}" != "${oPKGEXTRAVERSION}_${PKGEXTRAVERSION#${oPKGEXTRAVERSION}_}" ] ; then
print_error "${BEE##*/}: Invalid change in PKGEXTRAVERSION(${PKGEXTRAVERSION}) detected. Only appending '_something' is supported."
exit 1
fi
print_info "${COLOR_YELLOW}PKGEXTRAVERSION changed from '${oPKGEXTRAVERSION}' to '${PKGEXTRAVERSION}'"
fi
if [ "${PKGREVISION}" != "${oPKGREVISION}" ] ; then
print_error "${BEE##*/}: Invalid change in PKGREVISION(${PKGREVISION}) detected. Changing PKGREVISION is not supported."
exit 1
fi
PKGFULLPKG=${PKGFULLNAME}-${PKGFULLVERSION}-${PKGREVISION}
# since PKGARCH is now known reconstruct PKGALLPKG
PKGALLPKG="${PKGFULLPKG}.${PKGARCH}"
eval $("${BEE_BINDIR}/beeversion" "${PKGALLPKG}")
}
###############################################################################
###############################################################################
###############################################################################
function dump_variables() {
for i in P{,N{,F,E},F,V{,E,F,R},S,R} ${!PKG*} ${!BEE*} ${!DEF*} ${!OPT*} ${!DOT*} R F W S B D ; do
eval echo "${i}=\${${i}}"
done
}
function is_func() {
[ "$(type -t "${1}")" == "function" ]
return $?
}
function bee_run() {
action=${1}
shift
if is_func "mee_${action}_pre" ; then
log_enter "mee_${action}_pre()"
mee_${action}_pre "${@}"
log_leave "mee_${action}_pre()"
fi
if is_func "mee_${action}" ; then
log_enter "mee_${action}()"
mee_${action} "${@}"
log_leave "mee_${action}()"
elif is_func "bee_${action}" ; then
log_enter "bee_${action}()"
bee_${action} "${@}"
log_leave "bee_${action}()"
else
print_error "don't know how to run '${action}'"
exit
fi
if is_func "mee_${action}_post" ; then
log_enter "mee_${action}_post()"
mee_${action}_post "${@}"
log_leave "mee_${action}_post()"
fi
}
###############################################################################
OPTIONS=$("${BEE_BINDIR}/beegetopt" --name beesh \
--option help/h \
--option install/i \
--option force-install/f \
--option cleanup/c \
--option debug= \
--option archive-build \
--option no-archive-build \
--option check \
-- "$@")
if [ $? != 0 ] ; then
print_info "Terminating..." >&2
exit 1
fi
eval set -- "${OPTIONS}"
: ${OPT_INSTALL:="no"}
: ${OPT_CLEANUP:="no"}
: ${OPT_CHECK:="no"}
: ${OPT_ARCHIVE_BUILD:="yes"}
while true ; do
case "$1" in
--help)
show_help
exit 0
;;
--install)
OPT_INSTALL="yes"
shift
;;
--force-install)
OPT_INSTALL="yes"
OPT_FORCE="yes"
shift
;;
--update)
OPT_INSTALL="yes"
OPT_UPDATE="yes"
shift
;;
--cleanup)
OPT_CLEANUP="yes"
shift
;;
--no-archive-build)
OPT_ARCHIVE_BUILD="no"
shift
;;
--archive-build)
OPT_ARCHIVE_BUILD="yes"
shift
;;
--check)
OPT_CHECK="yes"
shift
;;
--debug)
DEBUG=$2
shift 2
;;
--)
shift
break
;;
*)
print_error "Internal error!"
exit 1
;;
esac
done
config_init
echo -e "${COLOR_CYAN}BEE v${BEE_VERSION} 2009-2016"
echo -e " by Marius Tolzmann <marius@mariux.de>"
echo -e " Matthias Ruester <ruester@molgen.mpg.de>"
echo -e " Tobias Dreyer <dreyer@molgen.mpg.de>"
echo -e "${COLOR_NORMAL}"
config_set_skiplist
print_info " BEE_SKIPLIST ${BEE_SKIPLIST}"
print_info " BEE_REPOSITORY_PREFIX ${BEE_REPOSITORY_PREFIX}"
print_info " BEE_METADIR ${BEE_METADIR}"
print_info " BEE_TMP_TMPDIR ${BEE_TMP_TMPDIR}"
print_info " BEE_TMP_BUILDROOT ${BEE_TMP_BUILDROOT}"
###############################################################################
###############################################################################
###############################################################################
BEE=$1
if [ "${BEE:0:1}" != "/" ] ; then
BEE=${PWD}/$BEE
fi
if [ ! -f "${BEE}" ] ; then
print_error "${BEE}: No such file."
exit 1
fi
### define pkg variables
PKGNAME=
PKGVERSION=
PKGREVISION=
eval $("${BEE_BINDIR}/beeversion" "${BEE}")
if [ -z "${PKGNAME}" -o -z "${PKGVERSION}" -o -z "${PKGREVISION}" ] ; then
print_error "${BEE}: please use the proper package versioning (e.g. package-1.0-0)"
exit 1
fi
BEEPKGROOT="${BEE_TMP_BUILDROOT}/${PKGNAME}"
BEEWORKDIR="${BEEPKGROOT}/${PKGFULLPKG}"
F=${BEEPKGROOT}/files
S=${BEEWORKDIR}/source
B=${BEEWORKDIR}/build
D=${BEEWORKDIR}/image
###############################################################################
# clear PKGALLPKG since we can't trust PKGARCH in this state
PKGALLPKG=
save_current_package_variables
# source file.bee
. "${BEE}"
# now set PKGARCH if set or changed by user via ARCH=.. and not given via file.arch.bee
: ${PKGARCH:=${ARCH}}
verify_new_package_variables
extract_new_package_variables
config_handle_deprecated_beefile
expand_prefix_variables
config_export
###############################################################################
check_rebuild "${BEE%/*}/${PKGFULLPKG}.bee" "${PKGALLPKG}"
print_info "current working directory: ${PWD}"
bee_init_builddir
check_repositories
print_info "==> building ${PKGALLPKG} .."
bee_run getsources
bee_run extract "${bee_SOURCEFILES[@]}"
: ${BEE_SOURCESUBDIR=""}
if [ ! -d "${S}/${BEE_SOURCESUBDIR}" ] ; then
print_error "ERROR: directory specified as sourcesubdir (${S}/${BEE_SOURCESUBDIR}) does not exist."
exit 1
fi
if [ "${B}" = "${S}" -a -n "${BEE_SOURCESUBDIR}" ] ; then
B="${S}/${BEE_SOURCESUBDIR}"
fi
if [ -n "${BEE_SOURCESUBDIR}" ]; then
S="${S}/${BEE_SOURCESUBDIR}"
fi
print_info "changing to source directory: ${S}"
cd "${S}"
bee_run patch "${bee_PATCHFILES[@]}"
bee_buildmagic=( $("${BEE_BINDIR}/beeuniq" "${BEE_BUILDTYPE[@]}" \
cmake \
autotools \
autogen \
perl-module \
perl-module-makemaker \
python-module \
make \
meson \
jb \
haskell-module \
) )
BEE_BUILDTYPE_DETECTED=""
for t in "${bee_buildmagic[@]}" ; do
load_buildmagic "${t}"
if [ -n "${BEE_BUILDTYPE_DETECTED}" ] ; then
break
fi
done
bee_init_buildinsourcedir
print_info "changing to build directory: ${B}"
cd "${B}"
bee_run configure
bee_run build
if [ "${OPT_CHECK}" != "no" ] ; then
bee_run check
fi
bee_run install
print_info "changing to image directory: ${D}"
cd "${D}"
bee_crosscheck
bee_pkg_pack
function bee_check_conflicts() {
"${BEE_LIBEXECDIR}/bee/bee-cache-inventory" CONTENT \
--prepend "${PKGALLPKG} " \
| sort -r -u -k8 -k1 \
> "${D}${PKGALLPKG}.bc"
last=""
while read p f ; do
if [ "${last}" != "${p}" ] ; then
print_info "${COLOR_RED}Conflicts with installed package found: ${p}:${COLOR_NORMAL}"
last=${p}
fi
print_info "${COLOR_NORMAL} $f"
done < <(bee-cache print-conflicts ${PKGALLPKG} \
--tmpinstall "${D}${PKGALLPKG}.bc" \
-f1,8- | sort -k1 -u )
}
bee_check_conflicts
cd "${BEEWORKDIR}"
bee_archivebuild
echo
print_info "==================================================================="
print_info "build summary:"
print_info " "
print_info "download directory \${F}: ${COLOR_NORMAL}${F}"
print_info " source directory \${S}: ${COLOR_NORMAL}${S}"
print_info " build directory \${B}: ${COLOR_NORMAL}${B}"
print_info " image directory \${D}: ${COLOR_NORMAL}${D}"
print_info " "
print_info " bee-file: ${COLOR_NORMAL}${beefiledest}"
print_info " pkg-file: ${COLOR_NORMAL}${pkgfile}"
print_info "build-archive: ${COLOR_NORMAL}${archive}"
print_info "==================================================================="
echo
if [ "${OPT_INSTALL}" = "yes" ] ; then
print_info "installing ${PKGALLPKG} .."
bee-install ${OPT_FORCE:+-f} ${OPT_UPDATE:+-u} "${BEE_PKGDIR}/${PKGALLPKG}.bee.tar.bz2"
fi