mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-02-12 02:54:15 +01:00
Make sure version-info is always updated when needed
by doing it every time but only writing if different
This commit is contained in:
parent
97f5d36fea
commit
88d52c1dc5
6
Makefile
6
Makefile
@ -376,10 +376,12 @@ include $(ROOT_DIR)/package/$(UNAME).mk
|
|||||||
# Source for distribution
|
# Source for distribution
|
||||||
#
|
#
|
||||||
##############################
|
##############################
|
||||||
$(DIST_VER_INFO): .git/index | $(DIST_DIR)
|
FORCE:
|
||||||
|
|
||||||
|
$(DIST_VER_INFO): FORCE | $(DIST_DIR)
|
||||||
$(V1) $(VERSION_INFO) --jsonpath="$(DIST_DIR)"
|
$(V1) $(VERSION_INFO) --jsonpath="$(DIST_DIR)"
|
||||||
|
|
||||||
$(DIST_TAR): $(DIST_VER_INFO) .git/index | $(DIST_DIR)
|
$(DIST_TAR): $(DIST_VER_INFO) | $(DIST_DIR)
|
||||||
@$(ECHO) " SOURCE FOR DISTRIBUTION $(call toprel, $(DIST_TAR))"
|
@$(ECHO) " SOURCE FOR DISTRIBUTION $(call toprel, $(DIST_TAR))"
|
||||||
$(V1) git archive --prefix="$(PACKAGE_NAME)/" -o "$(DIST_TAR)" HEAD
|
$(V1) git archive --prefix="$(PACKAGE_NAME)/" -o "$(DIST_TAR)" HEAD
|
||||||
$(V1) tar --append --file="$(DIST_TAR)" \
|
$(V1) tar --append --file="$(DIST_TAR)" \
|
||||||
|
@ -252,8 +252,29 @@ class Repo:
|
|||||||
json_data['dirty'] = False
|
json_data['dirty'] = False
|
||||||
|
|
||||||
json_path = os.path.join(path, 'version-info.json')
|
json_path = os.path.join(path, 'version-info.json')
|
||||||
with open(json_path, 'w') as json_file:
|
|
||||||
json.dump(json_data, json_file)
|
write_if_different(json_path, json.dumps(json_data))
|
||||||
|
|
||||||
|
|
||||||
|
def write_if_different(out_name, out):
|
||||||
|
"""Write ouput to file only if it differs from current"""
|
||||||
|
|
||||||
|
# Check if output file already exists
|
||||||
|
try:
|
||||||
|
of = open(out_name, "rb")
|
||||||
|
except IOError:
|
||||||
|
# No file - create new
|
||||||
|
of = open(out_name, "wb")
|
||||||
|
of.write(out)
|
||||||
|
of.close()
|
||||||
|
else:
|
||||||
|
# File exists - overwite only if content is different
|
||||||
|
inp = of.read()
|
||||||
|
of.close()
|
||||||
|
if inp != out:
|
||||||
|
of = open(out_name, "wb")
|
||||||
|
of.write(out)
|
||||||
|
of.close()
|
||||||
|
|
||||||
def escape_dict(dictionary):
|
def escape_dict(dictionary):
|
||||||
"""Escapes dictionary values for C"""
|
"""Escapes dictionary values for C"""
|
||||||
@ -300,22 +321,8 @@ def file_from_template(tpl_name, out_name, dictionary):
|
|||||||
# Replace placeholders using dictionary
|
# Replace placeholders using dictionary
|
||||||
out = Template(tpl).substitute(dictionary)
|
out = Template(tpl).substitute(dictionary)
|
||||||
|
|
||||||
# Check if output file already exists
|
write_if_different(out_name, out)
|
||||||
try:
|
|
||||||
of = open(out_name, "rb")
|
|
||||||
except IOError:
|
|
||||||
# No file - create new
|
|
||||||
of = open(out_name, "wb")
|
|
||||||
of.write(out)
|
|
||||||
of.close()
|
|
||||||
else:
|
|
||||||
# File exists - overwite only if content is different
|
|
||||||
inp = of.read()
|
|
||||||
of.close()
|
|
||||||
if inp != out:
|
|
||||||
of = open(out_name, "wb")
|
|
||||||
of.write(out)
|
|
||||||
of.close()
|
|
||||||
|
|
||||||
def sha1(file):
|
def sha1(file):
|
||||||
"""Provides C source representation of sha1 sum of file"""
|
"""Provides C source representation of sha1 sum of file"""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user