VirtualBox

source: vbox/trunk/tools/bin/backport-common.sh@ 83667

Last change on this file since 83667 was 83611, checked in by vboxsync, 5 years ago

Forward r137018 & r137019 from 6.1: tools/bin/backport-*.sh: Experimental backporting helper scripts.

  • Property svn:eol-style set to LF
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 4.3 KB
Line 
1# $Id: backport-common.sh 83611 2020-04-07 17:11:42Z vboxsync $
2## @file
3# Common backport script bits.
4#
5
6#
7# Copyright (C) 2020 Oracle Corporation
8#
9# This file is part of VirtualBox Open Source Edition (OSE), as
10# available from http://www.virtualbox.org. This file is free software;
11# you can redistribute it and/or modify it under the terms of the GNU
12# General Public License (GPL) as published by the Free Software
13# Foundation, in version 2 as it comes in the "COPYING" file of the
14# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16#
17
18#
19# Globals.
20#
21 MY_CAT=kmk_cat
22 MY_EXPR=kmk_expr
23MY_PRINTF=kmk_printf
24 MY_RM=kmk_rm
25 MY_SVN=svn
26 MY_SED=kmk_sed
27
28MY_BRANCH_DEFAULT_DIR=`cd "${MY_SCRIPT_DIR}"; cd ../..; pwd -L`
29MY_BRANCH_DEFAULT=`echo "${MY_BRANCH_DEFAULT_DIR}" | "${MY_SED}" -e 's|^\(.*\)/\([^/][^/]*\)$|\2|' -e 's/VBox-//'`
30if test "${MY_BRANCH_DEFAULT}" = "trunk"; then
31 MY_TRUNK_DIR=${MY_BRANCH_DEFAULT_DIR}
32elif test -d "${MY_BRANCH_DEFAULT_DIR}/../../trunk"; then
33 MY_TRUNK_DIR=`cd "${MY_BRANCH_DEFAULT_DIR}"; cd ../../trunk; pwd -L`
34else
35 MY_TRUNK_DIR="^/trunk"
36fi
37
38#
39# Parse arguments.
40#
41MY_BRANCH_DIR=
42MY_BRANCH=
43MY_REVISIONS=
44MY_REVISION_COUNT=0
45MY_EXTRA_ARGS=
46MY_DEBUG=
47
48while test $# -ge 1;
49do
50 ARG=$1
51 shift
52 case "${ARG}" in
53 r[0-9][0-9]*)
54 MY_REV=`echo ${ARG} | "${MY_SED}" -e 's/^r//'`
55 MY_REVISIONS="${MY_REVISIONS} ${MY_REV}"
56 MY_REVISION_COUNT=`${MY_EXPR} ${MY_REVISION_COUNT} + 1`
57 ;;
58
59 [0-9][0-9]*)
60 MY_REVISIONS="${MY_REVISIONS} ${ARG}"
61 MY_REVISION_COUNT=`${MY_EXPR} ${MY_REVISION_COUNT} + 1`
62 ;;
63
64 --trunk-dir)
65 if test $# -eq 0; then
66 echo "error: missing --trunk-dir argument." 1>&2
67 exit 1;
68 fi
69 MY_TRUNK_DIR=`echo "$1" | "${SED}" -e 's|\\\|/|g'`
70 shift
71 ;;
72
73 --branch-dir)
74 if test $# -eq 0; then
75 echo "error: missing --branch-dir argument." 1>&2
76 exit 1;
77 fi
78 MY_BRANCH_DIR=`echo "$1" | "${SED}" -e 's|\\\|/|g'`
79 shift
80 ;;
81
82 --branch)
83 if test $# -eq 0; then
84 echo "error: missing --branch argument." 1>&2
85 exit 1;
86 fi
87 MY_BRANCH="$1"
88 shift
89 ;;
90
91 --extra)
92 if test $# -eq 0; then
93 echo "error: missing --extra argument." 1>&2
94 exit 1;
95 fi
96 MY_EXTRA_ARGS="${MY_EXTRA_ARGS} $1"
97 shift
98 ;;
99
100 --debug)
101 MY_DEBUG=1
102 ;;
103
104 # usage
105 --h*|-h*|-?|--?)
106 echo "usage: $0 [--trunk-dir <dir>] [--branch <ver>] [--branch-dir <dir>] [--extra <svn-arg>] rev1 [rev2..[revN]]]"
107 echo ""
108 echo "Options:"
109 echo " --trunk-dir <dir>"
110 echo " --branch <ver>"
111 echo " --branch-dir <dir>"
112 echo " --extra <svn-arg>"
113 echo ""
114 exit 2;
115 ;;
116
117 *)
118 echo "syntax error: ${ARG}"
119 exit 2;
120 ;;
121 esac
122done
123
124if test -n "${MY_DEBUG}"; then
125 echo " MY_SCRIPT_DIR=${MY_SCRIPT_DIR}"
126 echo "MY_BRANCH_DEFAULT_DIR=${MY_BRANCH_DEFAULT_DIR}"
127 echo " MY_BRANCH_DEFAULT=${MY_BRANCH_DEFAULT}"
128 echo " MY_TRUNK_DIR=${MY_TRUNK_DIR}"
129 echo " MY_REVISIONS=${MY_REVISIONS}"
130fi
131
132#
133# Resolve branch variables.
134#
135if test -z "${MY_BRANCH_DIR}" -a -z "${MY_BRANCH}"; then
136 MY_BRANCH_DIR=${MY_BRANCH_DEFAULT_DIR}
137 MY_BRANCH=${MY_BRANCH_DEFAULT}
138elif test -n "${MY_BRANCH}" -a -z "${MY_BRANCH_DIR}"; then
139 MY_BRANCH_DIR=${MY_BRANCH_DEFAULT_DIR}
140elif test -z "${MY_BRANCH}" -a -n "${MY_BRANCH_DIR}"; then
141 MY_BRANCH=`echo "${MY_BRANCH_DIR}" | "${SED}" -e 's/^-([1]*[5-9]\.[0-5])[/]*$/\1/'`
142 if test -z "${MY_BRANCH}" -o "${MY_BRANCH}" = "${MY_BRANCH_DIR}"; then
143 echo "error: Failed to guess branch name for: ${MY_BRANCH_DIR}" >2
144 echo " Use --branch to specify it." >2
145 exit 2;
146 fi
147fi
148if test "${MY_BRANCH}" = "trunk"; then
149 echo "error: script does not work with 'trunk' as the branch" >2
150 exit 2;
151fi
152
153#
154# Stop if no revisions specified.
155#
156if test -z "${MY_REVISIONS}"; then
157 echo "error: No revisions specified" >&2;
158 exit 2;
159fi
160
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette