Skip to contentSkip to conversation

various improvements to package/mender

PATCH New Mirza Krak 3 participants 37 messages Aug 20, 2018 – Oct 21, 2018

lore
Share & tools
lore

Mirza Krak

author
#0 lore raw

v2 cover various improvements to package/mender

This patch series brings some improvements to the Mender package. So far the Mender client binary was compiled properly but it was lacking some configuration files to function properly, which this series hope to adress.

The Mender client is only part one part of integrating Mender and the other parts (in short) are (generic & board specific):

Generic:
- eMMC disk image with correct partition layout (A & B rootfs + data part)
- But this is board specific in Buildroot?
- Mender artifact images (mender-artifact host tool)

Board specific:
- U-boot patches
- bootcmd, altbootcmd, BOOTCOUNT_LIMIT, BOOTCOUNT_ENV
- persistante storage of ENV
- redundant ENV
- fw_printenv/fw_setenv configuration file

But above are not covered in this series and will be handled separately.

This series has been tested on a custom ATSAMA5D27 based board.

Previous revisions of this series can be found here:

    http://lists.busybox.net/pipermail/buildroot/2018-August/227822.html

Changes in v2:

- Split up patches in more logical changes and the order them accordingly
- PATCH 1-5 - "Fixes" to make the mender client work, and work being defined as the mender.service will start without errors.
- PATCH 6-12 - Clean-ups and improvements
- PATCH 13-14 - RFC status

Mirza Krak (14):
package/mender: fix install path for identity and inventory scripts package/mender: provide sane values in mender.conf package/mender: create directory structures required by the Mender
client
package/mender: create directory containing Mender state script package/mender: symlink /var/lib/mender -> /data/mender package/mender: select BR2_PACKAGE_UBOOT_TOOLS_FWPRINTENV package/mender: select BR2_PACKAGE_CA_CERTIFICATES package/mender: remove tenant.conf
package/mender: use inventory and identity script from upstream source package/mender: update legal info
package/mender: set version in go linker
package/mender: use MENDER_PKGDIR to access local files package/mender: add BR2_PACKAGE_MENDER_ARTIFACT_NAME option package/mender: add BR2_PACKAGE_MENDER_DEVICE_TYPE option

 package/mender/Config.in                 | 27 ++++++++++++
 package/mender/mender-device-identity    | 52 -----------------------
 package/mender/mender-inventory-hostinfo | 21 ----------
 package/mender/mender-inventory-network  | 47 ---------------------
 package/mender/mender.conf               | 20 ++++-----
 package/mender/mender.hash               | 39 ++++++++++++++++++
 package/mender/mender.mk                 | 71 +++++++++++++++++++++++++++-----
 package/mender/mender.service            |  1 -
 package/mender/tenant.conf               |  0
 9 files changed, 134 insertions(+), 144 deletions(-)
 delete mode 100644 package/mender/mender-device-identity
 delete mode 100644 package/mender/mender-inventory-hostinfo
 delete mode 100644 package/mender/mender-inventory-network
 delete mode 100644 package/mender/tenant.conf

--
2.11.0

author
#1 lore raw

PATCH v2 1/14 package/mender: fix install path for identity and inventory scripts

These scripts are used to generate the device identity and to populate the the device inventory. The Mender client will call these and at least the mender-device-identity is required to be present at the correct location. Inventory scripts are there as an example and not actually required.

Example output from identity script:

    $ ./mender-device-identity
    mac=de:ad:ca:fe:00:01
    cpuid=1112233

Example output from inventory script:

    $ ./mender-inventory-network
    mac_br-fbfdad18c33c=02:42:7e:74:96:85
    network_interfaces=br-fbfdad18c33c
    ipv4_br-fbfdad18c33c=172.21.0.1/16
    mac_enp0s25=de:ad:be:ef:bb:05
    network_interfaces=enp0s25
    ipv4_enp0s25=123.22.0.197/16
    ipv4_enp0s25=10.20.20.105/16
    ipv6_enp0s25=fe80::2aad:beff:feef:bb05/64

Inventory and device identity data is presented on the Mender server front-end.

---
 package/mender/mender.mk | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
package/mender/mender.mk +4 -3
index 695b5e7a91..deab0cb039 100644
@@ -14,12 +14,13 @@ define MENDER_INSTALL_CONFIG_FILES
 		$(TARGET_DIR)/etc/mender/tenant.conf
 	$(INSTALL) -D -m 0644 package/mender/server.crt \
 		$(TARGET_DIR)/etc/mender/server.crt
+
 	$(INSTALL) -D -m 0755 package/mender/mender-device-identity \
-		$(TARGET_DIR)/var/share/mender/identity/mender-device-identity
+		$(TARGET_DIR)/usr/share/mender/identity/mender-device-identity
 	$(INSTALL) -D -m 0755 package/mender/mender-inventory-network \
-		$(TARGET_DIR)/var/share/mender/inventory/mender-inventory-network
+		$(TARGET_DIR)/usr/share/mender/inventory/mender-inventory-network
 	$(INSTALL) -D -m 0755 package/mender/mender-inventory-hostinfo \
-		$(TARGET_DIR)/var/share/mender/inventory/mender-inventory-hostinfo
+		$(TARGET_DIR)/usr/share/mender/inventory/mender-inventory-hostinfo
 endef
 
 MENDER_POST_INSTALL_TARGET_HOOKS += MENDER_INSTALL_CONFIG_FILES
Signature · 1 line
2.11.0
#2 lore raw

PATCH v2 1/14 package/mender: fix install path for identity and inventory scripts

Hello,

Quoted 24 lines · Mirza Krak

These scripts are used to generate the device identity and to populate the the device inventory. The Mender client will call these and at least the mender-device-identity is required to be present at the correct location. Inventory scripts are there as an example and not actually required.

Example output from identity script:

    $ ./mender-device-identity
    mac=de:ad:ca:fe:00:01
    cpuid=1112233

Example output from inventory script:

    $ ./mender-inventory-network
    mac_br-fbfdad18c33c=02:42:7e:74:96:85
    network_interfaces=br-fbfdad18c33c
    ipv4_br-fbfdad18c33c=172.21.0.1/16
    mac_enp0s25=de:ad:be:ef:bb:05
    network_interfaces=enp0s25
    ipv4_enp0s25=123.22.0.197/16
    ipv4_enp0s25=10.20.20.105/16
    ipv6_enp0s25=fe80::2aad:beff:feef:bb05/64
Quoted 7 lines

Inventory and device identity data is presented on the Mender server front-end.

---
 package/mender/mender.mk | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

Applied to master, thanks.

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com
author
#3 lore raw

PATCH v2 2/14 package/mender: provide sane values in mender.conf

In reply to Mirza Krak

The current values that are in mender.conf will actually cause the Mender client to fail to start because of invalid values.

Provide sane default values that at least allow the Mender client to parse the configuration options and start running.

The values provided will actually work in a "Demo Environment", see https://docs.mender.io/getting-started/create-a-test-environment.

Though an entry is required in /etc/hosts to resolve the URL to the local IP address of the running demo server.

Example:

    echo "192.168.0.10 docker.mender.io s3.docker.mender.io" >> \
         /etc/hosts

Above is required because the demo certificate (/etc/mender/server.crt) is created for https://docker.mender.io.

---
 package/mender/mender.conf | 20 ++++++++------------
 1 file changed, 8 insertions(+), 12 deletions(-)
package/mender/mender.conf +8 -12
index a5c7c545c3..979f16aaf6 100644
@@ -1,14 +1,10 @@
 {
-  "ClientProtocol": "http",
-  "HttpsClient": {
-    "Certificate": "",
-    "Key": ""
-  },
-  "RootfsPartA": "@MENDER_ROOTFS_PART_A@",
-  "RootfsPartB": "@MENDER_ROOTFS_PART_B@",
-  "UpdatePollIntervalSeconds": @MENDER_UPDATE_POLL_INTERVAL_SECONDS@,
-  "InventoryPollIntervalSeconds": @MENDER_INVENTORY_POLL_INTERVAL_SECONDS@,
-  "RetryPollIntervalSeconds": @MENDER_RETRY_POLL_INTERVAL_SECONDS@,
-  "ServerURL": "@MENDER_SERVER_URL@",
-  "ServerCertificate": "@MENDER_CERT_LOCATION@"
+  "InventoryPollIntervalSeconds": 1800,
+  "UpdatePollIntervalSeconds": 1800,
+  "RetryPollIntervalSeconds": 300,
+  "RootfsPartA": "mmcblk0p2",
+  "RootfsPartB": "mmcblk0p3",
+  "ServerCertificate": "/etc/mender/server.crt",
+  "ServerURL": "https://docker.mender.io",
+  "TenantToken": "dummy"
 }
Signature · 1 line
2.11.0
#4 lore raw

PATCH v2 2/14 package/mender: provide sane values in mender.conf

Hello,

Quoted 18 lines · Mirza Krak

The current values that are in mender.conf will actually cause the Mender client to fail to start because of invalid values.

Provide sane default values that at least allow the Mender client to parse the configuration options and start running.

The values provided will actually work in a "Demo Environment", see https://docs.mender.io/getting-started/create-a-test-environment.

Though an entry is required in /etc/hosts to resolve the URL to the local IP address of the running demo server.

Example:

    echo "192.168.0.10 docker.mender.io s3.docker.mender.io" >> \
         /etc/hosts
Quoted 7 lines

Above is required because the demo certificate (/etc/mender/server.crt) is created for https://docker.mender.io.

---
 package/mender/mender.conf | 20 ++++++++------------
 1 file changed, 8 insertions(+), 12 deletions(-)

Applied to master, thanks.

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com
author
#5 lore raw

PATCH v2 3/14 package/mender: create directory structures required by the Mender client

In reply to Mirza Krak

/uboot is a mount point for vfat boot partition. /data is a mount point for the persistent data partition.

---
 package/mender/mender.mk | 4 ++++
 1 file changed, 4 insertions(+)
package/mender/mender.mk +4 -0
index deab0cb039..71f92ce048 100644
@@ -8,6 +8,10 @@ MENDER_VERSION = 1.4.0
 MENDER_SITE = $(call github,mendersoftware,mender,$(MENDER_VERSION))
 
 define MENDER_INSTALL_CONFIG_FILES
+	$(INSTALL) -d -m 755 $(TARGET_DIR)/data/mender
+	$(INSTALL) -d -m 755 $(TARGET_DIR)/data/uboot
+	$(INSTALL) -d -m 755 $(TARGET_DIR)/uboot
+
 	$(INSTALL) -D -m 0644 package/mender/mender.conf \
 		$(TARGET_DIR)/etc/mender/mender.conf
 	$(INSTALL) -D -m 0644 package/mender/tenant.conf \
Signature · 1 line
2.11.0
#6 lore raw

PATCH v2 3/14 package/mender: create directory structures required by the Mender client

Hello,

Quoted 13 lines · Mirza Krak

/uboot is a mount point for vfat boot partition. /data is a mount point for the persistent data partition.

---
 package/mender/mender.mk | 4 ++++
 1 file changed, 4 insertions(+)
package/mender/mender.mk +0 -0
index deab0cb039..71f92ce048 100644

package/mender/mender.mk MENDER_VERSION = 1.4.0 · line 13

Quoted 6 lines
package/mender/mender.mk +3 -0
@@ -8,6 +8,10 @@ MENDER_VERSION = 1.4.0
 MENDER_SITE = $(call github,mendersoftware,mender,$(MENDER_VERSION))
 
 define MENDER_INSTALL_CONFIG_FILES
+	$(INSTALL) -d -m 755 $(TARGET_DIR)/data/mender
+	$(INSTALL) -d -m 755 $(TARGET_DIR)/data/uboot
+	$(INSTALL) -d -m 755 $(TARGET_DIR)/uboot

I am sorry, but despite the explanations, I still don't understand why these *must* be /data and /uboot. Is Mender *enforcing* those locations exactly ?

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com
author
#7 lore raw

PATCH v2 3/14 package/mender: create directory structures required by the Mender client

Quoted 18 lines · Thomas Petazzoni

Hello,

Quoted 15 lines · Mirza Krak

/uboot is a mount point for vfat boot partition. /data is a mount point for the persistent data partition.

---
 package/mender/mender.mk | 4 ++++
 1 file changed, 4 insertions(+)
package/mender/mender.mk +0 -0
index deab0cb039..71f92ce048 100644
@@ -8,6 +8,10 @@ MENDER_VERSION = 1.4.0
 MENDER_SITE = $(call github,mendersoftware,mender,$(MENDER_VERSION))
 
Quoted 8 lines

package/mender/mender.mk MENDER_VERSION = 1.4.0 · line 13

Quoted 4 lines
package/mender/mender.mk +3 -0
 define MENDER_INSTALL_CONFIG_FILES
+     $(INSTALL) -d -m 755 $(TARGET_DIR)/data/mender
+     $(INSTALL) -d -m 755 $(TARGET_DIR)/data/uboot
+     $(INSTALL) -d -m 755 $(TARGET_DIR)/uboot

I am sorry, but despite the explanations, I still don't understand why these *must* be /data and /uboot. Is Mender *enforcing* those locations exactly ?

/uboot, not really enforced, just aligned to other systems that integrate Mender. I could actually drop this.

/data is not really enforced but the symlink /var/lib/mender must point to a valid location (normally it points to /data), because once the Mender daemon starts it will generate some initial files at that location and the service would fail if non-existent.

List of files that are generated on "first start-up"

-rw-------    1 root     root        2.4K Jan 28  2018 mender-agent.pem
-rw-------    1 root     root        8.0K Jan 28  2018 mender-store
-rw-------    1 root     root        8.0K Jan 28  2018 mender-store-lock

Thank you.

Signature · 3 lines
Mirza Krak | Embedded Solutions Architect | https://mender.io

 Northern.tech AS | @northerntechHQ
author
#8 lore raw

PATCH v2 3/14 package/mender: create directory structures required by the Mender client

Quoted 29 lines · Mirza Krak
Quoted 18 lines · Thomas Petazzoni

Hello,

Quoted 15 lines · Mirza Krak

/uboot is a mount point for vfat boot partition. /data is a mount point for the persistent data partition.

---
 package/mender/mender.mk | 4 ++++
 1 file changed, 4 insertions(+)
package/mender/mender.mk +0 -0
index deab0cb039..71f92ce048 100644
@@ -8,6 +8,10 @@ MENDER_VERSION = 1.4.0
 MENDER_SITE = $(call github,mendersoftware,mender,$(MENDER_VERSION))
 
Quoted 8 lines

package/mender/mender.mk MENDER_VERSION = 1.4.0 · line 13

Quoted 4 lines
package/mender/mender.mk +3 -0
 define MENDER_INSTALL_CONFIG_FILES
+     $(INSTALL) -d -m 755 $(TARGET_DIR)/data/mender
+     $(INSTALL) -d -m 755 $(TARGET_DIR)/data/uboot
+     $(INSTALL) -d -m 755 $(TARGET_DIR)/uboot

I am sorry, but despite the explanations, I still don't understand why these *must* be /data and /uboot. Is Mender *enforcing* those locations exactly ?

Quoted 7 lines

/uboot, not really enforced, just aligned to other systems that integrate Mender. I could actually drop this.

/data is not really enforced but the symlink /var/lib/mender must point to a valid location (normally it points to /data), because once the Mender daemon starts it will generate some initial files at that location and the service would fail if non-existent.

Actually I can drop the /data creation from mender.mk as well, as the mender.service will run:

ExecStartPre=/bin/mkdir -p -m 0700 /data/mender

So yeah a bit enforced.

Signature · 3 lines
Mirza Krak | Embedded Solutions Architect | https://mender.io

 Northern.tech AS | @northerntechHQ
author
#9 lore raw

PATCH v2 3/14 package/mender: create directory structures required by the Mender client

Quoted 38 lines · Mirza Krak
Quoted 29 lines · Mirza Krak
Quoted 18 lines · Thomas Petazzoni

Hello,

Quoted 15 lines · Mirza Krak

/uboot is a mount point for vfat boot partition. /data is a mount point for the persistent data partition.

---
 package/mender/mender.mk | 4 ++++
 1 file changed, 4 insertions(+)
package/mender/mender.mk +0 -0
index deab0cb039..71f92ce048 100644
@@ -8,6 +8,10 @@ MENDER_VERSION = 1.4.0
 MENDER_SITE = $(call github,mendersoftware,mender,$(MENDER_VERSION))
 
Quoted 8 lines

package/mender/mender.mk MENDER_VERSION = 1.4.0 · line 13

Quoted 4 lines
package/mender/mender.mk +3 -0
 define MENDER_INSTALL_CONFIG_FILES
+     $(INSTALL) -d -m 755 $(TARGET_DIR)/data/mender
+     $(INSTALL) -d -m 755 $(TARGET_DIR)/data/uboot
+     $(INSTALL) -d -m 755 $(TARGET_DIR)/uboot

I am sorry, but despite the explanations, I still don't understand why these *must* be /data and /uboot. Is Mender *enforcing* those locations exactly ?

Quoted 7 lines

/uboot, not really enforced, just aligned to other systems that integrate Mender. I could actually drop this.

/data is not really enforced but the symlink /var/lib/mender must point to a valid location (normally it points to /data), because once the Mender daemon starts it will generate some initial files at that location and the service would fail if non-existent.

Quoted 6 lines

Actually I can drop the /data creation from mender.mk as well, as the mender.service will run:

ExecStartPre=/bin/mkdir -p -m 0700 /data/mender

So yeah a bit enforced.

But what I wanted tot say is that we can probably drop this patch.

Signature · 3 lines
Mirza Krak | Embedded Solutions Architect | https://mender.io

 Northern.tech AS | @northerntechHQ
#10 lore raw

PATCH v2 3/14 package/mender: create directory structures required by the Mender client

Quoted 39 lines · Mirza Krak
Quoted 38 lines · Mirza Krak
Quoted 36 lines · Mirza Krak
Quoted 18 lines · Thomas Petazzoni

Hello,

Quoted 15 lines · Mirza Krak

/uboot is a mount point for vfat boot partition. /data is a mount point for the persistent data partition.

---
 package/mender/mender.mk | 4 ++++
 1 file changed, 4 insertions(+)
package/mender/mender.mk +0 -0
index deab0cb039..71f92ce048 100644
@@ -8,6 +8,10 @@ MENDER_VERSION = 1.4.0
 MENDER_SITE = $(call github,mendersoftware,mender,$(MENDER_VERSION))
 
Quoted 8 lines

package/mender/mender.mk MENDER_VERSION = 1.4.0 · line 13

Quoted 4 lines
package/mender/mender.mk +3 -0
 define MENDER_INSTALL_CONFIG_FILES
+     $(INSTALL) -d -m 755 $(TARGET_DIR)/data/mender
+     $(INSTALL) -d -m 755 $(TARGET_DIR)/data/uboot
+     $(INSTALL) -d -m 755 $(TARGET_DIR)/uboot

I am sorry, but despite the explanations, I still don't understand why these *must* be /data and /uboot. Is Mender *enforcing* those locations exactly ?

/uboot, not really enforced, just aligned to other systems that integrate Mender. I could actually drop this.

/data is not really enforced but the symlink /var/lib/mender must point to a valid location (normally it points to /data), because once the Mender daemon starts it will generate some initial files at that location and the service would fail if non-existent.

Quoted 8 lines
Quoted 6 lines

Actually I can drop the /data creation from mender.mk as well, as the mender.service will run:

ExecStartPre=/bin/mkdir -p -m 0700 /data/mender

So yeah a bit enforced.

But what I wanted tot say is that we can probably drop this patch.

As you suggested, I've marked the patch as Rejected in patchwork.

Regards,
Arnout

author
#11 lore raw

PATCH v2 4/14 package/mender: create directory containing Mender state script

In reply to Mirza Krak

Mender state-scripts are essentially "hooks" that can be provided to influence the update flow.

They should be placed inside /etc/mender/scripts and the directory must contain a file containing the current state-script format version. It is currently "2".

---
 package/mender/mender.mk | 3 +++
 1 file changed, 3 insertions(+)
package/mender/mender.mk +3 -0
index 71f92ce048..acf50e0092 100644
@@ -12,6 +12,9 @@ define MENDER_INSTALL_CONFIG_FILES
 	$(INSTALL) -d -m 755 $(TARGET_DIR)/data/uboot
 	$(INSTALL) -d -m 755 $(TARGET_DIR)/uboot
 
+	$(INSTALL) -d -m 755 $(TARGET_DIR)/etc/mender/scripts
+	echo -n "2" > $(TARGET_DIR)/etc/mender/scripts/version
+
 	$(INSTALL) -D -m 0644 package/mender/mender.conf \
 		$(TARGET_DIR)/etc/mender/mender.conf
 	$(INSTALL) -D -m 0644 package/mender/tenant.conf \
Signature · 1 line
2.11.0
#12 lore raw

PATCH v2 4/14 package/mender: create directory containing Mender state script

Hello,

Quoted 11 lines · Mirza Krak

Mender state-scripts are essentially "hooks" that can be provided to influence the update flow.

They should be placed inside /etc/mender/scripts and the directory must contain a file containing the current state-script format version. It is currently "2".

---
 package/mender/mender.mk | 3 +++
 1 file changed, 3 insertions(+)

Applied to master, thanks.

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com
author
#13 lore raw

PATCH v2 5/14 package/mender: symlink /var/lib/mender -> /data/mender

In reply to Mirza Krak

The Mender client will use /var/lib/mender to access the persistent data partition and expect the link to be in place.

By default it points to /data, but this can easily be overriden by overriding the link in overlay_fs

---
 package/mender/mender.mk | 2 ++
 1 file changed, 2 insertions(+)
package/mender/mender.mk +2 -0
index acf50e0092..eb718ebc02 100644
@@ -28,6 +28,8 @@ define MENDER_INSTALL_CONFIG_FILES
 		$(TARGET_DIR)/usr/share/mender/inventory/mender-inventory-network
 	$(INSTALL) -D -m 0755 package/mender/mender-inventory-hostinfo \
 		$(TARGET_DIR)/usr/share/mender/inventory/mender-inventory-hostinfo
+
+	ln -sf /data/mender $(TARGET_DIR)/var/lib/mender
 endef
 
 MENDER_POST_INSTALL_TARGET_HOOKS += MENDER_INSTALL_CONFIG_FILES
Signature · 1 line
2.11.0
author
#14 lore raw

PATCH v2 5/14 package/mender: symlink /var/lib/mender -> /data/mender

Quoted 10 lines · Mirza Krak

The Mender client will use /var/lib/mender to access the persistent data partition and expect the link to be in place.

By default it points to /data, but this can easily be overriden by overriding the link in overlay_fs

---
 package/mender/mender.mk | 2 ++
 1 file changed, 2 insertions(+)

Thanks Thomas for picking up my other patches.

Wondering if this one was missed or some other reason not to apply it?

Signature · 3 lines
Mirza Krak | Embedded Solutions Architect | https://mender.io

 Northern.tech AS | @northerntechHQ
#15 lore raw

PATCH v2 5/14 package/mender: symlink /var/lib/mender -> /data/mender

Hello,

Quoted 7 lines · Mirza Krak
Quoted 6 lines · Mirza Krak

The Mender client will use /var/lib/mender to access the persistent data partition and expect the link to be in place.

By default it points to /data, but this can easily be overriden by overriding the link in overlay_fs

Quoted 8 lines
Quoted 4 lines
---
 package/mender/mender.mk | 2 ++
 1 file changed, 2 insertions(+)  

Thanks Thomas for picking up my other patches.

Wondering if this one was missed or some other reason not to apply it?

This one also relies on the assumption that /data is the persistent partition, which is the part I'm still not sure how to handle. So I've so far merged the things that I agree with, and that are OK for master.

The rest is either stuff that needs more discussion (persistent partition related stuff) or that isn't material for master because it doesn't fix any problem.

BTW, could you send a patch adding yourself as a developer for the mender package in the DEVELOPERS file ?

Thanks!

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com
author
#16 lore raw

PATCH v2 5/14 package/mender: symlink /var/lib/mender -> /data/mender

Quoted 15 lines · Thomas Petazzoni

Hello,

Quoted 12 lines · Mirza Krak
Quoted 10 lines · Mirza Krak

The Mender client will use /var/lib/mender to access the persistent data partition and expect the link to be in place.

By default it points to /data, but this can easily be overriden by overriding the link in overlay_fs

---
 package/mender/mender.mk | 2 ++
 1 file changed, 2 insertions(+)
Quoted 7 lines
Quoted 3 lines

Thanks Thomas for picking up my other patches.

Wondering if this one was missed or some other reason not to apply it?

This one also relies on the assumption that /data is the persistent partition, which is the part I'm still not sure how to handle. So I've so far merged the things that I agree with, and that are OK for master.

Sorry I probably mislead you regarding this.

The Mender client will use the /var/lib/mender path, that is pretty much hard-coded. The fact that it was a link to /data is simply to provide a "valid" path, because the mender.service will create the directory structure on start-up. The reason it is a link is because you can change it to point to where ever your persistent storage is.

So we either have to have a "mkdir -p /var/lib/mender" in mender.mk or use the link that this patch provides.

Sorry once again for not making this clear.

Quoted 7 lines

The rest is either stuff that needs more discussion (persistent partition related stuff) or that isn't material for master because it doesn't fix any problem.

BTW, could you send a patch adding yourself as a developer for the mender package in the DEVELOPERS file ?

Will do.

Signature · 3 lines
Mirza Krak | Embedded Solutions Architect | https://mender.io

 Northern.tech AS | @northerntechHQ
#17 lore raw

PATCH v2 5/14 package/mender: symlink /var/lib/mender -> /data/mender

Quoted 27 lines · Mirza Krak
Quoted 15 lines · Thomas Petazzoni

Hello,

Quoted 12 lines · Mirza Krak
Quoted 10 lines · Mirza Krak

The Mender client will use /var/lib/mender to access the persistent data partition and expect the link to be in place.

By default it points to /data, but this can easily be overriden by overriding the link in overlay_fs

---
 package/mender/mender.mk | 2 ++
 1 file changed, 2 insertions(+)
Quoted 7 lines
Quoted 3 lines

Thanks Thomas for picking up my other patches.

Wondering if this one was missed or some other reason not to apply it?

This one also relies on the assumption that /data is the persistent partition, which is the part I'm still not sure how to handle. So I've so far merged the things that I agree with, and that are OK for master.

Sorry I probably mislead you regarding this.

Quoted 8 lines

The Mender client will use the /var/lib/mender path, that is pretty much hard-coded. The fact that it was a link to /data is simply to provide a "valid" path, because the mender.service will create the directory structure on start-up. The reason it is a link is because you can change it to point to where ever your persistent storage is.

So we either have to have a "mkdir -p /var/lib/mender" in mender.mk or use the link that this patch provides.

I think we should take a similar approach as for dropbear.

Since mender hardcodes /var/lib/mender, that is what we should use within
Buildroot as well. So the service file should use that path.

However, that means that we have to create that path, and do it in a writable
location.

So the proposal is the following:

- install a symlink /var/lib/mender -> /var/run/mender

- in the service file, check if /var/lib/mender is a symlink to /var/run/mender. If it is, try to remove it and replace it with an actual directory (that covers the case when /var/lib is mounted as a read-write partition); if it isn't, do an mkdir -p of the location pointed to by that symlink AND print a warning that this is a bad idea. If /var/lib/mender doesn't exist or is a symlink to somewhere else, create the directory.

Do you feel up to that? :-)

I've marked the patch as Changes Requested in patchwork.

Regards,
Arnout

author
#18 lore raw

PATCH v2 6/14 package/mender: select BR2_PACKAGE_UBOOT_TOOLS_FWPRINTENV

In reply to Mirza Krak

The Mender client uses fw_printenv/fw_setenv to manipulate the U-boot environment, e.g to change the boot candidate after a update has been done.

---

Changes in V2:
- Added #runtime to hint that this not a build dependency

 package/mender/Config.in | 2 ++
 1 file changed, 2 insertions(+)
package/mender/Config.in +2 -0
index e461857486..aeb0b2694f 100644
@@ -3,6 +3,8 @@ config BR2_PACKAGE_MENDER
 	depends on BR2_PACKAGE_HOST_GO_ARCH_SUPPORTS
 	depends on BR2_PACKAGE_HOST_GO_CGO_LINKING_SUPPORTS
 	depends on BR2_TOOLCHAIN_HAS_THREADS
+	select BR2_PACKAGE_UBOOT_TOOLS # runtime
+	select BR2_PACKAGE_UBOOT_TOOLS_FWPRINTENV # runtime
 	help
 	  Mender is an open source over-the-air (OTA) software updater
 	  for embedded Linux devices. Mender comprises a client

--
2.11.0

#19 lore raw

PATCH v2 6/14 package/mender: select BR2_PACKAGE_UBOOT_TOOLS_FWPRINTENV

Hello,

Quoted 6 lines · Mirza Krak

The Mender client uses fw_printenv/fw_setenv to manipulate the U-boot environment, e.g to change the boot candidate after a update has been done.

---

Applied to master, thanks.

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com
author
#20 lore raw

PATCH v2 7/14 package/mender: select BR2_PACKAGE_CA_CERTIFICATES

In reply to Mirza Krak

Mender uses TLS to community with the management server, and if CA signed certificates are used we must have the ca-certificates package installed to be able to verify these.

---

Changes in V2:
- Added #runtime to hint that this not a build dependency

 package/mender/Config.in | 1 +
 1 file changed, 1 insertion(+)
package/mender/Config.in +1 -0
index aeb0b2694f..853a472ea1 100644
@@ -5,6 +5,7 @@ config BR2_PACKAGE_MENDER
 	depends on BR2_TOOLCHAIN_HAS_THREADS
 	select BR2_PACKAGE_UBOOT_TOOLS # runtime
 	select BR2_PACKAGE_UBOOT_TOOLS_FWPRINTENV # runtime
+	select BR2_PACKAGE_CA_CERTIFICATES # runtime
 	help
 	  Mender is an open source over-the-air (OTA) software updater
 	  for embedded Linux devices. Mender comprises a client

--
2.11.0

#21 lore raw

PATCH v2 7/14 package/mender: select BR2_PACKAGE_CA_CERTIFICATES

Hello,

Quoted 6 lines · Mirza Krak

Mender uses TLS to community with the management server, and if CA signed certificates are used we must have the ca-certificates package installed to be able to verify these.

I am not sure we want to make this a mandatory dependency. If people are using a management server that provides a CA signed certificate, then they should add the ca-certificates package to their build.

Perhaps this belongs more to a note in the Config.in help text. Or maybe even Mender deserves a package/mender/readme.txt, which a bit like boot/grub2/readme.txt, would give more details about Mender's integration in Buildroot.

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com
author
#22 lore raw

PATCH v2 7/14 package/mender: select BR2_PACKAGE_CA_CERTIFICATES

Quoted 10 lines · Thomas Petazzoni

Hello,

Quoted 6 lines · Mirza Krak

Mender uses TLS to community with the management server, and if CA signed certificates are used we must have the ca-certificates package installed to be able to verify these.

Quoted 8 lines

I am not sure we want to make this a mandatory dependency. If people are using a management server that provides a CA signed certificate, then they should add the ca-certificates package to their build.

Perhaps this belongs more to a note in the Config.in help text. Or maybe even Mender deserves a package/mender/readme.txt, which a bit like boot/grub2/readme.txt, would give more details about Mender's integration in Buildroot.

Makes sense.

Thanks for the hint on creating a readme.txt. Will make so sure to do that.

Signature · 3 lines
Mirza Krak | Embedded Solutions Architect | https://mender.io

 Northern.tech AS | @northerntechHQ
#23 lore raw

PATCH v2 7/14 package/mender: select BR2_PACKAGE_CA_CERTIFICATES

Quoted 16 lines · Mirza Krak
Quoted 14 lines · Thomas Petazzoni

Hello,

Quoted 6 lines · Mirza Krak

Mender uses TLS to community with the management server, and if CA signed certificates are used we must have the ca-certificates package installed to be able to verify these.

I am not sure we want to make this a mandatory dependency. If people are using a management server that provides a CA signed certificate, then they should add the ca-certificates package to their build.

Quoted 9 lines
Quoted 4 lines

Perhaps this belongs more to a note in the Config.in help text. Or maybe even Mender deserves a package/mender/readme.txt, which a bit like boot/grub2/readme.txt, would give more details about Mender's integration in Buildroot.

Makes sense.

Thanks for the hint on creating a readme.txt. Will make so sure to do that.

Assuming you're going to create this readme.txt, I've marked this patch as
Changes Requested.

Regards,
Arnout

author
#24 lore raw

PATCH v2 8/14 package/mender: remove tenant.conf

In reply to Mirza Krak

Tenant Token is a configuration option that has to do with Hosted Mender, where you you need to set this for the devices to connect to the correct organization in a multi-tenant system.

The removal of tenant.conf usage (and /var/lib/mender/authtentoken) was in Mender client version 1.2.0, where it was switched to be an mender.conf option instead as the example above demonstrates. As the first version that was integrated in Buildroot was 1.4.0, the inclusion of tenant.conf and the creation of the symlink is not necessary.

Now it is specified as such in mender.conf:

Example:

/etc/mender/mender.conf
{
TenantToken: "very long base64 encoded string"
}

---

Changes in V2:

- New patch, split out from package/mender: update install of config files
- Better description

 package/mender/mender.mk      | 3 +--
 package/mender/mender.service | 1 -
 package/mender/tenant.conf    | 0
 3 files changed, 1 insertion(+), 3 deletions(-)
 delete mode 100644 package/mender/tenant.conf
package/mender/mender.mk +1 -2
index eb718ebc02..24122cafc5 100644
@@ -17,8 +17,7 @@ define MENDER_INSTALL_CONFIG_FILES
 
 	$(INSTALL) -D -m 0644 package/mender/mender.conf \
 		$(TARGET_DIR)/etc/mender/mender.conf
-	$(INSTALL) -D -m 0644 package/mender/tenant.conf \
-		$(TARGET_DIR)/etc/mender/tenant.conf
+
 	$(INSTALL) -D -m 0644 package/mender/server.crt \
 		$(TARGET_DIR)/etc/mender/server.crt
 
package/mender/mender.service +0 -1
index ec77fbc46c..9ede55acb5 100644
@@ -7,7 +7,6 @@ Type=idle
 User=root
 Group=root
 ExecStartPre=/bin/mkdir -p -m 0700 /data/mender
-ExecStartPre=/bin/ln -sf /etc/mender/tenant.conf /var/lib/mender/authtentoken
 ExecStart=/usr/bin/mender -daemon
 Restart=on-abort
 
package/mender/tenant.conf deleted +0 -0
deleted file mode 100644
index e69de29bb2..0000000000

--
2.11.0

#25 lore raw

PATCH v2 8/14 package/mender: remove tenant.conf

Hello,

Quoted 14 lines · Mirza Krak

Tenant Token is a configuration option that has to do with Hosted Mender, where you you need to set this for the devices to connect to the correct organization in a multi-tenant system.

The removal of tenant.conf usage (and /var/lib/mender/authtentoken) was in Mender client version 1.2.0, where it was switched to be an mender.conf option instead as the example above demonstrates. As the first version that was integrated in Buildroot was 1.4.0, the inclusion of tenant.conf and the creation of the symlink is not necessary.

Now it is specified as such in mender.conf:

Example:

Quoted 7 lines

/etc/mender/mender.conf
{
TenantToken: "very long base64 encoded string"
}

---

Applied to master, thanks.

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com
author
#26 lore raw

PATCH v2 9/14 package/mender: use inventory and identity script from upstream source

In reply to Mirza Krak

These files are part of Mender sources and no point in keeping duplicate files locally.

---

Changes in V2:
- New patch, split out from package/mender: update install of config files

 package/mender/mender-device-identity    | 52 --------------------------------
 package/mender/mender-inventory-hostinfo | 21 -------------
 package/mender/mender-inventory-network  | 47 -----------------------------
 package/mender/mender.mk                 | 10 +++---
 4 files changed, 5 insertions(+), 125 deletions(-)
 delete mode 100644 package/mender/mender-device-identity
 delete mode 100644 package/mender/mender-inventory-hostinfo
 delete mode 100644 package/mender/mender-inventory-network
package/mender/mender-device-identity deleted +0 -52
deleted file mode 100644
index d87f843357..0000000000
@@ -1,52 +0,0 @@
-#!/bin/sh
-
-# Example script called by Mender agent to collect device identity data. The
-# script needs to be located at
-# $(datadir)/mender/identity/mender-device-identity path for the agent to find
-# it. The script shall exit with non-0 status on errors. In this case the agent
-# will discard any output the script may have produced.
-#
-# The script shall output identity data in <key>=<value> format, one
-# entry per line. Example
-#
-# $ ./mender-device-identity
-# mac=de:ad:ca:fe:00:01
-# cpuid=1112233
-#
-# The example script collects the MAC address of a network interface with the
-# type ARPHRD_ETHER and it will pick the interface with the lowest ifindex
-# number if there are multiple interfaces with that type. The identity data is
-# output in the following format:
-#
-# mac=00:01:02:03:04:05
-#
-
-set -ue
-
-SCN=/sys/class/net
-min=65535
-arphrd_ether=1
-ifdev=
-
-# find iface with lowest ifindex, skip non ARPHRD_ETHER types (lo, sit ...)
-for dev in $SCN/*; do
-    iftype=$(cat $dev/type)
-    if [ $iftype -ne $arphrd_ether ]; then
-        continue
-    fi
-
-    idx=$(cat $dev/ifindex)
-    if [ $idx -lt $min ]; then
-        min=$idx
-        ifdev=$dev
-    fi
-done
-
-if [ -z "$ifdev" ]; then
-    echo "no suitable interfaces found" >&2
-    exit 1
-else
-    echo "using interface $ifdev" >&2
-    # grab MAC address
-    echo "mac=$(cat $ifdev/address)"
-fi
package/mender/mender-inventory-hostinfo deleted +0 -21
deleted file mode 100644
index cf508fdf88..0000000000
@@ -1,21 +0,0 @@
-#!/bin/sh
-#
-# The example script collects information about current host
-#
-
-set -ue
-
-LC_ALL=C
-export LC_ALL
-
-grep 'model name' /proc/cpuinfo | uniq | awk -F': ' '
-     // { printf("cpu_model=%s\n", $2);}
-'
-echo "kernel=$(cat /proc/version)"
-
-cat /proc/meminfo | awk '
-/MemTotal/ {printf("mem_total_kB=%d\n", $2)}
-'
-
-echo "hostname=$(cat /etc/hostname)"
-
package/mender/mender-inventory-network deleted +0 -47

47 lines not on this page · raw message

package/mender/mender.mk +5 -5
index 24122cafc5..1f54862077 100644
@@ -21,12 +21,12 @@ define MENDER_INSTALL_CONFIG_FILES
 	$(INSTALL) -D -m 0644 package/mender/server.crt \
 		$(TARGET_DIR)/etc/mender/server.crt
 
-	$(INSTALL) -D -m 0755 package/mender/mender-device-identity \
+	$(INSTALL) -D -m 0755 $(@D)/support/mender-device-identity \
 		$(TARGET_DIR)/usr/share/mender/identity/mender-device-identity
-	$(INSTALL) -D -m 0755 package/mender/mender-inventory-network \
-		$(TARGET_DIR)/usr/share/mender/inventory/mender-inventory-network
-	$(INSTALL) -D -m 0755 package/mender/mender-inventory-hostinfo \
-		$(TARGET_DIR)/usr/share/mender/inventory/mender-inventory-hostinfo
+	$(foreach f,hostinfo network, \
+		$(INSTALL) -D -m 0755 $(@D)/support/mender-inventory-$(f) \
+			$(TARGET_DIR)/usr/share/mender/inventory/mender-inventory-$(f)
+	)
 
 	ln -sf /data/mender $(TARGET_DIR)/var/lib/mender
 endef

--
2.11.0

#27 lore raw

PATCH v2 9/14 package/mender: use inventory and identity script from upstream source

Hello,

Quoted 5 lines · Mirza Krak

These files are part of Mender sources and no point in keeping duplicate files locally.

---

Applied to master, thanks.

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com
author
#28 lore raw

PATCH v2 10/14 package/mender: update legal info

In reply to Mirza Krak

Also added license checksums in mender.hash

---

Changes in V2:

- Added all vendor licenses to mender.hash and MENDER_LICENSE_FILES

 package/mender/mender.hash | 39 +++++++++++++++++++++++++++++++++++++++
 package/mender/mender.mk   | 25 +++++++++++++++++++++++++
 2 files changed, 64 insertions(+)
package/mender/mender.hash +39 -0
index 30a04fad7a..8faa740e3b 100644
@@ -1,2 +1,41 @@
 # Locally computed:
 sha256 267fa73ad472b034248ee298593b5c52ea0b105fd73c91febb3587280c61bee2 mender-1.4.0.tar.gz
+
+# Apache-2.0 license, locally computed
+sha256 ceb1b36ff073bd13d9806d4615b931707768ca9023805620acc32dd1cfc2f680 LICENSE
+
+# Vendor licenses
+# Generated with sed '/^[A-Za-z0-9_]/s/^/sha256  /' LIC_FILES_CHKSUM.sha256
+
+# Apache-2.0 license.
+sha256 ceb1b36ff073bd13d9806d4615b931707768ca9023805620acc32dd1cfc2f680  vendor/github.com/mendersoftware/mendertesting/LICENSE
+sha256 3591f687e2d6f49c83b1ec69577e8110afbde80be5ec81791bd86d2838ccd3de  vendor/github.com/mendersoftware/log/LICENSE
+sha256 bbb303820971c294a9a8e5eba5affcf1379036e877ea61c11cbf9400b2949483  vendor/github.com/mendersoftware/log/COPYING
+sha256 3591f687e2d6f49c83b1ec69577e8110afbde80be5ec81791bd86d2838ccd3de  vendor/github.com/mendersoftware/scopestack/LICENSE
+sha256 bbb303820971c294a9a8e5eba5affcf1379036e877ea61c11cbf9400b2949483  vendor/github.com/mendersoftware/scopestack/COPYING
+sha256 b40930bbcf80744c86c46a12bc9da056641d722716c378f5659b9e555ef833e1  vendor/github.com/mendersoftware/mender-artifact/LICENSE
+
+# BSD 2 Clause license.
+sha256 8d427fd87bc9579ea368fde3d49f9ca22eac857f91a9dec7e3004bdfab7dee86  vendor/github.com/pkg/errors/LICENSE
+
+# BSD 3 Clause license.
+sha256 2eb550be6801c1ea434feba53bf6d12e7c71c90253e0a9de4a4f46cf88b56477  vendor/github.com/pmezard/go-difflib/LICENSE
+sha256 2d36597f7117c38b006835ae7f537487207d8ec407aa9d9980794b2030cbc067  vendor/golang.org/x/sys/LICENSE
+sha256 2d36597f7117c38b006835ae7f537487207d8ec407aa9d9980794b2030cbc067  vendor/golang.org/x/net/LICENSE
+sha256 0634b008cee55ca01f0888d2f5aba2d34e66c3f52c31a4e16a5d5d33d0c2a03e  vendor/github.com/bmatsuo/lmdb-go/LICENSE.md
+
+# ISC license.
+sha256  3525392c6db3b804af76980b2c560ee9ec1abdadd907d76a26091df7c78f3a25  vendor/github.com/davecgh/go-spew/LICENSE
+
+# MIT license.
+sha256 51a0c9ec7f8b7634181b8d4c03e5b5d204ac21d6e72f46c313973424664b2e6b  vendor/github.com/Sirupsen/logrus/LICENSE
+sha256 402f39eed8a1851385d0703999aa9f23d067c2ea3e15c63c074e389cbf8f8f8f  vendor/github.com/stretchr/testify/LICENSE
+sha256 402f39eed8a1851385d0703999aa9f23d067c2ea3e15c63c074e389cbf8f8f8f  vendor/github.com/stretchr/testify/LICENCE.txt
+sha256 fde7d610b9b95fc5a6304055c4dae951025b630aaa42a24e95ebf76675ae832c  vendor/github.com/stretchr/objx/LICENSE.md
+sha256 ffa15bdce332058a03a1d923910864fb6e58bf6df66a0e3914284725b327183e  vendor/github.com/ungerik/go-sysfs/LICENSE
+
+# OpenLDAP Public License
+sha256 310fe25c858a9515fc8c8d7d1f24a67c9496f84a91e0a0e41ea9975b1371e569  vendor/github.com/bmatsuo/lmdb-go/LICENSE.mdb.md
+
+# sha256 of all the vendor licenses combined
+sha256 54d6f54a2815cc2e3cef4f7dde5a3aae20f09b2cde394d8d3f1dce5d8a79d738 LIC_FILES_CHKSUM.sha256
package/mender/mender.mk +25 -0
index 1f54862077..fafb0d923a 100644
@@ -6,6 +6,31 @@
 
 MENDER_VERSION = 1.4.0
 MENDER_SITE = $(call github,mendersoftware,mender,$(MENDER_VERSION))
+MENDER_LICENSE = Apache-2.0, BSD-2-Clause, BSD-3-Clause, ISC, MIT, OLDAP-2.8
+
+# Vendor license paths generated with:
+#    awk '{print $2}' LIC_FILES_CHKSUM.sha256 | grep vendor
+MENDER_LICENSE_FILES = \
+	LICENSE \
+	LIC_FILES_CHKSUM.sha256 \
+	vendor/github.com/mendersoftware/mendertesting/LICENSE \
+	vendor/github.com/mendersoftware/log/LICENSE \
+	vendor/github.com/mendersoftware/log/COPYING \
+	vendor/github.com/mendersoftware/scopestack/LICENSE \
+	vendor/github.com/mendersoftware/scopestack/COPYING \
+	vendor/github.com/mendersoftware/mender-artifact/LICENSE \
+	vendor/github.com/pkg/errors/LICENSE \
+	vendor/github.com/pmezard/go-difflib/LICENSE \
+	vendor/golang.org/x/sys/LICENSE \
+	vendor/golang.org/x/net/LICENSE \
+	vendor/github.com/bmatsuo/lmdb-go/LICENSE.md \
+	vendor/github.com/davecgh/go-spew/LICENSE \
+	vendor/github.com/Sirupsen/logrus/LICENSE \
+	vendor/github.com/stretchr/testify/LICENSE \
+	vendor/github.com/stretchr/testify/LICENCE.txt \
+	vendor/github.com/stretchr/objx/LICENSE.md \
+	vendor/github.com/ungerik/go-sysfs/LICENSE \
+	vendor/github.com/bmatsuo/lmdb-go/LICENSE.mdb.md
 
 define MENDER_INSTALL_CONFIG_FILES
 	$(INSTALL) -d -m 755 $(TARGET_DIR)/data/mender

--
2.11.0

#29 lore raw

PATCH v2 10/14 package/mender: update legal info

Hello,

Quoted 4 lines · Mirza Krak

Also added license checksums in mender.hash

---

Applied to master, thanks.

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com
author
#30 lore raw

PATCH v2 11/14 package/mender: set version in go linker

In reply to Mirza Krak

This is used when calling the mender client with the -version option and it says "unknown" if not set in linker.

Now it displays the following:

    # mender -version
    1.4.0
    runtime: go1.10.2

---

Changes in V2:
- None

 package/mender/mender.mk | 2 ++
 1 file changed, 2 insertions(+)
package/mender/mender.mk +2 -0
index fafb0d923a..7e6f18f523 100644
@@ -32,6 +32,8 @@ MENDER_LICENSE_FILES = \
 	vendor/github.com/ungerik/go-sysfs/LICENSE \
 	vendor/github.com/bmatsuo/lmdb-go/LICENSE.mdb.md
 
+MENDER_LDFLAGS = -X main.Version=$(MENDER_VERSION)
+
 define MENDER_INSTALL_CONFIG_FILES
 	$(INSTALL) -d -m 755 $(TARGET_DIR)/data/mender
 	$(INSTALL) -d -m 755 $(TARGET_DIR)/data/uboot

--
2.11.0

#31 lore raw

PATCH v2 11/14 package/mender: set version in go linker

Hello,

Quoted 4 lines · Mirza Krak

This is used when calling the mender client with the -version option and it says "unknown" if not set in linker.

Quoted 8 lines

Now it displays the following:

    # mender -version
    1.4.0
    runtime: go1.10.2

---

Applied to master, thanks.

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com
author
#32 lore raw

PATCH v2 12/14 package/mender: use MENDER_PKGDIR to access local files

In reply to Mirza Krak

Utilize the predefined variable MENDER_PKGDIR which points to the directory containing mender.mk and Config.in, along with the local files.

One benefit is also that it works when BR2_EXTERNAL is used, which makes it easier to "backport" this to an older external tree.

---

Changes in V2:
- New patch, reported by eager user :)

 package/mender/mender.mk | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
package/mender/mender.mk +3 -4
index 7e6f18f523..a4b9c6ee85 100644
@@ -42,10 +42,9 @@ define MENDER_INSTALL_CONFIG_FILES
 	$(INSTALL) -d -m 755 $(TARGET_DIR)/etc/mender/scripts
 	echo -n "2" > $(TARGET_DIR)/etc/mender/scripts/version
 
-	$(INSTALL) -D -m 0644 package/mender/mender.conf \
+	$(INSTALL) -D -m 0644 $(MENDER_PKGDIR)/mender.conf \
 		$(TARGET_DIR)/etc/mender/mender.conf
-
-	$(INSTALL) -D -m 0644 package/mender/server.crt \
+	$(INSTALL) -D -m 0644 $(MENDER_PKGDIR)/server.crt \
 		$(TARGET_DIR)/etc/mender/server.crt
 
 	$(INSTALL) -D -m 0755 $(@D)/support/mender-device-identity \
@@ -61,7 +60,7 @@ endef
 MENDER_POST_INSTALL_TARGET_HOOKS += MENDER_INSTALL_CONFIG_FILES
 
 define MENDER_INSTALL_INIT_SYSTEMD
-	$(INSTALL) -D -m 0644 package/mender/mender.service \
+	$(INSTALL) -D -m 0644 $(MENDER_PKGDIR)/mender.service \
 		$(TARGET_DIR)/usr/lib/systemd/system/mender.service
 	mkdir -p $(TARGET_DIR)/etc/systemd/system/multi-user.target.wants
 	ln -fs ../../../../usr/lib/systemd/system/mender.service \

--
2.11.0

#33 lore raw

PATCH v2 12/14 package/mender: use MENDER_PKGDIR to access local files

Hello,

Quoted 9 lines · Mirza Krak

Utilize the predefined variable MENDER_PKGDIR which points to the directory containing mender.mk and Config.in, along with the local files.

One benefit is also that it works when BR2_EXTERNAL is used, which makes it easier to "backport" this to an older external tree.

---

Applied to master, thanks.

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
author
#34 lore raw

PATCH v2 13/14 package/mender: add BR2_PACKAGE_MENDER_ARTIFACT_NAME option

In reply to Mirza Krak

ARTIFACT_NAME is used to set a unique string of the built artifact/image and this will be reported to the Mender managment server as "current software running".

The Mender managment server will skip updating device if the ARTIFACT_NAME is the same on the target device as in the Mender artifact and hence this name must be unique for every release.

---
 package/mender/Config.in | 13 +++++++++++++
 package/mender/mender.mk |  7 +++++++
 2 files changed, 20 insertions(+)
package/mender/Config.in +13 -0
index 853a472ea1..8a6359c906 100644
@@ -14,6 +14,19 @@ config BR2_PACKAGE_MENDER
 
 	  https://github.com/mendersoftware/mender
 
+if BR2_PACKAGE_MENDER
+
+config BR2_PACKAGE_MENDER_ARTIFACT_NAME
+	string "Mender artifact name"
+	help
+	  The name of the image or update that will be built. This is
+	  what the device will report that it is running, and different
+	  updates must have different names.
+
+	  Will be stored in /etc/mender/artifact_info
+
+endif
+
 comment "mender needs a toolchain w/ threads"
 	depends on BR2_PACKAGE_HOST_GO_ARCH_SUPPORTS
 	depends on BR2_PACKAGE_HOST_GO_CGO_LINKING_SUPPORTS
package/mender/mender.mk +7 -0
index a4b9c6ee85..0d4df3a763 100644
@@ -34,6 +34,10 @@ MENDER_LICENSE_FILES = \
 
 MENDER_LDFLAGS = -X main.Version=$(MENDER_VERSION)
 
+ifeq ($(call qstrip,$(BR2_PACKAGE_MENDER_ARTIFACT_NAME)),)
+$(error Mender device type not set. Check your BR2_PACKAGE_MENDER_ARTIFACT_NAME setting)
+endif
+
 define MENDER_INSTALL_CONFIG_FILES
 	$(INSTALL) -d -m 755 $(TARGET_DIR)/data/mender
 	$(INSTALL) -d -m 755 $(TARGET_DIR)/data/uboot
@@ -55,6 +59,9 @@ define MENDER_INSTALL_CONFIG_FILES
 	)
 
 	ln -sf /data/mender $(TARGET_DIR)/var/lib/mender
+
+	echo "artifact_name=$(call qstrip,$(BR2_PACKAGE_MENDER_ARTIFACT_NAME))" > \
+		$(TARGET_DIR)/etc/mender/artifact_info
 endef
 
 MENDER_POST_INSTALL_TARGET_HOOKS += MENDER_INSTALL_CONFIG_FILES
Signature · 1 line
2.11.0
#35 lore raw

PATCH v2 13/14 package/mender: add BR2_PACKAGE_MENDER_ARTIFACT_NAME option

Quoted 7 lines · Mirza Krak

ARTIFACT_NAME is used to set a unique string of the built artifact/image and this will be reported to the Mender managment server as "current software running".

The Mender managment server will skip updating device if the ARTIFACT_NAME is the same on the target device as in the Mender artifact and hence this name must be unique for every release.

When a package needs some configuration, we don't usually add configure options
for it, but instead assume the user will create the necessary configuration files in an overlay.

In particular in this case, you probably want to generate it with a script that
looks at a git tag or something like that.

This would be something good to document in the readme.txt that you were going
to write.

If you want to deliver an out-of-the-box experience, you could create files
with some default values (which would normally get overwritten in the overlay). But I'm not even sure we really want that.

So I've marked this patch and the following one as Rejected.

Regards,
Arnout

Quoted 57 lines
---
 package/mender/Config.in | 13 +++++++++++++
 package/mender/mender.mk |  7 +++++++
 2 files changed, 20 insertions(+)
package/mender/Config.in +13 -0
index 853a472ea1..8a6359c906 100644
@@ -14,6 +14,19 @@ config BR2_PACKAGE_MENDER
 
 	  https://github.com/mendersoftware/mender
 
+if BR2_PACKAGE_MENDER
+
+config BR2_PACKAGE_MENDER_ARTIFACT_NAME
+	string "Mender artifact name"
+	help
+	  The name of the image or update that will be built. This is
+	  what the device will report that it is running, and different
+	  updates must have different names.
+
+	  Will be stored in /etc/mender/artifact_info
+
+endif
+
 comment "mender needs a toolchain w/ threads"
 	depends on BR2_PACKAGE_HOST_GO_ARCH_SUPPORTS
 	depends on BR2_PACKAGE_HOST_GO_CGO_LINKING_SUPPORTS
package/mender/mender.mk +7 -0
index a4b9c6ee85..0d4df3a763 100644
@@ -34,6 +34,10 @@ MENDER_LICENSE_FILES = \
 
 MENDER_LDFLAGS = -X main.Version=$(MENDER_VERSION)
 
+ifeq ($(call qstrip,$(BR2_PACKAGE_MENDER_ARTIFACT_NAME)),)
+$(error Mender device type not set. Check your BR2_PACKAGE_MENDER_ARTIFACT_NAME setting)
+endif
+
 define MENDER_INSTALL_CONFIG_FILES
 	$(INSTALL) -d -m 755 $(TARGET_DIR)/data/mender
 	$(INSTALL) -d -m 755 $(TARGET_DIR)/data/uboot
@@ -55,6 +59,9 @@ define MENDER_INSTALL_CONFIG_FILES
 	)
 
 	ln -sf /data/mender $(TARGET_DIR)/var/lib/mender
+
+	echo "artifact_name=$(call qstrip,$(BR2_PACKAGE_MENDER_ARTIFACT_NAME))" > \
+		$(TARGET_DIR)/etc/mender/artifact_info
 endef
 
 MENDER_POST_INSTALL_TARGET_HOOKS += MENDER_INSTALL_CONFIG_FILES
author
#36 lore raw

PATCH v2 14/14 package/mender: add BR2_PACKAGE_MENDER_DEVICE_TYPE option

In reply to Mirza Krak

MENDER_DEVICE_TYPE is used to verify compatibility of Mender artifacts against devices and it will also be reported to the Mender management server from the device for the server to be able to verify this.

Device type can not change once a device has been provisioned with the initial software and this is why it is stored on the persistent data partition which is preserved across updates.

---
 package/mender/Config.in | 11 +++++++++++
 package/mender/mender.mk |  7 +++++++
 2 files changed, 18 insertions(+)
package/mender/Config.in +11 -0
index 8a6359c906..c9987adc36 100644
@@ -25,6 +25,17 @@ config BR2_PACKAGE_MENDER_ARTIFACT_NAME
 
 	  Will be stored in /etc/mender/artifact_info
 
+config BR2_PACKAGE_MENDER_DEVICE_TYPE
+	string "Mender device type"
+	help
+	  A string that defines the type of device which will be used
+	  to check compatibility of update artifacts. Once a device is
+	  flashed with this, it will not change, even if the device is
+	  updated using Mender.
+
+	  Will be stored in /data/mender/device_type. Note that /data
+	  is a mount point for the persistent data partition.
+
 endif
 
 comment "mender needs a toolchain w/ threads"
package/mender/mender.mk +7 -0
index 0d4df3a763..89965f4c85 100644
@@ -38,6 +38,10 @@ ifeq ($(call qstrip,$(BR2_PACKAGE_MENDER_ARTIFACT_NAME)),)
 $(error Mender device type not set. Check your BR2_PACKAGE_MENDER_ARTIFACT_NAME setting)
 endif
 
+ifeq ($(call qstrip,$(BR2_PACKAGE_MENDER_DEVICE_TYPE)),)
+$(error Mender device type not set. Check your BR2_PACKAGE_MENDER_DEVICE_TYPE setting)
+endif
+
 define MENDER_INSTALL_CONFIG_FILES
 	$(INSTALL) -d -m 755 $(TARGET_DIR)/data/mender
 	$(INSTALL) -d -m 755 $(TARGET_DIR)/data/uboot
@@ -62,6 +66,9 @@ define MENDER_INSTALL_CONFIG_FILES
 
 	echo "artifact_name=$(call qstrip,$(BR2_PACKAGE_MENDER_ARTIFACT_NAME))" > \
 		$(TARGET_DIR)/etc/mender/artifact_info
+
+	echo "device_type=$(call qstrip,$(BR2_PACKAGE_MENDER_DEVICE_TYPE))" > \
+		$(TARGET_DIR)/data/mender/device_type
 endef
 
 MENDER_POST_INSTALL_TARGET_HOOKS += MENDER_INSTALL_CONFIG_FILES
Signature · 1 line
2.11.0