]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blame - debian/scripts/misc/gen-auto-reconstruct
UBUNTU: [Debian] autoreconstruct -- generate extend-diff-ignore for links
[mirror_ubuntu-zesty-kernel.git] / debian / scripts / misc / gen-auto-reconstruct
CommitLineData
985db879
AW
1#!/bin/bash
2
79208cb7
AW
3if [ "$#" -ne 3 ]; then
4 echo "Usage: $0 <orig tag>|<base release> <reconstruct> <options>" 1>&2
985db879
AW
5 exit 1
6fi
7tag="$1"
79208cb7
AW
8reconstruct="$2"
9options="$3"
985db879
AW
10
11case "$tag" in
12v*) ;;
13*) tag="v${tag%.*}" ;;
14esac
15
16# Validate the tag.
17count=$( git tag -l "$tag" | wc -l )
18if [ "$count" != 1 ]; then
19 echo "$0: $tag: tag invalid" 1>&2
20 exit 1
21fi
22
23#git ls-tree -r --full-tree HEAD | grep ^120 | \
24#while read mode type blobid name
25
79208cb7
AW
26(
27 # Identify all new symlinks since the proffered tag.
28 echo "# Recreate any symlinks created since the orig."
29 git diff "$tag.." --raw | awk '(/^:000000 120000/ && $5 == "A") { print $NF }' | \
30 while read name
31 do
32 link=$( readlink "$name" )
33
34 echo "[ ! -L '$name' ] && ln -sf '$link' '$name'"
35 done
36
37 # Identify all removed files since the proffered tag.
38 echo "# Remove any files deleted from the orig."
39 git diff "$tag.." --raw | awk '(/^:/ && $5 == "D") { print $NF }' | \
40 while read name
41 do
42 echo "rm -f '$name'"
43 done
44
45 # All done, make sure this does not complete in error.
46 echo "exit 0"
47) >"$reconstruct"
48
49(
50 # Identify all new symlinks since the proffered tag.
51 echo "# Ignore any symlinks created since the orig which are rebuilt by reconstruct."
52 git diff "$tag.." --raw | awk '(/^:000000 120000/ && $5 == "A") { print $NF }' | \
53 while read name
54 do
55 echo "extend-diff-ignore=$name"
56 done
57) >"$options.update"
58
59
60head='^## autoreconstruct -- begin$'
61foot='^## autoreconstruct -- end$'
62sed -i -e "
63 /$head/,/$foot/{
64 /$head/{
65 p;
66 r $options.update
67 };
68 /$foot/p;
69 d
70 }
71" "$options"
72rm -f "$options.update"