Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Makefile, tinyramfs, .lib/* : respect ${LIBDIR} #40

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ install:
cp -f doc/tinyramfs.5 ${DESTDIR}${MANDIR}/man5/
cp -f doc/tinyramfs.8 ${DESTDIR}${MANDIR}/man8/
cp -R hook ${DESTDIR}${LIBDIR}/tinyramfs/hook.d
find ${DESTDIR}${LIBDIR}/tinyramfs/ -name '*.sh' -exec sed -i "s|@@LIBDIR@@|${LIBDIR}|g" {} +
sed -i "s|@@LIBDIR@@|${LIBDIR}|g" ${DESTDIR}${BINDIR}/tinyramfs


uninstall:
rm -f ${DESTDIR}${BINDIR}/tinyramfs
Expand Down
4 changes: 2 additions & 2 deletions lib/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ copy_kmod()
# TODO allow full path to hook
copy_hook()
{
for _dir in ${local+./hook} /etc/tinyramfs/hook.d /lib/tinyramfs/hook.d; do
for _dir in ${local+./hook} /etc/tinyramfs/hook.d @@LIBDIR@@/tinyramfs/hook.d; do
_hook="${_dir}/${1}/${1}"
[ -f "$_hook" ] && break
done
Expand All @@ -115,7 +115,7 @@ copy_hook()

print "copying hook: ${1}.${_ext}"

copy_file "${_hook}.${_ext}" "/lib/tinyramfs/hook.d/${1}/${1}.${_ext}" 0644
copy_file "${_hook}.${_ext}" "@@LIBDIR@@/tinyramfs/hook.d/${1}/${1}.${_ext}" 0644
done

print "evaluating hook: $1"
Expand Down
6 changes: 3 additions & 3 deletions lib/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ eval_hooks()
{ IFS=,; set -- $hooks; unset IFS; }

for _hook; do
[ -f "/lib/tinyramfs/hook.d/${_hook}/${_hook}.${_type}" ] || continue
[ -f "@@LIBDIR@@/tinyramfs/hook.d/${_hook}/${_hook}.${_type}" ] || continue
[ "$rdbreak" = "$_hook" ] && panic "break before: ${_hook}.${_type}"

# https://shellcheck.net/wiki/SC1090
# shellcheck disable=1090
. "/lib/tinyramfs/hook.d/${_hook}/${_hook}.${_type}"
. "@@LIBDIR@@/tinyramfs/hook.d/${_hook}/${_hook}.${_type}"
done
}

Expand Down Expand Up @@ -104,7 +104,7 @@ trap panic EXIT

# https://shellcheck.net/wiki/SC1091
# shellcheck disable=1091
. /lib/tinyramfs/common.sh
. @@LIBDIR@@/tinyramfs/common.sh

# https://shellcheck.net/wiki/SC1091
# shellcheck disable=1091
Expand Down
14 changes: 7 additions & 7 deletions tinyramfs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ init_base()
ln -s ../run/lock var/lock
ln -s bin usr/sbin

ln -s lib/tinyramfs/init.sh init
ln -s /lib/tinyramfs/init.sh init
ln -s ../lib/tinyramfs/helper.sh bin/helper
)

Expand All @@ -69,9 +69,9 @@ init_base()
fi

copy_file "$config" /etc/tinyramfs/config 0644
copy_file "$init" /lib/tinyramfs/init.sh 0755
copy_file "$devh" /lib/tinyramfs/helper.sh 0755
copy_file "$shrd" /lib/tinyramfs/common.sh 0755
copy_file "$init" @@LIBDIR@@/tinyramfs/init.sh 0755
copy_file "$devh" @@LIBDIR@@/tinyramfs/helper.sh 0755
copy_file "$shrd" @@LIBDIR@@/tinyramfs/common.sh 0755
}

copy_hooks()
Expand Down Expand Up @@ -187,9 +187,9 @@ shift "$((OPTIND - 1))"

: "${kernel:=$(uname -r)}"
: "${moddir:=/lib/modules}"
: "${init:=/lib/tinyramfs/init.sh}"
: "${devh:=/lib/tinyramfs/helper.sh}"
: "${shrd:=/lib/tinyramfs/common.sh}"
: "${init:=@@LIBDIR@@/tinyramfs/init.sh}"
: "${devh:=@@LIBDIR@@/tinyramfs/helper.sh}"
: "${shrd:=@@LIBDIR@@/tinyramfs/common.sh}"

# -e: Exit if command return status greater than 0
# -f: Disable globbing *?[]
Expand Down