Commit d9cee91a authored by Vitaly Lipatov's avatar Vitaly Lipatov

set_distro_info: split to TMPDIR, BIGTMPDIR and export DISTR* vars only once

parent 3028467d
......@@ -753,29 +753,43 @@ get_help()
done
}
# TODO: get all info by one request (too slow)
set_distro_info()
set_bigtmpdir()
{
# use external distro_info if internal one is missed
DISTRVENDOR=$PROGDIR/distr_info
[ -x $DISTRVENDOR ] || DISTRVENDOR=distro_info
export DISTRVENDOR
# export pack of variables:
# BASEDISTRNAME
# DISTRNAME
# DISTRVERSION
# DISTRARCH
# DISTRCONTROL
# PMTYPE
eval $($DISTRVENDOR --print-eepm-env)
[ -n "$TMPDIR" ] || TMPDIR="/tmp"
# TODO: improve BIGTMPDIR conception
# https://bugzilla.mozilla.org/show_bug.cgi?id=69938
# https://refspecs.linuxfoundation.org/FHS_3.0/fhs/ch05s15.html
# https://geekpeach.net/ru/%D0%BA%D0%B0%D0%BA-systemd-tmpfiles-%D0%BE%D1%87%D0%B8%D1%89%D0%B0%D0%B5%D1%82-tmp-%D0%B8%D0%BB%D0%B8-var-tmp-%D0%B7%D0%B0%D0%BC%D0%B5%D0%BD%D0%B0-tmpwatch-%D0%B2-centos-rhel-7
[ -n "$BIGTMPDIR" ] || [ -d "/var/tmp" ] && BIGTMPDIR="/var/tmp" || BIGTMPDIR="$TMPDIR"
export BIGTMPDIR
}
assure_tmpdir()
{
if [ -z "$TMPDIR" ] ; then
export TMPDIR="/tmp"
warning "Your have no TMPDIR defined. Use $TMPDIR as fallback."
fi
if [ ! -w "$TMPDIR" ] ; then
fatal "TMPDIR $TMPDIR is not writable."
fi
}
set_distro_info()
{
assure_tmpdir
set_bigtmpdir
# don't run again in subprocesses
[ -n "$DISTRVENDOR" ] && return 0
DISTRVENDOR=$PROGDIR/distr_info
export DISTRVENDOR
# export pack of variables, see epm print info --print-eepm-env
[ -n "$verbose" ] && $DISTRVENDOR --print-eepm-env
eval $($DISTRVENDOR --print-eepm-env | grep -v '^ *#')
}
# FIXME: detect if not recognized
......
......@@ -56,7 +56,6 @@ filter_out()
sed -e 's|^onefile_estrlist()|estrlist()|g' | \
sed -e 's|$SHAREDIR/tools_json|internal_tools_json|g' | \
sed -e 's|DISTRVENDOR=$PROGDIR/distr_info|DISTRVENDOR=internal_distr_info|g' | \
sed -e 's|DISTRVENDOR=distro_info|DISTRVENDOR=internal_distr_info|g' | \
sed -e "s|@VERSION@|$(get_version)|g"
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment