crux-arm / crux-arm-release

Build CRUX-ARM releases for generic and optimized devices
GNU General Public License v3.0
4 stars 3 forks source link

Release build not setting pkgmk.conf and prt-get.conf file properly #1

Closed pitill0 closed 1 year ago

pitill0 commented 2 years ago

We are facing an issue when building the final release rootfs. The process is always setting up generic files instead of optimized ones.

This patch is intended to copy specific config files (pkgmk.conf and prt-get.conf) for optimized devices to the corresponding path according to the optimization chosen:

$ diff -uN Makefile.orig Makefile
--- Makefile.orig       2022-10-30 00:03:18.774386901 +0200
+++ Makefile    2022-10-30 00:03:12.122385746 +0200
@@ -344,12 +344,26 @@
 $(RELEASE_TAR_FILE): $(ROOTFS_STAGE1_DIR)
        @echo "[`date +'%F %T'`] Cleaning up"
        @test ! -d $(ROOTFS_STAGE1_DIR)/workspace || sudo rmdir $(ROOTFS_STAGE1_DIR)/workspace
-       @sudo rm -f $(ROOTFS_STAGE1_DIR)/etc/pkgmk.conf && \
-               sudo cp $(PORTS_DIR)/core-arm/pkgutils/pkgmk.conf $(ROOTFS_STAGE1_DIR)/etc/pkgmk.conf
-       @sudo rm -f $(ROOTFS_STAGE1_DIR)/etc/prt-get.conf && \
-               sudo cp $(PORTS_DIR)/core-arm/prt-get/prt-get.conf $(ROOTFS_STAGE1_DIR)/etc/prt-get.conf
+ifeq ($(DEVICE_OPTIMIZATION),arm)
+       @sudo cp -v $(PORTS_DIR)/core-$(DEVICE_OPTIMIZATION)/pkgutils/pkgmk.conf $(ROOTFS_STAGE1_DIR)/etc/ || true && \
+               sudo cp -v $(PORTS_DIR)/core-$(DEVICE_OPTIMIZATION)/prt-get/prt-get.conf $(ROOTFS_STAGE1_DIR)/etc/ || true
+else ifeq ($(DEVICE_OPTIMIZATION),arm64)
+       @sudo cp -v $(PORTS_DIR)/core-$(DEVICE_OPTIMIZATION)/pkgutils/pkgmk.conf $(ROOTFS_STAGE1_DIR)/etc/ || true  && \
+               sudo cp -v $(PORTS_DIR)/core-$(DEVICE_OPTIMIZATION)/prt-get/prt-get.conf $(ROOTFS_STAGE1_DIR)/ || true
+else
+       @if [ -e "$(PORTS_DIR)/$(DEVICE_OPTIMIZATION)-arm/pkgutils/pkgmk.conf" ]; then \
+               sudo cp -v $(PORTS_DIR)/$(DEVICE_OPTIMIZATION)-arm/pkgutils/pkgmk.conf $(ROOTFS_STAGE1_DIR)/etc/ ;\
+       else \
+               sudo cp -v $(PORTS_DIR)/$(DEVICE_OPTIMIZATION)-arm64/pkgutils/pkgmk.conf $(ROOTFS_STAGE1_DIR)/etc/ ;\
+       fi
+       @if [ -e "$(PORTS_DIR)/$(DEVICE_OPTIMIZATION)-arm/prt-get/prt-get.conf" ]; then \
+               sudo cp -v $(PORTS_DIR)/$(DEVICE_OPTIMIZATION)-arm/prt-get/prt-get.conf $(ROOTFS_STAGE1_DIR)/etc/ ;\
+       else \
+               sudo cp -v $(PORTS_DIR)/$(DEVICE_OPTIMIZATION)-arm64/prt-get/prt-get.conf $(ROOTFS_STAGE1_DIR)/etc/ ;\
+       fi
+endif
        @echo "[`date +'%F %T'`] Building $(RELEASE_TAR_FILE)"
        @cd $(ROOTFS_STAGE1_DIR) && \
-               sudo tar cJf $(RELEASE_TAR_FILE) * && \
+               sudo tar cJf ../$(RELEASE_TAR_FILE) * && \
                sudo chown $(CURRENT_UID):$(CURRENT_GID) $(RELEASE_TAR_FILE)
-       @echo "[`date +'%F %T'`] Release completed"
+       @echo "[`date +'%F %T'`] Release completed"
sepen commented 2 years ago

LGTM but why you use ../$(RELEASE_TAR_FILE). The RELEASE_TAR_FILE should be an absolute path so there is no need to use ../

sepen commented 2 years ago

I think we can do it in a simpler way. We can get the first value of the COLLECTIONS list variable.

--- a/Makefile
+++ b/Makefile
@@ -344,10 +344,11 @@ release: $(RELEASE_TAR_FILE)
 $(RELEASE_TAR_FILE): $(ROOTFS_STAGE1_DIR)
        @echo "[`date +'%F %T'`] Cleaning up"
        @test ! -d $(ROOTFS_STAGE1_DIR)/workspace || sudo rmdir $(ROOTFS_STAGE1_DIR)/workspace
-       @sudo rm -f $(ROOTFS_STAGE1_DIR)/etc/pkgmk.conf && \
-               sudo cp $(PORTS_DIR)/core-arm/pkgutils/pkgmk.conf $(ROOTFS_STAGE1_DIR)/etc/pkgmk.conf
-       @sudo rm -f $(ROOTFS_STAGE1_DIR)/etc/prt-get.conf && \
-               sudo cp $(PORTS_DIR)/core-arm/prt-get/prt-get.conf $(ROOTFS_STAGE1_DIR)/etc/prt-get.conf
+       @sudo rm -f $(ROOTFS_STAGE1_DIR)/etc/pkgmk.conf
+       @sudo rm -f $(ROOTFS_STAGE1_DIR)/etc/prt-get.conf
+       @echo "[`date +'%F %T'`] Copying config files"
+       @sudo cp $(PORTS_DIR)/$(word 1, $(COLLECTIONS))/pkgutils/pkgmk.conf $(ROOTFS_STAGE1_DIR)/etc/pkgmk.conf
+       @sudo cp $(PORTS_DIR)/$(word 1, $(COLLECTIONS))/prt-get/prt-get.conf $(ROOTFS_STAGE1_DIR)/etc/prt-get.conf
        @echo "[`date +'%F %T'`] Building $(RELEASE_TAR_FILE)"
        @cd $(ROOTFS_STAGE1_DIR) && \
                sudo tar cJf $(RELEASE_TAR_FILE) * && \
pitill0 commented 2 years ago

It serms to be a cleaner and a simpler way to manager this issue.

I'll test this patch locally and I'll share results.

pitill0 commented 2 years ago

It seems to be working right. This issue can be closed.