Getting the highest version of subversion in my `R CMD build` filename

question following make-the-subversion-revision-number-visible-in-my-r-scripts

R CMD build PKGcreates a file named Package_Version.tar.gz according to the fields in DESCRIPTION.

not only is it not strictly sequential numbering coming from svn, but its format $REV: number $does not take into account the structure number.number-numberexpected after Version:.

I think I would like to use the subversion revision number as the third “coordinate” version of the package. the first and second coordinates will be raised manually with significant changes.

but how do you usually feel?


You can write a bash / grep / awk script that gets the highest Rev from sources, which will not be a problem. But, configureworks up to R CMD build? In this case, it would be possible to create a DESCRIPTION file (not containing source code) from the template file and this highest version number.

My question is about common practice.


The "optimal" answer would allow me to place the package on r-forge and run automatic scripts there, update the third coordinate of the field Version:from the last files transferred in the subdirectory R.

the “good enough” answer will work locally, and I already have it, but I don’t use it anymore, because otherwise I’m used to things that are usually not available.

, . , () .

0
6

svnversion . . littler, , , , :

#!/bin/sh -e

svnversion() {
    svnrevision=`LC_ALL=C svn info | awk '/^Revision:/ {print $2}'`
    svndate=`LC_ALL=C svn info | awk '/^Last Changed Date:/ {print $4,$5}'`

    now=`date`

    cat <<EOF > svnversion.h

// Do not edit!  This file was autogenerated
//      by $0
//      on $now
//
// svnrevision and svndate are as reported by svn at that point in time,
// compiledate and compiletime are being filled gcc at compilation

#include <stdlib.h>

static const char* svnrevision = "$svnrevision";
static const char* svndate = "$svndate";
static const char* compiletime = __TIME__;
static const char* compiledate = __DATE__;

EOF
}

if [ "$#" -ge 0 ]; then
    if [ "$1" = "--svnversion" ]; then
        svnversion
        exit
    fi
fi

test -f svnversion.h || svnversion

Makefile,

void showVersionAndExit() {
    printf("%s ('%s') version %s\n\tsvn revision %s as of %s\n\t"
           "built at %s on %s\n",
           binaryName, programName, VERSION,
           svnrevision, svndate, compiletime, compiledate);
    /* more code below ... */

R, DESCRIPTION, .

, , , :), , svnversion ( ), , DESCRIPTION. , , , , .

+2

'svnversion < work-copy > ' .

, , . ( ), (, ).

$ svnversion --help
usage: svnversion [OPTIONS] [WC_PATH [TRAIL_URL]]

  Produce a compact 'version number' for the working copy path
  WC_PATH.  TRAIL_URL is the trailing portion of the URL used to
  determine if WC_PATH itself is switched (detection of switches
  within WC_PATH does not rely on TRAIL_URL).  The version number
  is written to standard output.  For example:

    $ svnversion . /repos/svn/trunk
    4168

  The version number will be a single number if the working
  copy is single revision, unmodified, not switched and with
  an URL that matches the TRAIL_URL argument.  If the working
  copy is unusual the version number will be more complex:

   4123:4168     mixed revision working copy
   4168M         modified working copy
   4123S         switched working copy
   4123P         partial working copy, from a sparse checkout
   4123:4168MS   mixed revision, modified, switched working copy

  If invoked on a directory that is not a working copy, an
  exported directory say, the program will output 'exported'.

  If invoked without arguments WC_PATH will be the current directory.

Valid options:
  -n [--no-newline]        : do not output the trailing newline
  -c [--committed]         : last changed rather than current revisions
  -h [--help]              : display this help
  --version                : show program version information
+1

script, svn, DESCRIPTION tar.gz.

, Jira, /svn ( Apache ).

0

. Dec 11, 2009 12:01:03 20091211120103. subversion , , .

0

, . /cleanup R CMD build ....

, ...

  • DESCRIPTION.template .
  • subversion DESCRIPTION.
  • cleanup script.
  • accept R CMD build ( DESCRIPTION R CMD build, cleanup).

cleanup:

#!/bin/bash
FLAGS=$(svnversion . | tr -cd A-Z)

VERSIONS=$(svnversion . | tr -d A-Z)
VERSIONS=$(echo $VERSIONS:$VERSIONS | cut -d: -f1,2)
LOW=${VERSIONS%:*}
HIGH=${VERSIONS#*:}

[ $LOW -ne $HIGH ] && echo "- mixed revisions in local copy ($LOW:$HIGH)"
[ "$FLAGS" != "" ] && echo "- local copy has flags: $FLAGS"
echo "- highest revision in local copy: $HIGH"

sed -re "s/(^Version:[^-]*).+$/\1-$HIGH/" DESCRIPTION.template > DESCRIPTION

DATE=`LC_ALL=C svn info | awk '/^Last Changed Date:/ {print $4,$5}'`

now=$(date)
cat <<EOF > R/version.R
# Do not edit!  This file was autogenerated
#      by $0
#      on $now
#
# DO NOT put this file under version control!
#
# SVNVERSION as the highest revision reported by svnversion.
# DATE as the Last Changed Date reported by svn info.

SVNVERSION <- "$HIGH"
SVNDATE <- "$DATE"
EOF

, DESCRIPTION.template > DESCRIPTION, .


, , , .

mario@lt41:~/Local/.../Trunk/Rnens$ R CMD build src
* checking for file 'src/DESCRIPTION' ... OK
* preparing 'src':
* checking DESCRIPTION meta-information ... OK
* running cleanup
- highest revision in local copy: 8762
* removing junk files
* checking for LF line-endings in source and make files
* checking for empty or unneeded directories
* building 'NenS_0.1-8762.tar.gz'

: , , .

0

my current practice is not automated at all: I give the three coordinates of the field the Version:value as in the question, but the third coordinate (svn version number), I update it manually (increasing it by one) before each commit.

works with Emacs (using psvn), I don’t see this as a major limitation, but it’s more work than I would like to do manually, and it’s definitely unsatisfactory in large repositories where the version number is incremented by unbound commits.

0
source

Source: https://habr.com/ru/post/1725378/


All Articles