X-Git-Url: http://pilppa.org/gitweb/gitweb.cgi?a=blobdiff_plain;f=scripts%2Fsetlocalversion;h=1c1bdaf7348a61fc3606165cb1cc5c6725831e05;hb=20bfdbba7212d19613b93dcea93f26cb65af91fe;hp=7c805c8fccd26b7a839079ba9e5268046cb392e9;hpb=d7f6884ae0ae6e406ec3500fcde16e8f51642460;p=linux-2.6-omap-h63xx.git diff --git a/scripts/setlocalversion b/scripts/setlocalversion old mode 100644 new mode 100755 index 7c805c8fccd..1c1bdaf7348 --- a/scripts/setlocalversion +++ b/scripts/setlocalversion @@ -1,56 +1,63 @@ -#!/usr/bin/perl -# Copyright 2004 - Ryan Anderson GPL v2 - -use strict; -use warnings; -use Digest::MD5; -require 5.006; - -if (@ARGV != 1) { - print < -EOT - exit(1); -} - -my ($srctree) = @ARGV; -chdir($srctree); - -my @LOCALVERSIONS = (); - -# We are going to use the following commands to try and determine if this -# repository is at a Version boundary (i.e, 2.6.10 vs 2.6.10 + some patches) We -# currently assume that all meaningful version boundaries are marked by a tag. -# We don't care what the tag is, just that something exists. - -# Git/Cogito store the top-of-tree "commit" in .git/HEAD -# A list of known tags sits in .git/refs/tags/ -# -# The simple trick here is to just compare the two of these, and if we get a -# match, return nothing, otherwise, return a subset of the SHA-1 hash in -# .git/HEAD - -sub do_git_checks { - open(H,"<.git/HEAD") or return; - my $head = ; - chomp $head; - close(H); - - opendir(D,".git/refs/tags") or return; - foreach my $tagfile (grep !/^\.{1,2}$/, readdir(D)) { - open(F,"<.git/refs/tags/" . $tagfile) or return; - my $tag = ; - chomp $tag; - close(F); - return if ($tag eq $head); - } - closedir(D); - - push @LOCALVERSIONS, "g" . substr($head,0,8); -} +#!/bin/sh +# Print additional version information for non-release trees. -if ( -d ".git") { - do_git_checks(); +usage() { + echo "Usage: $0 [srctree]" >&2 + exit 1 } -printf "-%s\n", join("-",@LOCALVERSIONS) if (scalar @LOCALVERSIONS > 0); +cd "${1:-.}" || usage + +# Check for git and a git repo. +if head=`git rev-parse --verify HEAD 2>/dev/null`; then + # Do we have an untagged version? + if git name-rev --tags HEAD | grep -E '^HEAD[[:space:]]+(.*~[0-9]*|undefined)$' > /dev/null; then + git describe | awk -F- '{printf("-%05d-%s", $(NF-1),$(NF))}' + fi + + # Are there uncommitted changes? + git update-index --refresh --unmerged > /dev/null + if git diff-index --name-only HEAD | grep -v "^scripts/package" \ + | read dummy; then + printf '%s' -dirty + fi + + # All done with git + exit +fi + +# Check for mercurial and a mercurial repo. +if hgid=`hg id 2>/dev/null`; then + tag=`printf '%s' "$hgid" | cut -d' ' -f2` + + # Do we have an untagged version? + if [ -z "$tag" -o "$tag" = tip ]; then + id=`printf '%s' "$hgid" | sed 's/[+ ].*//'` + printf '%s%s' -hg "$id" + fi + + # Are there uncommitted changes? + # These are represented by + after the changeset id. + case "$hgid" in + *+|*+\ *) printf '%s' -dirty ;; + esac + + # All done with mercurial + exit +fi + +# Check for svn and a svn repo. +if rev=`svn info 2>/dev/null | grep '^Revision'`; then + rev=`echo $rev | awk '{print $NF}'` + changes=`svn status 2>/dev/null | grep '^[AMD]' | wc -l` + + # Are there uncommitted changes? + if [ $changes != 0 ]; then + printf -- '-svn%s%s%s' "$rev" -dirty "$changes" + else + printf -- '-svn%s' "$rev" + fi + + # All done with svn + exit +fi