Skip to content
Snippets Groups Projects
Commit 24788c3b authored by Clemens Terasa's avatar Clemens Terasa
Browse files

guf-recipe: Get rid of .version files

The required git-version.inc introduced .version files when used with
guf-recipe.inc. This results in layer changes when the source comes from
a in-tree sources.

There is no issue known to us, that the version files ever helped. Thus
keeping this "feature" seems pointless.

This also deactivates the SVN-like revision patching, that has the same
issue.
parent 3c9f1290
No related branches found
No related tags found
1 merge request!1Minor cleanups
#
# Setups up the package version to <major>-<rsvnrev>
# Saves the result to src/version
#
def write_version_file(file, version):
path=os.path.dirname(file)
try:
os.makedirs(path, exist_ok=True)
except:
bb.error('Failed to create directory: {} '.format(path))
pass
with open(file, 'w') as f:
f.write(version + '\n')
def read_version_file(file):
try:
f = open(file, 'r')
except:
#bb.debug( 2, ('Failed to read file: {}'.format(file)) )
return ''
version=f.read().rstrip()
f.close()
return version
python __anonymous () {
import subprocess
import bb
import time
updatedversion=0
package=str(d.getVar('PN', True))
bb.debug( 2, package + ": Execute git-version.inc" )
thisdir=d.getVar('THISDIR', True)
bb.debug( 2, package + ': This dir: ' + thisdir )
versionfile=thisdir + '/files/' + package + '.version'
versionfile=versionfile.replace("//","/")
bb.debug( 2, 'using dir: {}'.format(thisdir))
# get major version from recipe
major = bb.parse.BBHandler.vars_from_file(d.getVar('FILE', False),d)[1] or '1.0'
bb.debug( 2, package + ": Major: " + str(major) )
version=str(major)
#use git format to query hash and date
result=''
cmd=['git','log','-n','1','--format="%h %ad"','--date=short','--', '.' ]
try:
with subprocess.Popen(cmd,stdout=subprocess.PIPE,cwd=thisdir) as p:
result=p.stdout.read().decode().strip()
except:
pass
rev=''
if len(result) > 0:
hash,date=result.replace('"','').split()
rev="{}".format(date.replace('-',''))
if len(rev) > 0:
updatedversion=1
bb.debug( 2, "Revision: " + rev )
version='{}-{}'.format(major, rev)
else:
bb.debug( 2, 'Try to read svn version from file' )
ver= read_version_file(versionfile)
if len(ver) > 0:
version=str(ver)
else:
#bb.debug( 2, ("Failed to read version from file, try again in a second") )
time.sleep(1)
ver= read_version_file(versionfile)
if len(ver) > 0:
version=str(ver)
else:
bb.warn("Failed to determine git version for package %s, fall back to 0." % package)
version=str(major)
write_version_file(versionfile, version)
bb.debug( 2, "Version: {}".format(version) )
#Create 'version' file to use in source code and for later usage in the bsp
#Write version file when we got the version from svn
if updatedversion:
write_version_file(versionfile, version)
d.setVar('PV', version)
src_uri = d.getVar('SRC_URI')
d.setVar('SRC_URI', src_uri + ' file://' + package + '.version')
d.setVar('SVNVERSION',version)
versiondate=version.split('-')
try:
versiondate=versiondate[1]
except Exception:
versiondate=""
d.setVar('LASTCHANGEDATE',versiondate)
bb.debug( 2, package + ": Done git-version.inc" )
}
do_replace_svnrevision() {
echo "Replace '\$Revsion\$' expression with ${LASTCHANGEDATE}"
for i in $( find ${S} -type f );
do
echo "sed -i -e "s/\$Revision[^\\$]*\\$/\$Revision: ${LASTCHANGEDATE}\$/g" $i"
sed -i -e "s/\$Revision[^\\$]*\\$/\$Revision: ${LASTCHANGEDATE}\$/g" $i
done
echo "Done replace svnrevision"
}
# Add this line to recipes using this feature
#addtask do_replace_svnrevision after do_unpack before do_configure
......@@ -5,5 +5,3 @@ HOMEPAGE = "http://www.garz-fricke.de/"
LICENSE = "Apache-2.0"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10"
require conf/git-version.inc
1.0-20180212
......@@ -2,8 +2,7 @@ SUMMARY = "Garz & Fricke I2C test tool"
require conf/guf-recipe.inc
DEPENDS += "virtual/kernel"
PE="1"
FILESEXTRAPATHS_prepend := "${THISDIR}:"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment