Commit 7f306692 authored by Pierre-Yves Fourmond's avatar Pierre-Yves Fourmond

Fixed Issue #36

parent 73c03c90
This diff is collapsed.
......@@ -34,7 +34,7 @@ Usage: $LIAR [OPTIONS...] COMMAND [PARAMETERS...]
-d Specify DESTINATION folder. If unspecified, installation will be done in $HOME/Programs.
-l Create symbolic links in $HOME/bin folder after installation.
-s Specify the folder for SYMBOLIC links creation.
-p Specify the file PATTERN to restrict symbolic links creation.
-p Specify the file PATTERN(s) to restrict symbolic links creation.
-a Specify the download user AGENT: wget, curl or aria2c. By default, wget is used.
-c Specify the file path expected CHECKSUM.
-t Specify the checksum TYPE: md5, sha1, sha256 or sha512. By default sha1 is used.
......@@ -387,6 +387,34 @@ set_arg() {
eval "$NAME=\"$VALUE\""
}
create_links() {
bin_pattern="$1"
if [ "$(expr substr "$bin_pattern" 1 1)" != "*" ]; then
bin_pattern="*$bin_pattern"
fi
exec_names=$(find "$INSTALL_FOLDER" -type f -executable -wholename "$bin_pattern")
if [ -n "$exec_names" ]; then
install_links="$INSTALL_FOLDER/.liar_links"
for exec_name in $exec_names; do
if ! is_executable "$exec_name"; then
continue
fi
link_name="$BIN_FOLDER/$(basename "$exec_name")"
if [ -f "$link_name" ]; then
continue
fi
if [ -n "$VERBOSE" ]; then
echo "Creating link: '$link_name' -> '$exec_name'"
else
echo "Creating link: '$link_name'"
fi
if ln -s "$exec_name" "$link_name"; then
echo "$link_name" >> "$install_links"
fi
done
fi
}
parse() {
SOURCE=$(readlink -e $0)
......@@ -399,7 +427,7 @@ parse() {
;;
s) set_arg BIN_FOLDER "$OPTARG" || return 1
;;
p) set_arg BIN_PATTERN "$OPTARG" || return 1
p) set_arg BIN_PATTERNS "$OPTARG" || return 1
;;
a) case "$OPTARG" in
wget | curl | aria2c)
......@@ -507,10 +535,8 @@ parse() {
fi
fi
if [ -z "$BIN_PATTERN" ]; then
BIN_PATTERN="*"
elif [ "$(expr substr "$BIN_PATTERN" 1 1)" != "*" ]; then
BIN_PATTERN="*$BIN_PATTERN"
if [ -z "$BIN_PATTERNS" ]; then
BIN_PATTERNS="*"
fi
if [ -z "$USER_AGENT" ]; then
......@@ -657,24 +683,10 @@ EOF
if [ -n "$CREATE_LINKS" ]; then
if [ -d "$BIN_FOLDER" ]; then
exec_names=$(find "$INSTALL_FOLDER" -type f -executable -wholename "$BIN_PATTERN")
if [ -n "$exec_names" ]; then
install_links="$INSTALL_FOLDER/.liar_links"
for exec_name in $exec_names; do
if ! is_executable "$exec_name"; then
continue
fi
link_name="$BIN_FOLDER/$(basename "$exec_name")"
if [ -n "$VERBOSE" ]; then
echo "Creating link: '$link_name' -> '$exec_name'"
else
echo "Creating link: '$link_name'"
fi
if ln -s "$exec_name" "$link_name"; then
echo "$link_name" >> "$install_links"
fi
done
fi
bin_patterns="$(echo "$BIN_PATTERNS" | tr -d " " | tr "|" "\n" | sed "s/^\**//" | uniq)"
for bin_pattern in $bin_patterns; do
create_links "$bin_pattern"
done
else
echo "WARNING: Directory: '$BIN_FOLDER' does not exist, Links won't be created"
fi
......
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