]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - debian/scripts/misc/gen-auto-reconstruct
UBUNTU: [Packaging] resync git-ubuntu-log
[mirror_ubuntu-bionic-kernel.git] / debian / scripts / misc / gen-auto-reconstruct
CommitLineData
0d34a427
LO
1#!/bin/bash
2
3if [ "$#" -ne 3 ]; then
4 echo "Usage: $0 <orig tag>|<base release> <reconstruct> <options>" 1>&2
5 exit 1
6fi
7tag="$1"
8reconstruct="$2"
9options="$3"
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
26(
27 # Identify all new symlinks since the proffered tag.
28 echo "# Recreate any symlinks created since the orig."
29 git diff "$tag.." --raw --no-renames | 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 --no-renames | awk '(/^:/ && $5 == "D") { print $NF }' | \
40 while read name
41 do
42 echo "rm -f '$name'"
43 done
44
d9ee49d6
SF
45 # Identify files with execute permissions added since the proffered tag.
46 git diff "$tag.." --raw --no-renames | awk -F '[: \t]' '{print $2, $3, $NF }' | \
47 while IFS=" " read old new name
48 do
49 # Exclude files in debian* directories
50 if [[ "$name" =~ ^debian ]]; then
51 continue
52 fi
53
54 old=$( printf "0%s" $old )
55 new=$( printf "0%s" $new )
56 changed=$(( (old ^ new) & 0111 ))
57 if [ "$changed" -ne 0 ]; then
58 echo "chmod +x '$name'"
59 fi
60 done
61
0d34a427
LO
62 # All done, make sure this does not complete in error.
63 echo "exit 0"
64) >"$reconstruct"
65
66(
67 # Identify all new symlinks since the proffered tag.
68 echo "# Ignore any symlinks created since the orig which are rebuilt by reconstruct."
69 git diff "$tag.." --raw --no-renames | awk '(/^:000000 120000/ && $5 == "A") { print $NF }' | \
70 while read name
71 do
2c21160b 72 echo "extend-diff-ignore=^$name\$"
0d34a427
LO
73 done
74) >"$options.update"
75
76
77head='^## autoreconstruct -- begin$'
78foot='^## autoreconstruct -- end$'
79sed -i -e "
80 /$head/,/$foot/{
81 /$head/{
82 p;
83 r $options.update
84 };
85 /$foot/p;
86 d
87 }
88" "$options"
89rm -f "$options.update"