Skip to content

Commit 1193883

Browse files
committed
package: avoid non-portable ln options
The options present in the 'ln' command differ between Linux and MacOS ('-r' in the former creates a relative link from absolute paths, '-F' in the latter forces overwriting an existing link). Drop use of these options in packaging/installation scripts by instead explicitly specifying relative paths and deleting existing links before calling 'ln', respectively. Signed-off-by: Victoria Dye <[email protected]>
1 parent 9f87527 commit 1193883

File tree

2 files changed

+17
-12
lines changed

2 files changed

+17
-12
lines changed

build/package/layout-unix.sh

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,28 +48,31 @@ if [ -d "$PAYLOAD" ]; then
4848
fi
4949

5050
# Ensure payload directory exists
51-
INSTALL_TO="$PAYLOAD/usr/local/git-bundle-server"
52-
mkdir -p "$INSTALL_TO"
51+
APP_ROOT="$PAYLOAD/usr/local/git-bundle-server"
52+
mkdir -p "$APP_ROOT"
5353

5454
# Copy built binaries
5555
echo "Copying binaries..."
56-
cp -R "$BINDIR/." "$INSTALL_TO/bin"
56+
cp -R "$BINDIR/." "$APP_ROOT/bin"
5757

5858
# Copy uninstaller script
5959
if [ -n "$UNINSTALLER" ]; then
6060
echo "Copying uninstall script..."
61-
cp "$UNINSTALLER" "$INSTALL_TO"
61+
cp "$UNINSTALLER" "$APP_ROOT"
6262
fi
6363

6464
# Create symlinks
6565
if [ -n "$INCLUDE_SYMLINKS" ]; then
6666
LINK_TO="$PAYLOAD/usr/local/bin"
67+
RELATIVE_LINK_TO_BIN="../git-bundle-server/bin"
6768
mkdir -p "$LINK_TO"
6869

69-
echo "Creating symlinks..."
70-
for program in "$INSTALL_TO"/bin/*
70+
echo "Creating binary symlinks..."
71+
for program in "$APP_ROOT"/bin/*
7172
do
72-
ln -s -r "$program" "$LINK_TO/$(basename $program)"
73+
p=$(basename "$program")
74+
rm -f "$LINK_TO/$p"
75+
ln -s "$RELATIVE_LINK_TO_BIN/$p" "$LINK_TO/$p"
7376
done
7477
fi
7578

build/package/pkg/scripts/postinstall

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,17 @@ PACKAGE=$1
55
INSTALL_DESTINATION=$2
66

77
# Directories
8-
INSTALL_TO="$INSTALL_DESTINATION/usr/local/git-bundle-server/"
9-
LINK_TO="$INSTALL_DESTINATION/usr/local/bin/"
10-
RELATIVE_LINK_TO_INSTALL="../git-bundle-server"
8+
APP_ROOT="$INSTALL_DESTINATION/usr/local/git-bundle-server"
9+
LINK_TO="$INSTALL_DESTINATION/usr/local/bin"
10+
RELATIVE_LINK_TO_BIN="../git-bundle-server/bin"
1111
mkdir -p "$LINK_TO"
1212

1313
# Create symlinks
14-
for program in "$INSTALL_TO"/bin/*
14+
for program in "$APP_ROOT"/bin/*
1515
do
16-
/bin/ln -Fs "$RELATIVE_LINK_TO_INSTALL/bin/$(basename $program)" "$LINK_TO/$(basename $program)"
16+
p=$(basename "$program")
17+
rm -f "$LINK_TO/$p"
18+
ln -s "$RELATIVE_LINK_TO_BIN/$p" "$LINK_TO/$p"
1719
done
1820

1921
exit 0

0 commit comments

Comments
 (0)