Skip to content
This repository was archived by the owner on Mar 1, 2025. It is now read-only.

Commit b6fa4b7

Browse files
committed
fix: [#264] make DESTDIR properly configured in header
1 parent c818f00 commit b6fa4b7

File tree

4 files changed

+15
-13
lines changed

4 files changed

+15
-13
lines changed

CONTRIBUTING.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ For contributing, there are several functions and variables built-in the header
8989
- `wslu_util_name` - current utility name
9090
- `wslu_version` - wslu version, written by `VERSION`
9191
- `wslu_prefix` - the location `wslu` installed to, written by the `PREFIX` during the make.
92+
- `wslu_dest_dir` - the location `wslu` installed to, written by the `DESTDIR` during the make.
9293
- `wslu_debug` - the variable used for calling utility across. This will allow calling the `--debug` option for other `wslu` utilities inside script easier.
9394
- Formatting: `black`, `red`, `green`, `brown`, `blue`, `purple`, `cyan`, `yellow`, `white`, `dark_gray`, `light_red`, `light_green`, `light_blue`, `light_purple`, `light_cyan`, `light_gray`, `orange`, `light_orange`, `deep_purple`, `bold`, `reset`
9495
- Indicator: `info`, `input_info`, `error`, `warn`

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ VERTMP = $(shell cat ./VERSION)
2020

2121
all: doc
2222
[ -d $(OUTPATH) ] || mkdir $(OUTPATH)
23-
sed -e 's/VERSIONPLACEHOLDER/'$(VERTMP)'/' -e 's|PREFIXPLACEHOLDER|'$(PREFIX)'|' $(HEADER) > $(HEADER).tmp; \
23+
sed -e 's/VERSIONPLACEHOLDER/'$(VERTMP)'/' -e 's|PREFIXPLACEHOLDER|'$(PREFIX)'|' -e 's|DESTDIRPLACEHOLDER|'$(DESTDIR)'|' $(HEADER) > $(HEADER).tmp; \
2424
for file in $(SOURCES); do \
2525
cat $(HEADER).tmp $$file > $(OUTPATH)/`basename $$file`; \
2626
mv $(OUTPATH)/`basename $$file` $(OUTPATH)/`basename $$file .sh`; \

src/wslu-header

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ wslu_util_name=$(basename "$wslu_util_fullpath")
2525
# Version
2626
wslu_version=VERSIONPLACEHOLDER
2727
wslu_prefix="PREFIXPLACEHOLDER"
28+
wslu_dest_dir="DESTDIRPLACEHOLDER"
2829

2930
# Speed up script by using unicode.
3031
LC_ALL=C
@@ -150,20 +151,20 @@ function error_echo {
150151
}
151152

152153
# source default config
153-
if [ -f "${wslu_prefix}/share/wslu/conf" ]; then
154+
if [ -f "${wslu_dest_dir}${wslu_prefix}/share/wslu/conf" ]; then
154155
debug_echo "source default setting"
155-
source "${wslu_prefix}/share/wslu/conf"
156+
source "${wslu_dest_dir}${wslu_prefix}/share/wslu/conf"
156157
fi
157158

158159
# source user-defined config
159-
if [ -f "${wslu_prefix}/share/wslu/custom.conf" ]; then
160-
debug_echo "${wslu_prefix}/share/wslu/custom.conf found, sourcing"
161-
source "${wslu_prefix}/share/wslu/custom.conf"
160+
if [ -f "${wslu_dest_dir}${wslu_prefix}/share/wslu/custom.conf" ]; then
161+
debug_echo "${wslu_dest_dir}${wslu_prefix}/share/wslu/custom.conf found, sourcing"
162+
source "${wslu_dest_dir}${wslu_prefix}/share/wslu/custom.conf"
162163
fi
163164

164-
if [ -f "/etc/wslu/conf" ]; then
165-
debug_echo "/etc/wslu/conf found, sourcing"
166-
source "/etc/wslu/conf"
165+
if [ -f "${wslu_dest_dir}/etc/wslu/conf" ]; then
166+
debug_echo "${wslu_dest_dir}/etc/wslu/conf found, sourcing"
167+
source "${wslu_dest_dir}/etc/wslu/conf"
167168
fi
168169

169170
if [ -f "/etc/wslu/custom.conf" ]; then

src/wslvar.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# shellcheck shell=bash
2-
var_type=1
2+
var_type=${WSLVAR_DEFAULT_VARTYPE:-1}
33

44
help_short="wslvar [-sl] NAME\nwslvar [-hvSL]"
55

@@ -25,7 +25,7 @@ function cl_destoryer {
2525

2626
function caller {
2727
if [ "$*" != "" ]; then
28-
case $WSLVAR_DEFAULT_VARTYPE in
28+
case $var_type in
2929
1) p="$(cl_destoryer "$(call_sys "$@")")";;
3030
2) p="$(cl_destoryer "$(call_shell "$@")")";;
3131
*) error_echo "Invalid variable type. Aborted." 22;;
@@ -38,8 +38,8 @@ function caller {
3838

3939
while [ "$1" != "" ]; do
4040
case "$1" in
41-
-s|--sys) WSLVAR_DEFAULT_VARTYPE=1; shift;;
42-
-l|--shell) WSLVAR_DEFAULT_VARTYPE=2; shift;;
41+
-s|--sys) var_type=1; shift;;
42+
-l|--shell) var_type=2; shift;;
4343
-S|--getsys) view_sys; exit;;
4444
-L|--getshell) view_shell; exit;;
4545
-h|--help) help "$0" "$help_short"; exit;;

0 commit comments

Comments
 (0)