| git.druid.rocks | index | druid520 | ports | ports/ | meta/ | mp/ | add.sh |
ports/meta/mp/add.sh
set -e
git clone git://git.druid.rocks/druid520/mp.git
cd mp
if command -v mk >/dev/null 2>&1; then
mk . b
else
sh mk/b.sh
fi
mkdir -p $MP_PREFIX/bin/mplib $MP_PREFIX/libexec/mp
cp mpx $MP_PREFIX/libexec/mp/mpx.new
chmod +x $MP_PREFIX/libexec/mp/mpx.new
mv -f $MP_PREFIX/libexec/mp/mpx.new $MP_PREFIX/libexec/mp/mpx
cp mp $MP_PREFIX/bin/mp.new
chmod +x $MP_PREFIX/bin/mp.new
mv -f $MP_PREFIX/bin/mp.new $MP_PREFIX/bin/mp
# mp.<command>: every executable mp.* sitting next to mp itself (this glob
# also matches the real, non-executable mp.conf.example at repo root, so
# the -x check is what keeps that one out). each one is gated by its own
# USE flag, AND its group's master: a core command also needs
# USE_commands=1, a plugin also needs USE_extensions=1 (per plugins.list
# -- mk/b.sh's own record of which mp.<name>s came from plugins/ rather
# than src/) -- symmetric treatment for both groups. indirect ${VAR}
# lookup needs eval in POSIX sh (no bash-only ${!name}), safe here since
# every command/plugin name is plain lowercase alphanumeric.
#
# a flag being OFF actively REMOVES an already-installed copy, not just
# "don't refresh it": del.sh deliberately never touches any mp.* (so a
# remove+reinstall cycle -- what toggling a flag actually triggers -- has
# a working mp throughout), so a stale copy from before the flag was
# turned off would otherwise just sit there, still fully functional,
# forever -- defeating the entire point of being able to exclude it.
for f in mp.*; do
[ -x "$f" ] || continue
cmd="${f#mp.}"
if grep -qx "$cmd" plugins.list 2>/dev/null; then
eval "ownflag=\${USE_ext_$cmd:-}"
if [ -n "$USE_extensions" ] && [ -n "$ownflag" ]; then wanted=1; else wanted=; fi
else
eval "flagval=\${USE_$cmd:-}"
if [ -n "$USE_commands" ] && [ -n "$flagval" ]; then wanted=1; else wanted=; fi
fi
if [ -z "$wanted" ]; then
rm -f "$MP_PREFIX/bin/$f"
continue
fi
cp "$f" "$MP_PREFIX/bin/$f.new"
chmod +x "$MP_PREFIX/bin/$f.new"
mv -f "$MP_PREFIX/bin/$f.new" "$MP_PREFIX/bin/$f"
done
# plugins.list itself: usage()/mp.version both classify an mp.<name>
# they already found on disk as core vs. plugin by checking this file,
# same as the gating loop above -- copied unfiltered (a name in here
# with no corresponding installed file, USE flag off, is simply never
# looked up) since it's just data, not itself a command needing a flag.
# never installed before this: "commands:"/"plugins:" (mp help, mp
# version) always silently collapsed into one undifferentiated list on
# every real (non-dev-tree) install, for every mp there's ever been.
cp plugins.list $MP_PREFIX/bin/plugins.list.new
mv -f $MP_PREFIX/bin/plugins.list.new $MP_PREFIX/bin/plugins.list
# mplib::* modules: must land next to mp/mp.<command> (same dir), since
# each of those does "use lib $FindBin::Bin" to find them as sibling mplib/.
for f in mplib/*.pm; do
cp "$f" "$MP_PREFIX/bin/$f.new"
mv -f "$MP_PREFIX/bin/$f.new" "$MP_PREFIX/bin/mplib/$(basename "$f")"
done
[ -f /etc/mp.conf ] || cp mp.conf.example /etc/mp.conf
[ -f /etc/mpx.conf ] || cp mpx.conf.example /etc/mpx.conf