[Buildroot] [PATCH v2 09/15] fakedate: new package

Jérôme Pouiller jezz at sysmic.org
Sat Nov 19 13:24:24 UTC 2016


Hello,

On Friday 18 November 2016 12:48:06 Thomas Petazzoni wrote:
> On Fri, 18 Nov 2016 10:10:18 +0100, Jérôme Pouiller wrote:
[...]
> > +PATH=/bin:/usr/bin
> 
> It is not really nice to override the PATH. I guess you want to remove
> $(HOST_DIR)/usr/bin from the PATH to not call yourself recursively, but
> I think we should do better than assuming /bin:/usr/bin is OK.

My initial idea was something based on:
    sed "s/@@DATE_CMD@@/`which date`/"

However, I worried about people who add $HOST_DIR in their $PATH and
call host-fakedate-reinstall.

However, stripping $(dirname $0) from PATH during runtime seems a good
idea. I will try that.

> > +LOG=/dev/null
> 
> This variable is used by?

In my initial version, I logged calls to fakedate in $BUILD_DIR.
I removed the log file, but it may be convenient to easily restore it
if necessary.

> > +if [ -n "$SOURCE_DATE_EPOCH" ]; then
> > +    INHIBIT=0
> > +    for i in "$@"; do
> > +        case $i in
> > +        -d|-[!-]*d|--date=*|-f|-[!-]*f|--file=*)
> > +            INHIBIT=1
> > +            ;;
> > +        esac
> > +    done
> > +    if [ $INHIBIT -eq 0 ]; then
> > +        echo "date: Warning: using \$SOURCE_DATE_EPOCH instead of true time" >&2
> > +        echo "Catch call to date from `pwd` with parameters: '$@'" >> $LOG
> > +        exec date -d "@$SOURCE_DATE_EPOCH" "$@"
> > +    fi
> > +fi
> > +
> > +exec date "$@"
> 
> Could you explain a bit the logic here?

If this script is called with '--date', '--file' or any aliases of
these option, just call `date' as usual. Else, this script force
returned date.


BR,

-- 
Jérôme Pouiller, Sysmic
Embedded Linux specialist
http://www.sysmic.fr



More information about the buildroot mailing list