2024-07-18 12:22:03 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
H_FILE="regexis024_build_system.h"
|
2024-08-16 19:22:27 +00:00
|
|
|
SH_TEMP_FILE="regexis024_build_system.sh"
|
2024-07-18 12:22:03 +00:00
|
|
|
|
2024-08-16 19:22:27 +00:00
|
|
|
if [ \! \( -f "$H_FILE" \) -o \! \( -f "$SH_TEMP_FILE" \) ]; then
|
|
|
|
echo "Change cwd to root of build system source code root directory"; exit 1;
|
|
|
|
fi
|
2024-07-18 12:22:03 +00:00
|
|
|
|
|
|
|
usage(){
|
2024-08-16 19:22:27 +00:00
|
|
|
echo "Usage: ./install.sh [installation root]"
|
2024-07-18 12:22:03 +00:00
|
|
|
}
|
|
|
|
|
2024-08-16 19:22:27 +00:00
|
|
|
if [ $# -gt 1 ]; then usage; exit 1; fi
|
2024-07-18 12:22:03 +00:00
|
|
|
|
2024-08-16 19:22:27 +00:00
|
|
|
INST_ROOT="/usr"
|
2024-07-18 12:22:03 +00:00
|
|
|
|
2024-08-16 19:22:27 +00:00
|
|
|
if [ $# -ge 1 ]; then INST_ROOT="$1"; fi
|
2024-07-18 12:22:03 +00:00
|
|
|
|
2024-08-16 19:22:27 +00:00
|
|
|
INST_ROOT="$(realpath "$INST_ROOT")"
|
2024-07-18 12:22:03 +00:00
|
|
|
|
2024-08-16 19:22:27 +00:00
|
|
|
install -d "$INST_ROOT/include"
|
2024-07-18 12:22:03 +00:00
|
|
|
|
2024-08-16 19:22:27 +00:00
|
|
|
if [ $? != 0 ]; then
|
|
|
|
echo "Can't install IR/bin directory"; exit 1;
|
|
|
|
fi
|
2024-07-18 12:22:03 +00:00
|
|
|
|
2024-08-16 19:22:27 +00:00
|
|
|
install "$H_FILE" "$INST_ROOT/include/"
|
2024-07-18 12:22:03 +00:00
|
|
|
|
2024-08-16 19:22:27 +00:00
|
|
|
if [ $? != 0 ]; then
|
|
|
|
echo "Can't copy $H_FILE"; exit 1;
|
|
|
|
fi
|
|
|
|
|
|
|
|
I_DIR="$INST_ROOT/include"
|
|
|
|
|
|
|
|
escape4shell(){
|
|
|
|
echo "$1" | sed -e "s/'/'\\\\''/g; 1s/^/'/; \$s/\$/'/"
|
|
|
|
}
|
|
|
|
|
|
|
|
SH_TEMPLATE="$(cat "$SH_TEMP_FILE")"
|
|
|
|
SH_TEMPLATE="${SH_TEMPLATE/"i_dir=99999"/"id_dir=$(escape4shell "$I_DIR")"}"
|
|
|
|
|
|
|
|
install -d "$INST_ROOT/bin"
|
|
|
|
|
|
|
|
if [ $? != 0 ]; then echo "Failed to install IR/bin directory"; exit 1; fi
|
|
|
|
|
|
|
|
echo "$SH_TEMPLATE" > "$INST_ROOT/bin/$SH_TEMP_FILE"
|
|
|
|
|
|
|
|
if [ $? != 0 ]; then
|
|
|
|
echo "Can't paste generated $SH_TEMP_FILE"; exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
chmod +x "$INST_ROOT/bin/$SH_TEMP_FILE"
|
|
|
|
|
|
|
|
if [ $? != 0 ]; then
|
|
|
|
echo "Can't chmod +x on .sh script in IR/bin"; exit 1
|
|
|
|
fi
|
2024-07-18 12:22:03 +00:00
|
|
|
|