]>
Commit | Line | Data |
---|---|---|
5cc78bf9 AW |
1 | #!/bin/bash |
2 | ||
3 | remote_repo='' | |
4 | sru_cycle= | |
5 | while : | |
6 | do | |
7 | if [ "$1" = "--remote-repo" ]; then | |
8 | remote_repo="$2" | |
9 | shift 2 | |
10 | ||
11 | elif [ "$1" = "--sru-cycle" ]; then | |
12 | sru_cycle="$2" | |
13 | shift 2 | |
14 | ||
15 | else | |
16 | break | |
17 | fi | |
18 | done | |
19 | if [ "$#" -ne 0 ]; then | |
20 | { | |
21 | echo "Usage: $0 [<options>]" | |
22 | echo " --remote-repo <url>" | |
23 | echo " --sru-cycle <cycle>" | |
24 | } 1>&2 | |
25 | exit 1 | |
26 | fi | |
27 | ||
28 | default_sru_cycle() | |
29 | { | |
30 | local tracking_bug | |
31 | local version | |
32 | ||
33 | # Pick out the cycle from the tracking bug file. | |
34 | if [ -f "$DEBIAN/tracking-bug" ]; then | |
35 | read tracking_bug sru_cycle X <"$DEBIAN/tracking-bug" | |
36 | fi | |
37 | ||
38 | if [ -z "$sru_cycle" ]; then | |
39 | echo "$0: sru-cycle not found via debian/tracking-bug; specify --sru-cycle" 1>&2 | |
40 | exit 1 | |
41 | fi | |
42 | ||
43 | sru_cycle=$(echo "$sru_cycle" | sed -e 's/-[0-9][0-9]*$//' -e 's/^kernel-sru-cycle-//') | |
44 | ||
45 | #echo "default_sru_cycle: version<$version> sru_cycle<$sru_cycle>" | |
46 | } | |
47 | ||
48 | # Determine where our changelog is. | |
49 | DEBIAN=debian | |
50 | [ -f 'debian/debian.env' ] && . 'debian/debian.env' | |
51 | ||
52 | [ -z "$sru_cycle" ] && default_sru_cycle | |
53 | if [ -z "$remote_repo" ]; then | |
54 | case "$sru_cycle" in | |
55 | s[0-9][0-9][0-9][0-9].[0-9][0-9].[0-9][0-9]) | |
56 | remote_repo='security' ;; | |
57 | *) | |
58 | remote_repo='main' ;; | |
59 | esac | |
60 | fi | |
61 | case "$remote_repo" in | |
62 | security) | |
63 | remote_repo='ssh+git://git.launchpad.net/~canonical-kernel-security-team/canonical-kernel-private/+git/kernel-versions' | |
64 | remote_name='security' | |
65 | ;; | |
66 | main) | |
67 | remote_repo='git://git.launchpad.net/~canonical-kernel/+git/kernel-versions' | |
68 | remote_name='main' | |
69 | ;; | |
70 | *) | |
71 | remote_name='adhoc' | |
72 | ;; | |
73 | esac | |
74 | ||
75 | # | |
76 | # kernel-versoins repository dkms-version mapping see below for details: | |
77 | # https://git.launchpad.net/~canonical-kernel/+git/kernel-versions/plain/README | |
78 | # | |
79 | kv_repo="$HOME/.cache/kernel-versions-bare" | |
80 | git_base="$remote_name/$sru_cycle" | |
81 | ||
82 | # Now we know where our repo is and what it called update it. | |
83 | # We maintain "persistent" remotes for main and security, but assume | |
84 | # any manually supplied entries are transient. | |
85 | ( | |
86 | [ ! -d "$kv_repo" ] && mkdir -p "$kv_repo" | |
87 | cd "$kv_repo" || exit 1 | |
88 | [ ! -f config ] && git init -q --bare | |
89 | current_url=$(git config "remote.$remote_name.url") | |
90 | if [ -z "$current_url" ]; then | |
91 | git remote add "$remote_name" "$remote_repo" | |
92 | elif [ "$current_url" != "$remote_repo" ]; then | |
93 | git config "remote.$remote_name.url" "$remote_repo" | |
94 | fi | |
95 | git fetch -q -p "$remote_name" | |
96 | ) || exit 1 | |
97 | ||
98 | cat_file() | |
99 | { | |
100 | (cd "$kv_repo" && git cat-file "$@") || exit 1 | |
101 | } | |
102 | ||
103 | # Determine if we have this cycle. | |
104 | present=$(cat_file -t "$git_base" 2>/dev/null) | |
105 | if [ "$present" = "" ]; then | |
106 | # If we don't have the cycle in the development cycle then | |
107 | # fall back to master. | |
108 | case "$sru_cycle" in | |
109 | d*) git_base="$remote_name/master" ;; | |
110 | *) echo "$sru_cycle: cycle not found in $remote_repo" 2>&1 | |
111 | exit 1 | |
112 | ;; | |
113 | esac | |
114 | fi | |
115 | ||
116 | # Determine our series and mainline version from our own changelog. | |
117 | our_series=$(LC_ALL=C dpkg-parsechangelog -l"$DEBIAN/changelog" -SDistribution) | |
118 | if [ "$series" = "UNRELEASED" ]; then | |
119 | our_series=$(LC_ALL=C dpkg-parsechangelog -l"$DEBIAN/changelog" -c1 -SDistribution) | |
120 | fi | |
121 | our_mainline=$(LC_ALL=C dpkg-parsechangelog -l"$DEBIAN/changelog" -SVersion | sed -e 's/-.*//') | |
122 | ||
123 | # Update rules are complex. We update development series kernels to the | |
124 | # versions in development. For stable series we update versions against | |
125 | # the series in which our prime kernel was built. This is expressed | |
126 | # via the map/dkms-versions namespace. Attempt to map via our series | |
127 | # and then our mainline-version. | |
128 | ||
129 | # Attempt to map via our series, if that works assume we are development. | |
130 | versions_path=$(cat_file -p "$git_base:map/dkms-versions/$our_series" 2>/dev/null) | |
131 | ||
132 | # If we do not yet have a mapping re-map using our mainline version. | |
133 | if [ -z "$versions_path" ]; then | |
134 | versions_path=$(cat_file -p "$git_base:map/dkms-versions/$our_mainline") | |
135 | fi | |
136 | ||
137 | echo "git_base<$git_base> versions_path<$versions_path>" | |
138 | echo "II: grabbing dkms-versions from $sru_cycle $versions_path" | |
139 | ||
140 | cat_file -p "$git_base:$versions_path" >"debian/dkms-versions.new" | |
141 | rc="$?" | |
142 | if [ "$rc" -ne 0 ]; then | |
143 | echo "$0: unable to download an updated dkms-versions file" 1>&2 | |
144 | exit 1 | |
145 | ||
146 | elif [ "$rc" -eq 0 ]; then | |
147 | mv "debian/dkms-versions.new" "debian/dkms-versions" | |
148 | ||
149 | else | |
150 | rm -f "debian/dkms-versions.new" | |
151 | fi | |
152 | ||
153 | thing="debian/dkms-versions" | |
154 | if ! git diff --exit-code -- "$thing" >/dev/null; then | |
155 | git commit -m "UBUNTU: $thing -- update from kernel-versions ($git_base)" \ | |
156 | -m "BugLink: https://bugs.launchpad.net/bugs/1786013" \ | |
157 | -s -- "$thing" | |
158 | else | |
159 | echo "$thing: no changes from kernel-versions" | |
160 | fi | |
161 | ||
162 | exit "$rc" |