czechlight-cfg-fs: add YANG install script

Let's move cla-sysrepo's install-yang shell script to this package.
Normally, all the packages would have installed these YANGs by
themselves, but because there's no shared state in rootfs, only
in /cfg, so that's where all these modifications belong

Change-Id: Ia5f4ade46098d66a92d940366659e44f9ea74456
diff --git a/package/cla-sysrepo/Config.in b/package/cla-sysrepo/Config.in
index e9804e6..0a40ee3 100644
--- a/package/cla-sysrepo/Config.in
+++ b/package/cla-sysrepo/Config.in
@@ -9,5 +9,6 @@
 	select BR2_PACKAGE_BOOST
 	select BR2_PACKAGE_CPPCODEC
 	select BR2_PACKAGE_LIBEV
+	select BR2_PACKAGE_CZECHLIGHT_CFG_FS
 	help
 	  Control CzechLight devices over YANG with sysrepo
diff --git a/package/cla-sysrepo/cla-sysrepo.mk b/package/cla-sysrepo/cla-sysrepo.mk
index a54755c..9ef7eee 100644
--- a/package/cla-sysrepo/cla-sysrepo.mk
+++ b/package/cla-sysrepo/cla-sysrepo.mk
@@ -16,11 +16,7 @@
 endef
 
 define CLA_SYSREPO_INSTALL_INIT_SYSTEMD
-	$(INSTALL) -m 0755 -t $(TARGET_DIR)/usr/bin/ \
-		$(BR2_EXTERNAL_CZECHLIGHT_PATH)/package/cla-sysrepo/czechlight-install-yang.sh
 	mkdir -p $(TARGET_DIR)/usr/lib/systemd/system/multi-user.target.wants
-	$(INSTALL) -D -m 0644 -t $(TARGET_DIR)/usr/lib/systemd/system/ \
-		$(BR2_EXTERNAL_CZECHLIGHT_PATH)/package/cla-sysrepo/czechlight-install-yang.service
 
 	$(call CLA_SYSREPO_PREPARE_SERVICE,sdn-roadm-add-drop)
 	$(call CLA_SYSREPO_PREPARE_SERVICE,sdn-roadm-hires-add-drop)
diff --git a/package/czechlight-cfg-fs/Config.in b/package/czechlight-cfg-fs/Config.in
index e47d42f..40e6409 100644
--- a/package/czechlight-cfg-fs/Config.in
+++ b/package/czechlight-cfg-fs/Config.in
@@ -1,11 +1,14 @@
 config BR2_PACKAGE_CZECHLIGHT_CFG_FS
-	bool "Prepare persistent /cfg partition and /etc overlay"
+	bool "Prepare persistent /cfg partition and /etc overlay. Install required YANG models."
 	depends on BR2_INIT_SYSTEMD
+	depends on BR2_PACKAGE_NETOPEER2
 	help
 	  This is required for RAUC to work properly.  It creates a blank FS
 	  image, configures systemd to mount it, and ensures that its contents
 	  get restored to /etc at boot.  The /etc is set up as a RW overlay on
 	  top of a read-only rootfs.
+	  This takes care of installing YANG files used by czechlight system
+	  daemons into sysrepo.
 
 if BR2_PACKAGE_CZECHLIGHT_CFG_FS
 
diff --git a/package/czechlight-cfg-fs/czechlight-cfg-fs.mk b/package/czechlight-cfg-fs/czechlight-cfg-fs.mk
index bf000bd..4d79447 100644
--- a/package/czechlight-cfg-fs/czechlight-cfg-fs.mk
+++ b/package/czechlight-cfg-fs/czechlight-cfg-fs.mk
@@ -1,5 +1,5 @@
 CZECHLIGHT_CFG_FS_INSTALL_IMAGES = YES
-CZECHLIGHT_CFG_FS_DEPENDENCIES = host-e2fsprogs host-libyang netopeer2
+CZECHLIGHT_CFG_FS_DEPENDENCIES = host-e2fsprogs host-libyang netopeer2 systemd
 
 CZECHLIGHT_CFG_FS_LOCATION = $(BINARIES_DIR)/cfg.ext4
 
@@ -25,6 +25,11 @@
 		$(BR2_EXTERNAL_CZECHLIGHT_PATH)/package/czechlight-cfg-fs/init-czechlight.sh \
 		$(TARGET_DIR)/sbin/init-czechlight.sh
 	$(INSTALL) -D -m 0755 $(@D)/czechlight-random-seed $(TARGET_DIR)/sbin/czechlight-random-seed
+	$(INSTALL) -m 0755 -t $(TARGET_DIR)/usr/bin/ \
+		$(BR2_EXTERNAL_CZECHLIGHT_PATH)/package/czechlight-cfg-fs/czechlight-install-yang.sh
+	$(INSTALL) -D -m 0644 -t $(TARGET_DIR)/usr/lib/systemd/system/ \
+		$(BR2_EXTERNAL_CZECHLIGHT_PATH)/package/czechlight-cfg-fs/czechlight-install-yang.service
+	ln -sf ../czechlight-install-yang.service $(TARGET_DIR)/usr/lib/systemd/system/multi-user.target.wants/
 	mkdir -p $(TARGET_DIR)/cfg
 	$(INSTALL) -D -m 0644 \
 	    --target-directory $(TARGET_DIR)/usr/lib/systemd/system/ \
diff --git a/package/cla-sysrepo/czechlight-install-yang.service b/package/czechlight-cfg-fs/czechlight-install-yang.service
similarity index 100%
rename from package/cla-sysrepo/czechlight-install-yang.service
rename to package/czechlight-cfg-fs/czechlight-install-yang.service
diff --git a/package/cla-sysrepo/czechlight-install-yang.sh b/package/czechlight-cfg-fs/czechlight-install-yang.sh
similarity index 100%
rename from package/cla-sysrepo/czechlight-install-yang.sh
rename to package/czechlight-cfg-fs/czechlight-install-yang.sh
diff --git a/package/velia/Config.in b/package/velia/Config.in
index 4499ba0..cfec923 100644
--- a/package/velia/Config.in
+++ b/package/velia/Config.in
@@ -9,6 +9,7 @@
 	select BR2_PACKAGE_SYSREPO
 	select BR2_PACKAGE_SYSREPO_CPP
 	select BR2_PACKAGE_JSON_FOR_MODERN_CPP
+	select BR2_PACKAGE_CZECHLIGHT_CFG_FS
 	help
 	  Health tracking for embedded devices running Linux