]> git.proxmox.com Git - pve-kernel.git/blame - debian/scripts/import-upstream-tag
Update sources to Ubuntu-4.15.0-44.47
[pve-kernel.git] / debian / scripts / import-upstream-tag
CommitLineData
c8a6fd78
FG
1#!/bin/bash
2
3set -e
4
5top=$(pwd)
6
7# parameters
8kernel_submodule=
9kernel_patchdir=
10new_tag=
11rebase=
12
13# generated based on new_tag
14pq_branch=
15# previously checked out in submodule
16old_ref=
17
18function cleanup_pq_branch {
19 if [[ -n $pq_branch ]]; then
20 echo "cleaning up PQ branch '$pq_branch'"
21 cd "${top}/${kernel_submodule}"
22 git checkout --quiet $old_ref
23 git reset --hard
24 git branch -D "$pq_branch"
25 fi
26}
27
28function error_exit {
29 echo "$1"
30 set +e
31
32 cleanup_pq_branch
33
34 cd "${top}"
35
36 exit 1
37}
38
39if [[ "$#" -lt 3 || "$#" -gt 4 ]]; then
40 echo "USAGE: $0 submodule patchdir tag [rebase]"
41 echo "\t fetches and checks out 'tag' in 'submodule'"
42 echo "\t if 'rebase' is given, imports, rebases and exports patchqueue from 'patchdir' as well"
43 exit 1
44fi
45
46kernel_submodule=$1
47if [ ! -d "${kernel_submodule}" ]; then
48 error_exit "'${kernel_submodule}' must be a directory!"
49fi
50
51kernel_patchdir=$2
52if [ ! -d "${kernel_patchdir}" ]; then
53 error_exit "'${kernel_patchdir}' must be a directory!"
54fi
55
56new_tag=$3
57rebase=$4
58
59if [[ -n $(git status --untracked-files=no --porcelain) ]]; then
60 error_exit "working directory unclean, aborting"
61fi
62
63
64cd "${kernel_submodule}"
65## check for tag and fetch if needed
66echo "checking for tag '${new_tag}'"
67if [[ -z $(git tag -l "${new_tag}") ]]; then
68 echo "tag not found, fetching and retrying"
69 git fetch --tags
70fi
71if [[ -z $(git tag -l "${new_tag}") ]]; then
72 error_exit "tag not found, aborting"
73fi
74echo "tag found"
75cd "${top}"
76
77if [[ -n "$rebase" ]]; then
78 echo ""
79 echo "automatic patchqueue rebase enabled"
80 cd "${kernel_submodule}"
81 ## preparing patch queue branch
82 old_ref=$(git rev-parse HEAD)
83 pq_branch="auto_pq/${new_tag}"
84 cd "${top}"
85
86 echo "previous HEAD: ${old_ref}"
87
88 echo ""
89 "${top}/debian/scripts/import-patchqueue" "${kernel_submodule}" "${kernel_patchdir}" "${pq_branch}" || error_exit "failed to import patchqueue"
90
91 cd "${kernel_submodule}"
92 ## rebase patches
93 echo ""
94 echo "rebasing patchqueue on top of '${new_tag}'"
95 git rebase "${new_tag}"
96 cd "${top}"
97
98 ## regenerate exported patch queue
99 echo ""
100 "${top}/debian/scripts/export-patchqueue" "${kernel_submodule}" "${kernel_patchdir}" "${new_tag}" || error_exit "failed to export patchqueue"
101
102 cleanup_pq_branch
103 cd "${top}"
104 pq_branch=
105fi
106
107cd "${kernel_submodule}"
108echo ""
109echo "checking out '${new_tag}' in submodule"
110git checkout --quiet "${new_tag}"
111cd "${top}"
112
113echo ""
114echo "committing results"
115git commit --verbose -s -m "update sources to ${new_tag}" -m "(generated with debian/scripts/import-upstream-tag)" "${kernel_submodule}"
116if [[ -n "$rebase" ]]; then
117 git add "${kernel_patchdir}"
118 git commit --verbose -s -m "rebase patches on top of ${new_tag}" -m "(generated with debian/scripts/import-upstream-tag)" "${kernel_patchdir}"
119fi