diff options
author | Peter Korsgaard <peter@korsgaard.com> | 2017-02-07 23:08:17 +0100 |
---|---|---|
committer | Peter Korsgaard <peter@korsgaard.com> | 2017-07-03 15:10:58 +0200 |
commit | e7548edb5f930362e361b14eb67cda2b16c8846c (patch) | |
tree | 7a7ef4ae68202811026a289b1df1fe3da48755fd | |
parent | 51825df3a184cad0f5bccb6a18b9d6197855cab6 (diff) | |
download | buildroot-e7548edb5f930362e361b14eb67cda2b16c8846c.tar.gz buildroot-e7548edb5f930362e361b14eb67cda2b16c8846c.zip |
fakedate: simplify logic
Using -ef to check for the same file is nicer than relying on a magic
symlink-to-fakedate.
Notice that -ef isn't stricly posix (but supported by bash/dash/zsh), so
I've changed the shebang to /bin/bash.
While we are at it, restructure the logic to do a single exec at the end
instead of handling the epoch/!epoch cases differently for simplicity.
With that out of the way we can directly install it as $HOST/usr/bin/date
instead of the fakedate / date symlink.
[Peter: drop IFS=: change]
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
Reviewed-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
-rwxr-xr-x | package/fakedate/fakedate | 14 | ||||
-rw-r--r-- | package/fakedate/fakedate.mk | 3 |
2 files changed, 5 insertions, 12 deletions
diff --git a/package/fakedate/fakedate b/package/fakedate/fakedate index 4a9b9b5e64..a64d9b9cdf 100755 --- a/package/fakedate/fakedate +++ b/package/fakedate/fakedate @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # vim: set sw=4 expandtab: # # This program is free software; you can redistribute it and/or modify @@ -18,18 +18,12 @@ # Copyright (C) 2016 Jérôme Pouiller <jezz@sysmic.org> # -# Sanity check -if ! readlink -f "$0" | grep -q fakedate; then - echo "fakedate: Please name this script \`fakedate'" - exit 1 -fi - DATE_BIN=false # Do not call `date' directly since it will produce an infinite recursion. # Instead, find path of true `date' binary. for P in `echo $PATH | tr ':' ' '`; do if [ -x "$P/date" ]; then - if readlink -f "$P/date" | grep -qv fakedate; then + if ! [ "$P/date" -ef "$0" ]; then DATE_BIN="$P/date" break; fi @@ -50,8 +44,8 @@ if [ -n "$SOURCE_DATE_EPOCH" ]; then done if [ $FORCE_EPOCH -eq 1 ]; then echo "date: Warning: using \$SOURCE_DATE_EPOCH instead of true time" >&2 - exec $DATE_BIN -d "@$SOURCE_DATE_EPOCH" "$@" + ARGS="-d @$SOURCE_DATE_EPOCH" fi fi -exec $DATE_BIN "$@" +exec $DATE_BIN $ARGS "$@" diff --git a/package/fakedate/fakedate.mk b/package/fakedate/fakedate.mk index f47a5ee38c..5d90f719bb 100644 --- a/package/fakedate/fakedate.mk +++ b/package/fakedate/fakedate.mk @@ -8,8 +8,7 @@ HOST_FAKEDATE_LICENSE = GPL-2.0+ define HOST_FAKEDATE_INSTALL_CMDS - $(INSTALL) -D -m 755 package/fakedate/fakedate $(HOST_DIR)/usr/bin/fakedate - ln -sfn fakedate $(HOST_DIR)/usr/bin/date + $(INSTALL) -D -m 755 package/fakedate/fakedate $(HOST_DIR)/usr/bin/date endef $(eval $(host-generic-package)) |