From 16c0915b26deb9719a46e86be4063acfae28dfdc Mon Sep 17 00:00:00 2001 From: James Duley Date: Sat, 14 May 2016 14:51:02 +0100 Subject: [PATCH 1/6] LP-317: Update fedora package for OSG --- package/linux/rpmspec.in | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/package/linux/rpmspec.in b/package/linux/rpmspec.in index d175b4d26..3b783ac66 100644 --- a/package/linux/rpmspec.in +++ b/package/linux/rpmspec.in @@ -24,6 +24,8 @@ BuildRequires: qt5-qtserialport-devel BuildRequires: qt5-qtsvg-devel BuildRequires: qt5-qttools-devel BuildRequires: qt5-qttranslations +BuildRequires: OpenSceneGraph-devel +%{!?fc22:BuildRequires: osgearth-devel} BuildRequires: dwz BuildRequires: pkgconfig BuildRequires: python @@ -38,6 +40,8 @@ Requires: qt5-qtmultimedia Requires: qt5-qtscript Requires: qt5-qtserialport Requires: qt5-qtsvg +Requires: OpenSceneGraph-libs +%{!?fc22:Requires: osgearth} %description @@ -55,7 +59,8 @@ make config_new \ prefix=%{_prefix} \ QMAKE=qmake-qt5 \ udevrulesdir=%{_udevrulesdir} \ - WITH_PREBUILT_FW=$(pwd)/build/firmware + WITH_PREBUILT_FW=$(pwd)/build/firmware \ + GCS_EXTRA_CONF='osg%{!?fc22: osgearth}' make %{?_smp_mflags} opfw_resource gcs @@ -87,7 +92,6 @@ rm -rf $RPM_BUILD_ROOT # %{_libdir}/librepilot-gcs/libAggregation.so.1* %{_libdir}/librepilot-gcs/libExtensionSystem.so.1* -%{_libdir}/librepilot-gcs/libGLC_lib.so.1* %{_libdir}/librepilot-gcs/libopmapwidget.so.1* %{_libdir}/librepilot-gcs/libQScienceSpinBox.so.1* %{_libdir}/librepilot-gcs/libQtConcurrent.so.1* From 97f5d36fea575888d5beb2531b89dadf3c7bd170 Mon Sep 17 00:00:00 2001 From: James Duley Date: Sat, 14 May 2016 16:24:44 +0100 Subject: [PATCH 2/6] LP-317: Make rpm spec less sensitive to file changes by including everything rather than explicitly listing files Also removes hardcoded project name --- package/linux/rpmspec.in | 23 ++++------------------- 1 file changed, 4 insertions(+), 19 deletions(-) diff --git a/package/linux/rpmspec.in b/package/linux/rpmspec.in index 3b783ac66..330a36f7b 100644 --- a/package/linux/rpmspec.in +++ b/package/linux/rpmspec.in @@ -82,25 +82,10 @@ rm -rf $RPM_BUILD_ROOT %defattr(-,root,root) %doc README.md CREDITS.txt WHATSNEW.txt %doc GPLv3.txt -%{_bindir}/librepilot-gcs -%{_udevrulesdir}/45-librepilot.rules -%{_datadir}/applications/librepilot.desktop -%{_datadir}/librepilot-gcs/* -%{_datadir}/pixmaps/librepilot.png -%{_libdir}/librepilot-gcs/plugins/LibrePilot/*.pluginspec -%{_libdir}/librepilot-gcs/plugins/LibrePilot/*.so -# -%{_libdir}/librepilot-gcs/libAggregation.so.1* -%{_libdir}/librepilot-gcs/libExtensionSystem.so.1* -%{_libdir}/librepilot-gcs/libopmapwidget.so.1* -%{_libdir}/librepilot-gcs/libQScienceSpinBox.so.1* -%{_libdir}/librepilot-gcs/libQtConcurrent.so.1* -%{_libdir}/librepilot-gcs/libQwt.so.1* -%{_libdir}/librepilot-gcs/libsdlgamepad.so.1* -%{_libdir}/librepilot-gcs/libUtils.so.1* -%{_libdir}/librepilot-gcs/libVersionInfo.so.1* -# -%{_libdir}/librepilot-gcs/lib*.so +%{_bindir}/* +%{_udevrulesdir}/* +%{_datadir}/* +%{_libdir}/* %changelog From 88d52c1dc5f27b365e513c36fbc1c6b8f6a25a76 Mon Sep 17 00:00:00 2001 From: James Duley Date: Sat, 14 May 2016 18:25:22 +0100 Subject: [PATCH 3/6] Make sure version-info is always updated when needed by doing it every time but only writing if different --- Makefile | 6 +++-- make/scripts/version-info.py | 43 +++++++++++++++++++++--------------- 2 files changed, 29 insertions(+), 20 deletions(-) diff --git a/Makefile b/Makefile index dde9d8cb3..21490caee 100644 --- a/Makefile +++ b/Makefile @@ -376,10 +376,12 @@ include $(ROOT_DIR)/package/$(UNAME).mk # Source for distribution # ############################## -$(DIST_VER_INFO): .git/index | $(DIST_DIR) +FORCE: + +$(DIST_VER_INFO): FORCE | $(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))" $(V1) git archive --prefix="$(PACKAGE_NAME)/" -o "$(DIST_TAR)" HEAD $(V1) tar --append --file="$(DIST_TAR)" \ diff --git a/make/scripts/version-info.py b/make/scripts/version-info.py index 47d94a1ce..a06e96b21 100644 --- a/make/scripts/version-info.py +++ b/make/scripts/version-info.py @@ -252,8 +252,29 @@ class Repo: json_data['dirty'] = False 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): """Escapes dictionary values for C""" @@ -300,22 +321,8 @@ def file_from_template(tpl_name, out_name, dictionary): # Replace placeholders using dictionary out = Template(tpl).substitute(dictionary) - # 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() + write_if_different(out_name, out) + def sha1(file): """Provides C source representation of sha1 sum of file""" From 7250a7156c4f417f72baa578731fdf7709c92627 Mon Sep 17 00:00:00 2001 From: James Duley Date: Sat, 14 May 2016 18:44:23 +0100 Subject: [PATCH 4/6] LP-317: Make rpm spec depend on version-info so that it is always rebuilt when needed --- package/linux/rpm.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package/linux/rpm.mk b/package/linux/rpm.mk index 53a544ff9..8da6d6dba 100644 --- a/package/linux/rpm.mk +++ b/package/linux/rpm.mk @@ -25,7 +25,7 @@ SPEC_FILE_IN := $(ROOT_DIR)/package/linux/rpmspec.in .PHONY: rpmspec rpmspec: $(SPEC_FILE) -$(SPEC_FILE): $(SPEC_FILE_IN) | $(RPM_DIRS) +$(SPEC_FILE): $(SPEC_FILE_IN) $(DIST_VER_INFO) | $(RPM_DIRS) $(V1) cp -f $(SPEC_FILE_IN) $(SPEC_FILE) $(V1) $(SED_SCRIPT) $(SPEC_FILE) From d385c789f626da3bf8600563a4a2090e8c686022 Mon Sep 17 00:00:00 2001 From: James Duley Date: Sun, 15 May 2016 21:24:57 +0100 Subject: [PATCH 5/6] Add rule to upload debian source package --- package/linux/deb.mk | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/package/linux/deb.mk b/package/linux/deb.mk index 79668b0ca..0412dfcf6 100644 --- a/package/linux/deb.mk +++ b/package/linux/deb.mk @@ -9,6 +9,7 @@ endif DEB_NAME := $(ORG_SMALL_NAME) DEB_ORIG_SRC := $(PACKAGE_DIR)/$(DEB_NAME)_$(UPSTREAM_VER).orig.tar.gz DEB_ORIG_FW := $(PACKAGE_DIR)/$(DEB_NAME)_$(UPSTREAM_VER).orig-firmware.tar.gz +DEB_SRC_CHANGES := $(PACKAGE_DIR)/$(DEB_NAME)_$(UPSTREAM_VER)-$(DEB_REV)_source.changes DEB_PACKAGE_DIR := $(PACKAGE_DIR)/$(DEB_NAME)-$(UPSTREAM_VER) DEB_ARCH := $(shell dpkg --print-architecture) DEB_PACKAGE_NAME := $(DEB_NAME)_$(UPSTREAM_VER)-$(DEB_REV)_$(DEB_ARCH) @@ -37,7 +38,7 @@ package: debian @$(ECHO) "Building Linux package, please wait..." $(V1) sed -i -e "$(PACKAGE_DEPS_SED)" debian/control $(V1) sed -i -e 's,config_new.*, --help > /dev/null,' debian/rules - $(V1) dpkg-buildpackage -b -us -uc -nc $(DPKG_BUILDPACKAGE_OPTS) + $(V1) dpkg-buildpackage -b -us -uc -nc $(V1) mv $(ROOT_DIR)/../$(DEB_PACKAGE_NAME).deb $(BUILD_DIR) $(V1) mv $(ROOT_DIR)/../$(DEB_PACKAGE_NAME).changes $(BUILD_DIR) $(V1) rm -r debian @@ -56,8 +57,23 @@ ifeq ($(DEB_DIST), trusty) endif .PHONY: package_src -package_src: $(DEB_ORIG_SRC_NAME) $(DEB_PACKAGE_DIR) - $(V1) cd $(DEB_PACKAGE_DIR) && dpkg-buildpackage -S -us -uc $(DPKG_BUILDPACKAGE_OPTS) +package_src: $(DEB_SRC_CHANGES) + +.PHONY: package_src_upload +package_src_upload: $(DEB_SRC_CHANGES) + $(V1) debsign $(DEB_SRC_CHANGES) + $(V1) dput $(DPUT_URL) $(DEB_SRC_CHANGES) + +# Only include the orig if it we haven't alreadly built it, +# because if we have it is likely to be uploaded already +ifeq ($(wildcard $(DEB_ORIG_SRC)),) +DPKG_INCLUDE_ORIG := -sa +else +DPKG_INCLUDE_ORIG := -sd +endif + +$(DEB_SRC_CHANGES): $(DEB_ORIG_SRC_NAME) $(DEB_PACKAGE_DIR) + $(V1) cd $(DEB_PACKAGE_DIR) && dpkg-buildpackage -S -us -uc $(DPKG_INCLUDE_ORIG) $(DEB_ORIG_SRC): $(DIST_TAR_GZ) | $(PACKAGE_DIR) $(V1) cp $(DIST_TAR_GZ) $(DEB_ORIG_SRC) From ee0e69dc626be79abf55a9ded05207d13af7e4c6 Mon Sep 17 00:00:00 2001 From: James Duley Date: Mon, 16 May 2016 22:01:05 +0100 Subject: [PATCH 6/6] LP-317: Add make rule to upload to Copr --- package/linux/rpm.mk | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/package/linux/rpm.mk b/package/linux/rpm.mk index 8da6d6dba..4528bcdd7 100644 --- a/package/linux/rpm.mk +++ b/package/linux/rpm.mk @@ -38,6 +38,10 @@ $(RPM_PACKAGE_FILE): RPMBUILD_OPTS := -bb package_src: $(RPM_PACKAGE_SRC) $(RPM_PACKAGE_SRC): RPMBUILD_OPTS := -bs +.PHONY: package_src_upload +package_src_upload: $(RPM_PACKAGE_SRC) + copr-cli build --nowait $(COPR_PROJECT) $(RPM_PACKAGE_SRC) + $(RPM_PACKAGE_FILE) $(RPM_PACKAGE_SRC): $(SPEC_FILE) $(DIST_TAR_GZ) $(FW_DIST_TAR_GZ) | $(RPM_DIRS) @$(ECHO) "Building $(call toprel,$@), please wait..." $(V1) ln -sf $(DIST_TAR_GZ) $(PACKAGE_DIR)/SOURCES