The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/contrib/openzfs/scripts/make_gitrev.sh

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 #!/bin/sh
    2 
    3 #
    4 # CDDL HEADER START
    5 #
    6 # This file and its contents are supplied under the terms of the
    7 # Common Development and Distribution License ("CDDL"), version 1.0.
    8 # You may only use this file in accordance with the terms of version
    9 # 1.0 of the CDDL.
   10 #
   11 # A full copy of the text of the CDDL should have accompanied this
   12 # source.  A copy of the CDDL is also available via the Internet at
   13 # http://www.illumos.org/license/CDDL.
   14 #
   15 # CDDL HEADER END
   16 #
   17 
   18 # Copyright (c) 2018 by Delphix. All rights reserved.
   19 # Copyright (c) 2018 by Matthew Thode. All rights reserved.
   20 
   21 #
   22 # Generate zfs_gitrev.h.  Note that we need to do this for every
   23 # invocation of `make`, including for incremental builds.  Therefore we
   24 # can't use a zfs_gitrev.h.in file which would be processed only when
   25 # `configure` is run.
   26 #
   27 
   28 set -eu
   29 
   30 dist=no
   31 distdir=.
   32 while getopts D: flag
   33 do
   34         case $flag in
   35                 \?) echo "Usage: $0 [-D distdir] [file]" >&2; exit 1;;
   36                 D)  dist=yes; distdir=${OPTARG};;
   37                 *)  ;;
   38         esac
   39 done
   40 shift $((OPTIND - 1))
   41 
   42 top_srcdir="$(dirname "$0")/.."
   43 GITREV="${1:-include/zfs_gitrev.h}"
   44 
   45 # GITREV should be a relative path (relative to top_builddir or distdir)
   46 case "${GITREV}" in
   47         /*) echo "Error: ${GITREV} should be a relative path" >&2
   48             exit 1;;
   49         *) ;;
   50 esac
   51 
   52 ZFS_GITREV=$({ cd "${top_srcdir}" &&
   53         git describe --always --long --dirty 2>/dev/null; } || :)
   54 
   55 if [ -z "${ZFS_GITREV}" ]
   56 then
   57         # If the source directory is not a git repository, check if the file
   58         # already exists (in the source)
   59         if [ -f "${top_srcdir}/${GITREV}" ]
   60         then
   61                 ZFS_GITREV=$(sed -n \
   62                         '1s/^#define[[:blank:]]ZFS_META_GITREV "\([^"]*\)"$/\1/p' \
   63                         "${top_srcdir}/${GITREV}")
   64         fi
   65 elif [ "${dist}" = yes ]
   66 then
   67         # Append -dist when creating distributed sources from a git repository
   68         ZFS_GITREV="${ZFS_GITREV}-dist"
   69 fi
   70 ZFS_GITREV=${ZFS_GITREV:-unknown}
   71 
   72 GITREVTMP="${GITREV}~"
   73 printf '#define\tZFS_META_GITREV "%s"\n' "${ZFS_GITREV}" >"${GITREVTMP}"
   74 GITREV="${distdir}/${GITREV}"
   75 if cmp -s "${GITREV}" "${GITREVTMP}"
   76 then
   77         rm -f "${GITREVTMP}"
   78 else
   79         mv -f "${GITREVTMP}" "${GITREV}"
   80 fi

Cache object: d9402c5ec7cf5e2c0f8a89af279e242b


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.