Skip to content

Commit 8b66137

Browse files
authored
Merge pull request uutils#8810 from oech3/ln
Allow to replace ln -fs and hardlink on Windows by default
2 parents 5e076fe + 0fc825b commit 8b66137

File tree

2 files changed

+20
-25
lines changed

2 files changed

+20
-25
lines changed

.github/workflows/CICD.yml

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -364,29 +364,15 @@ jobs:
364364
test -h /tmp/usr/local/bin/sha512sum
365365
test -h /tmp/usr/local/bin/shake128sum
366366
test -h /tmp/usr/local/bin/shake256sum
367-
- name: "`make install MULTICALL=y`"
367+
- name: "`make install MULTICALL=y LN=ln -svf`"
368368
shell: bash
369369
run: |
370370
set -x
371-
DESTDIR=/tmp/ make PROFILE=release MULTICALL=y install
372-
# Check that the utils are present
373-
test -f /tmp/usr/local/bin/coreutils
374-
# Check that hashsum symlinks are present
375-
test -h /tmp/usr/local/bin/b2sum
376-
test -h /tmp/usr/local/bin/b3sum
377-
test -h /tmp/usr/local/bin/md5sum
378-
test -h /tmp/usr/local/bin/sha1sum
379-
test -h /tmp/usr/local/bin/sha224sum
380-
test -h /tmp/usr/local/bin/sha256sum
381-
test -h /tmp/usr/local/bin/sha3-224sum
382-
test -h /tmp/usr/local/bin/sha3-256sum
383-
test -h /tmp/usr/local/bin/sha3-384sum
384-
test -h /tmp/usr/local/bin/sha3-512sum
385-
test -h /tmp/usr/local/bin/sha384sum
386-
test -h /tmp/usr/local/bin/sha3sum
387-
test -h /tmp/usr/local/bin/sha512sum
388-
test -h /tmp/usr/local/bin/shake128sum
389-
test -h /tmp/usr/local/bin/shake256sum
371+
DESTDIR=/tmp/ make PROFILE=release MULTICALL=y LN="ln -svf" install
372+
# Check that relative symlinks of hashsum are present
373+
[ $(readlink /tmp/usr/local/bin/b2sum) = coreutils ]
374+
[ $(readlink /tmp/usr/local/bin/md5sum) = coreutils ]
375+
[ $(readlink /tmp/usr/local/bin/sha512sum) = coreutils ]
390376
- name: "`make UTILS=XXX`"
391377
shell: bash
392378
run: |
@@ -483,9 +469,11 @@ jobs:
483469
run: |
484470
## `make install`
485471
make install DESTDIR=target/size-release/
486-
make install MULTICALL=y DESTDIR=target/size-multi-release/
472+
make install MULTICALL=y LN="ln -vf" DESTDIR=target/size-multi-release/
487473
# strip the results
488474
strip target/size*/usr/local/bin/*
475+
- name: Test for hardlinks
476+
run: [ $(stat -c %i target/size-multi-release/usr/local/bin/cp) = $(stat -c %i target/size-multi-release/usr/local/bin/coreutils) ]
489477
- name: Compute uutil release sizes
490478
shell: bash
491479
run: |

GNUmakefile

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,13 @@ TOYBOX_SRC := $(TOYBOX_ROOT)/toybox-$(TOYBOX_VER)
6969
#------------------------------------------------------------------------
7070
OS ?= $(shell uname -s)
7171

72+
# Windows does not allow symlink by default.
73+
# Allow to override LN for AppArmor.
74+
ifeq ($(OS),Windows_NT)
75+
LN ?= ln -f
76+
endif
77+
LN ?= ln -sf
78+
7279
ifdef SELINUX_ENABLED
7380
override SELINUX_ENABLED := 0
7481
# Now check if we should enable it (only on non-Windows)
@@ -482,18 +489,18 @@ endif
482489
ifeq (${MULTICALL}, y)
483490
$(INSTALL) -m 755 $(BUILDDIR)/coreutils $(INSTALLDIR_BIN)/$(PROG_PREFIX)coreutils
484491
$(foreach prog, $(filter-out coreutils, $(INSTALLEES)), \
485-
cd $(INSTALLDIR_BIN) && ln -fs $(PROG_PREFIX)coreutils $(PROG_PREFIX)$(prog) $(newline) \
492+
cd $(INSTALLDIR_BIN) && $(LN) $(PROG_PREFIX)coreutils $(PROG_PREFIX)$(prog) $(newline) \
486493
)
487494
$(foreach prog, $(HASHSUM_PROGS), \
488-
cd $(INSTALLDIR_BIN) && ln -fs $(PROG_PREFIX)coreutils $(PROG_PREFIX)$(prog) $(newline) \
495+
cd $(INSTALLDIR_BIN) && $(LN) $(PROG_PREFIX)coreutils $(PROG_PREFIX)$(prog) $(newline) \
489496
)
490-
$(if $(findstring test,$(INSTALLEES)), cd $(INSTALLDIR_BIN) && ln -fs $(PROG_PREFIX)coreutils $(PROG_PREFIX)[)
497+
$(if $(findstring test,$(INSTALLEES)), cd $(INSTALLDIR_BIN) && $(LN) $(PROG_PREFIX)coreutils $(PROG_PREFIX)[)
491498
else
492499
$(foreach prog, $(INSTALLEES), \
493500
$(INSTALL) -m 755 $(BUILDDIR)/$(prog) $(INSTALLDIR_BIN)/$(PROG_PREFIX)$(prog) $(newline) \
494501
)
495502
$(foreach prog, $(HASHSUM_PROGS), \
496-
cd $(INSTALLDIR_BIN) && ln -fs $(PROG_PREFIX)hashsum $(PROG_PREFIX)$(prog) $(newline) \
503+
cd $(INSTALLDIR_BIN) && $(LN) $(PROG_PREFIX)hashsum $(PROG_PREFIX)$(prog) $(newline) \
497504
)
498505
$(if $(findstring test,$(INSTALLEES)), $(INSTALL) -m 755 $(BUILDDIR)/test $(INSTALLDIR_BIN)/$(PROG_PREFIX)[)
499506
endif

0 commit comments

Comments
 (0)