/usr/bin/ui-auto-uvc is in ui-auto 1.1.17-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 | #!/bin/bash -e
VCS_SUPPORTED="cvs svn git local"
autoDetectVCS()
{
if [ -d "CVS" ]; then
echo -n "cvs"
elif [ -d ".svn" ]; then
echo -n "svn"
elif [ -d ".git" ]; then
echo -n "git"
else
echo -n "local"
fi
}
COMMANDS="check_installation path version update check_sync diff add commit tag branch changelog news checkout"
# Options
PATH="${PATH}:$(dirname $0):/usr/local/share/ui-auto:/usr/share/ui-auto"
. ui-libopt.sh
ui_opt_init "Unified version control tool for ui-auto tasks." \
"This tool autodetects the used versioning control system and
unifies a selection of common tasks needed by ui-auto
tools. This is not a full featured version control tool.
VC paths have the common syntax 'LOCATION/TAG' (i.e., TAG is
after the last literal '/' and must not contain '/' itself).
This string is interpeted differently for the different VC
systems:
LOCAL(meta): 'LOCALPATH': Will just 'cp -a' locally.
Example: '/home/user/src/myproject/'.
CVS: 'CVSROOT;MODULE/TAG': TAG is an CVS tag. Empty or
TAG=HEAD is the same. ';' is separator and must not be
used elsewhere.
Example: 'cvs.myhost.org:/my/repo/path/repo;myproject/MYPROJECT_1_2_3'.
SVN: 'SVNURL/TAG': TAG just adds to the svn path (a svnpath alone is unique).
Example: 'svn://svn.myhost.org/my/repo/path/tags/myproject/MYPROJECT_1_2_3'
GIT: 'GITURL/TAG': TAG is a git branch. If empty, we stay on repo's default branch.
Example: 'ssh://git.myhost.org/my/git/path/myprojec.git/MYPROJECT_1_2_3'"
ui_opt_add "s" "Only print the autodetected vc system id."
ui_opt_add "S:" "Set VC System id arbitrarily. Supported: ${VCS_SUPPORTED}." "$(autoDetectVCS)"
ui_opt_add "m:" "Message for this action." "ui-auto-uvc: No user message." "" \
"Note that it depends on the used UVC command and the VC used how and if this is used."
ui_opt_addPos CMD "UVC command: ${COMMANDS}." "" "\
* check_installation : Check whether version control tools are installed.
* path : Print current working directory's VC path.
* version : Print a VC version string (suitable for snapshots).
* update : Update working directory w/ server.
* check_sync : Check that working directory has no uncommited changes and is up-to-date w/ server (where applicable).
* diff FILE : Display diff for file.
* add FILES : Add files to version control.
* commit FILES : Check-in FILES (-m may be used).
* tag NAME [DEST] : Tag repository using NAME (use DEST for VCSes that copy for tags).
* branch NAME [DEST] : Branch repository using NAME (use DEST for VCSes that copy for branches).
* changelog : Generate ChangeLog from the VCSes logs.
* news SINCE : Generate NEWS text (first line of VC checkins).
* checkout VCPATH DIR : Checkout a from VC path to DIR (you need to explicitly set VCS via -S).
See above for the syntax of VCPATH."
ui_opt_addPos OPT1 "Option 1 for command."
ui_opt_addPos OPT2 "Option 2 for command."
ui_opt_parse "$@"
# Check whether command exists (error exit), and is defined for the VC we use
vcHas()
{
local c="${1}"
local k
for k in ${COMMANDS}; do
if [ "${k}" = "${c}" ] && [ "$(type -t ${VCS}_cmd_${1})" = "function" ]; then
return 0
fi
done
ui_opt_error "Unknown command: ${c}"
}
checkOpts()
{
local n
for n in ${1}; do
ui_opt_getPos ${n} >/dev/null
done
}
#
# CVS
#
cvs_cmd_check_installation()
{
ui_check_installed "cvs --version"
ui_check_installed "/usr/bin/cvs2cl --version" warnonly
}
cvs_cmd_version()
{
# Just use a timestamp for CVS
echo "${VCS}$(date --utc +%Y%m%d%H%M%S)"
}
cvs_cmd_path()
{
local cvsroot=$(cat CVS/Root)
local module=$(cat CVS/Repository)
# Tag: We must strip first char
local tag=$(cat CVS/Tag 2>/dev/null)
tag=${tag:1}
echo "${cvsroot};${module}/${tag}"
}
cvs_cmd_update()
{
cvs update
}
cvs_cmd_check_sync()
{
if cvs -n update 2>&1 | grep "^[ARMCUP] "; then
ui_opt_error "${VCS} not in sync with server; please resolve above discrepancies" QUIET
fi
}
cvs_cmd_diff()
{
checkOpts "1"
cvs diff $(ui_opt_getPos 1)
}
cvs_cmd_add()
{
checkOpts "1"
cvs add $(ui_opt_getPos 1)
}
cvs_cmd_commit()
{
checkOpts "1"
cvs commit -m"$(ui_opt_get m)" $(ui_opt_getPos 1)
}
cvs_cmd_tag()
{
checkOpts "1"
cvs tag $(ui_opt_getPos 1)
}
cvs_cmd_branch()
{
checkOpts "1"
cvs tag -b $(ui_opt_getPos 1)
}
cvs_cmd_changelog()
{
ui_run_alt "/usr/bin/cvs2cl" "cvs log"
}
# SYNTAX: 'CVSROOT;CVSMODULE/TAG"
cvs_cmd_checkout()
{
checkOpts "1 2"
local vcpath=$(ui_opt_getPos 1)
local dir=$(ui_opt_getPos 2)
# Parse root, module and tag
local root=$(echo "${vcpath}" | cut -d";" -f1)
local rest=$(echo "${vcpath}" | cut -d";" -f2- | rev)
local module=$(echo "${rest}" | cut -d"/" -f2- | rev)
local tag=$(echo "${rest}" | cut -d"/" -f1 | rev)
local tagoption=""
[ -z "${tag}" ] || tagoption="-r ${tag}"
cvs -d "${root}" checkout -d "${dir}" ${tagoption} "${module}"
}
#
# SVN
#
svn_cmd_check_installation()
{
ui_check_installed "svn --version"
ui_check_installed "/usr/bin/svn2cl --version" warnonly
}
svn_cmd_version()
{
echo "svn$(svnversion)"
}
svn_cmd_path()
{
local url=$(svn info . | grep -i "^URL:" | cut -d" " -f2-)
# We don't care about /TAG, it just adds to the path anyway for svn
echo "${url}"
}
svn_cmd_update()
{
svn update
}
svn_cmd_check_sync()
{
local svn_stat=$(svn status --show-updates --quiet | grep --invert-match "^Status " || true)
if [ -n "${svn_stat}" ]; then
echo "${svn_stat}"
ui_opt_error "${VCS} not in sync with server; please resolve above discrepancies" QUIET
fi
}
svn_cmd_diff()
{
checkOpts "1"
svn diff $(ui_opt_getPos 1)
}
svn_cmd_add()
{
checkOpts "1"
svn add $(ui_opt_getPos 1)
}
svn_cmd_commit()
{
checkOpts "1"
svn commit -m"$(ui_opt_get m)" $(ui_opt_getPos 1)
}
svn_cmd_tag()
{
checkOpts "1 2"
local tag="$(ui_opt_getPos 1)"
local dest="$(ui_opt_getPos 2)"
svn copy --parents -m"$(ui_opt_get m)" "$(ui-auto-uvc path)" "${dest}/${tag}"
}
svn_cmd_branch()
{
svn_cmd_tag
}
svn_cmd_changelog()
{
ui_run_alt "/usr/bin/svn2cl" "svn log"
}
# SYNTAX: SVNURL/TAG
svn_cmd_checkout()
{
checkOpts "1 2"
local vcpath=$(ui_opt_getPos 1)
local dir=$(ui_opt_getPos 2)
svn checkout "${vcpath}" "${dir}"
}
#
# GIT
#
# Get the branch we are currently on
gitGetCurrentBranch()
{
git branch | grep "^\*" | cut -d ' ' -f2-
}
git_cmd_check_installation()
{
ui_check_installed "git --version"
ui_check_installed "/usr/share/gnulib/build-aux/gitlog-to-changelog --version" warnonly
}
git_cmd_version()
{
git show --pretty="${VCS}%h" ${2} | head -1
}
git_cmd_path()
{
echo "$(git config remote.origin.url)/$(gitGetCurrentBranch)"
}
git_cmd_update()
{
git pull
}
git_cmd_check_sync()
{
# Check for local changes or extra files
local lchanges=$(git ls-files --exclude-standard --modified --others)
if [ -n "${lchanges}" ]; then
echo "${lchanges}" >&2
ui_opt_error "${VCS} repo has local modifications or untracked files" QUIET
fi
# Check for uncommited changes in staging area
if ! git diff --exit-code --cached; then
ui_opt_error "You have uncommited changes in staging; please commit first." QUIET
fi
# Check if corresponding remote tip equals our tip
git fetch
local branch=$(gitGetCurrentBranch)
if ! git diff --exit-code origin/${branch}; then
ui_opt_error "Your local branch ${branch} differs from origin/${branch}" QUIET
fi
}
git_cmd_diff()
{
checkOpts "1"
git diff $(ui_opt_getPos 1)
}
git_cmd_add()
{
checkOpts "1"
git add $(ui_opt_getPos 1)
}
git_cmd_commit()
{
checkOpts "1"
git commit -m"$(ui_opt_get m)" $(ui_opt_getPos 1)
}
git_cmd_tag()
{
checkOpts "1"
git tag $(ui_opt_getPos 1)
}
git_cmd_branch()
{
checkOpts "1"
git branch $(ui_opt_getPos 1)
}
git_cmd_changelog()
{
ui_run_alt "/usr/share/gnulib/build-aux/gitlog-to-changelog" "git log --pretty --numstat --summary"
}
git_cmd_news()
{
checkOpts "1"
git shortlog $(ui_opt_getPos 1)..HEAD
}
# SYNTAX: REMOTEURL/BRANCH
git_cmd_checkout()
{
checkOpts "1 2"
local vcpath=$(ui_opt_getPos 1)
local dir=$(ui_opt_getPos 2)
# Parse root, module and tag
local remote=$(echo "${vcpath}" | rev | cut -d"/" -f2- | rev)
local branch=$(echo "${vcpath}" | rev | cut -d"/" -f1 | rev)
git clone --branch="${branch}" "${remote}" "${dir}"
}
#
# LOCAL (meta VC)
#
local_cmd_check_installation()
{
return 0
}
local_cmd_version()
{
date --utc +%Y%m%d%H%M%S
}
local_cmd_path()
{
pwd
}
local_cmd_checkout()
{
checkOpts "1 2"
local src=$(ui_opt_getPos 1)
local dest=$(ui_opt_getPos 2)
if [ -z "${src}" ]; then
ui_opt_error "Empty source directory" QUIET
fi
cp -a "${src}/." "${dest}"
}
#
# Start processing
#
# Set VC system to use
VCS=$(ui_opt_get S)
# Handle special options
if ui_opt_given s; then
# Print vc system id only
echo -n "${VCS}"
exit 0
fi
# Run the given command
CMD=$(ui_opt_getPos 0)
if vcHas ${CMD}; then
${VCS}_cmd_${CMD}
else
echo "W: VC(${VCS}): \"${CMD}\": Not implemented (skipping)." >&2
fi
exit 0
|