Installing Custom package containing files of another package

Hello All,

I am building an image for Sama5d2 Atmel chip with OpenWRT.

In my openwrt build, I have modified many lua scripts provided by the package luci-base. For all these modified files, I have created a separate package. This separate package will copy these modified files into the file system but with enabling this package, If i build the openwrt image, I get this error.

Configuring wireless-tools.
Configuring kmod-ipt-offload.
Configuring ppp-mod-pppoe.
Collected errors:
 * resolve_conffiles: Existing conffile /home/chandresh/goodFromB/zoll_medical/openWRT/openWRT_18.06/openwrt-at91/build_dir/target-arm_cortex-a5+neon-vfpv4_glibc_eabi/root-at91/etc/config/firewall is different from the conffile in the new package. The new conffile will be placed at /home/chandresh/goodFromB/zoll_medical/openWRT/openWRT_18.06/openwrt-at91/build_dir/target-arm_cortex-a5+neon-vfpv4_glibc_eabi/root-at91/etc/config/firewall-opkg.
 * check_data_file_clashes: Package web-UI wants to install file /home/chandresh/goodFromB/zoll_medical/openWRT/openWRT_18.06/openwrt-at91/build_dir/target-arm_cortex-a5+neon-vfpv4_glibc_eabi/root-at91/usr/lib/lua/luci/cacheloader.lua
        But that file is already provided by package  * luci-base
 * check_data_file_clashes: Package web-UI wants to install file /home/chandresh/goodFromB/zoll_medical/openWRT/openWRT_18.06/openwrt-at91/build_dir/target-arm_cortex-a5+neon-vfpv4_glibc_eabi/root-at91/usr/lib/lua/luci/cbi/datatypes.lua
        But that file is already provided by package  * luci-base
 * check_data_file_clashes: Package web-UI wants to install file /home/chandresh/goodFromB/zoll_medical/openWRT/openWRT_18.06/openwrt-at91/build_dir/target-arm_cortex-a5+neon-vfpv4_glibc_eabi/root-at91/usr/lib/lua/luci/cbi.lua
        But that file is already provided by package  * luci-base
 * check_data_file_clashes: Package web-UI wants to install file /home/chandresh/goodFromB/zoll_medical/openWRT/openWRT_18.06/openwrt-at91/build_dir/target-arm_cortex-a5+neon-vfpv4_glibc_eabi/root-at91/usr/lib/lua/luci/ccache.lua
        But that file is already provided by package  * luci-base
 * check_data_file_clashes: Package web-UI wants to install file /home/chandresh/goodFromB/zoll_medical/openWRT/openWRT_18.06/openwrt-at91/build_dir/target-arm_cortex-a5+neon-vfpv4_glibc_eabi/root-at91/usr/lib/lua/luci/config.lua
        But that file is already provided by package  * luci-base

Is there any way to install my modified files into the image with by another package?

Thanks,
Chandresh

opkg --help

opkg ... 	
--force-overwrite	Overwrite files from other package(s)
1 Like

Thanks for answering.

I am building the image file. Is there any configuration option in menuconfig for adding "--force-overwrite" option or can you tell me which Makefile, Should i add this "--force-overwrite" command?

Is it possible, I mean i can overwrite opkg package in the openwrt build right?

Chandresh

Please post the output of;

git remote -v

Please use the "Preformatted text </>" button for logs, scripts, configs and general console output.
grafik
Please edit your post accordingly. Thank you! :slight_smile:

fwiw... you need to either use your own "alternate" package ( via the use of a local feed or altering the original package files within the feed dir ) or make use of "./files"...

Just add this option to your opkg install command line... like :

opkg install <custompackage> --force-overwrite

My git repository is local to my organisation. I am using openWRT which is provided by Atmel. I followed this link for openWRT build.
https://www.linux4sam.org/bin/view/Linux4SAM/OpenWrt

I am using luci feed and for my modified lua files which i am trying to install at /usr/lib/lua/luci/* directory using my custom feed and custom package. Here is my package makefile.

include $(TOPDIR)/rules.mk

# Name, version and release number
# The name and version of your package are used to define the variable to point to the build directory of your package: $(PKG_BUILD_DIR)
PKG_NAME:=web-UI
PKG_VERSION:=1.0
PKG_RELEASE:=1

# Source settings (i.e. where to find the source codes)
# This is a custom variable, used below

include $(INCLUDE_DIR)/package.mk

# Package definition; instructs on how and where our package will appear in the overall configuration menu ('make menuconfig')
define Package/web-UI
  SECTION:=web-UI
  CATEGORY:=Zoll-Applications
  TITLE:=web-UI
endef

# Package preparation instructions; create the build directory and copy the source code.
# The last command is necessary to ensure our preparation instructions remain compatible with the patching system.
define Build/Prepare
        echo "Compilation Step for web-UI if required"
endef

# Package build instructions; invoke the target-specific compiler to first compile the source file, and then to link the file into the final executable
define Build/Compile
        echo "Compilation Step2 for web-UI if required"
endef

# Package description; a more verbose description on what our package does
define Package/web-UI/description
        To copy the web-UI related files in the file system.
endef

# Package install instructions; create a directory inside the package to hold our executable, and then copy the executable we built previously into the folder
define Package/web-UI/install
        rsync -a ./files/* $(1)/
endef

# This command is always the last, it uses the definitions and variables we give above in order to get the job done
$(eval $(call BuildPackage,web-UI))

In the files directory, If I keep any files or directory which is not present in the file system (Not provided by any other package), Then the image is built properly without any error but problem is if I try to modify any files in the "files/" directory which is provided by any other package like lua-base
For example, If my "files" directory is like this, I will get the error as these files are provided by luci-base

files/
├── etc
│   └── testFile
├── usr
│   └── lib
│       └── lua
│           └── luci
│               ├── cacheloader.lua
│               ├── cbi
│               │   └── datatypes.lua
│               ├── cbi.lua
│               ├── ccache.lua
│               ├── config.lua
│               ├── controller
│               │   ├── admin
│               │   │   ├── admin.lua
│               │   │   ├── filebrowser.lua
│               │   │   ├── index.lua
│               │   │   ├── network.lua
│               │   │   ├── settings.lua
│               │   │   ├── status.lua
│               │   │   ├── system.lua
│               │   │   ├── systemsetting.lua
│               │   │   └── uci.lua
│               │   └── firewall.lua
│               ├── debug.lua
│               ├── dispatcher.lua
│               ├── http.lua
│               ├── i18n.lua

Thanks,
Chandresh

Given that you have already been informed that you are not working with
official OpenWrt sources. The least you can do is avoid deception in your posts and tell other users that you are working with a "fork of OpenWrt".

There are several reasons for this, but primarily it is to ensure that you are not wasting the time of others or exposing yourself to risks that would not be the case using official sources;

  • Forks may contain many modifications
  • Forks may use non official package feeds
  • Forks may use old, insecure versions which are a risk to you and also difficult/improper for the current userbase to offer input to

If you are using a fork... tell people... be honest and upfront... i'm sure you expect the same in return.

1 Like

There is no clean, supported way to have one package overwrite files contained in another package. It appears you attempt to overwrite parts of LuCI (for customization, I guess) - best is to deselect LuCI entirely and only install your own Web-UI packages.

3 Likes

@jow
Thank you.

@anon50098793
I am sorry

I knew that I was using OpenWRT provided by Atmel but I didn't on purpose hide the information about me using "fork of OpenWrt". I would never do that.
Anyhow, Next time if I post anything, I will keep it in mind.

1 Like

Thankyou :upside_down_face:

seeings your such a good sport...

  • don't use files ( or at least in combination other stuff )
  • follow this (or similar ) in a new clone...
  • urge your vendor to upstream/update their device/repo so you can work with more recent code and avoid security/support issues.

basically you are "replacing an official package with a custom one"... there are quite a few posts / guides and resources on this topic if you search properly. nothing unsolvable with due diligence and practice.

1 Like

I found that the luci-base and luci-mod-admin-full are the two packages containing all these files so later on, i will replace files of those packages with either patch or scripting.

For now, I am updating the image itself, I.e once the zip gets created, mount it, update the contents anc create image out of thoses updated content.

@anon50098793: Thanks for the help.

Chandresh

If someone comes across this problem, the solution might be something like this

From af97aede375e52dfbd7bd1f4a30cc13e4aa1bcd9 Mon Sep 17 00:00:00 2001
From: iuncuim <iuncuim@gmail.com>
Date: Tue, 13 Apr 2021 09:56:25 +0300
Subject: [PATCH] MAKE: overwrite conf

---
 include/feeds.mk  |  7 ++++++-
 include/image.mk  |  8 ++++++++
 include/rootfs.mk | 12 ++++++++++++
 3 files changed, 26 insertions(+), 1 deletion(-)

diff --git a/include/feeds.mk b/include/feeds.mk
index 98e315b..af57068 100644
--- a/include/feeds.mk
+++ b/include/feeds.mk
@@ -13,9 +13,14 @@ ifneq ($(CONFIG_PER_FEED_REPO),)
   PACKAGE_SUBDIRS += $(OUTPUT_DIR)/packages/$(ARCH_PACKAGES)/base
   PACKAGE_SUBDIRS += $(foreach FEED,$(FEEDS_AVAILABLE),$(OUTPUT_DIR)/packages/$(ARCH_PACKAGES)/$(FEED))
 endif
+PACKAGE_SUBDIRS_FORCE=$(OUTPUT_DIR)/packages/$(ARCH_PACKAGES)/custom_feed
 
 opkg_package_files = $(wildcard \
-	$(foreach dir,$(PACKAGE_SUBDIRS), \
+	$(foreach dir,$(filter-out $(PACKAGE_SUBDIRS_FORCE),$(PACKAGE_SUBDIRS)), \
+	  $(foreach pkg,$(1), $(dir)/$(pkg)_*.ipk)))
+
+opkg_package_files_overwrite = $(wildcard \
+	$(foreach dir,$(PACKAGE_SUBDIRS_FORCE), \
 	  $(foreach pkg,$(1), $(dir)/$(pkg)_*.ipk)))
 
 # 1: package name
diff --git a/include/image.mk b/include/image.mk
index 2530108..42e452c 100644
--- a/include/image.mk
+++ b/include/image.mk
@@ -314,6 +314,10 @@ opkg_target = \
 	$(call opkg,$(mkfs_cur_target_dir)) \
 		-f $(mkfs_cur_target_dir).conf
 
+opkg_overwrite_target = \
+  $(call opkg_overwrite,$(mkfs_cur_target_dir)) \
+    -f $(mkfs_cur_target_dir).conf
+
 target-dir-%: FORCE
 	rm -rf $(mkfs_cur_target_dir) $(mkfs_cur_target_dir).opkg
 	$(CP) $(TARGET_DIR_ORIG) $(mkfs_cur_target_dir)
@@ -326,6 +330,10 @@ target-dir-%: FORCE
 		$(opkg_target) update && \
 		$(opkg_target) install \
 			$(call opkg_package_files,$(mkfs_packages_add)))
+	$(if $(call opkg_package_files_overwrite,$(mkfs_packages_add)), \
+		$(opkg_overwrite_target) update && \
+		$(opkg_overwrite_target) install \
+			$(call opkg_package_files_overwrite,$(mkfs_packages_add)))
 	-$(CP) -T $(mkfs_cur_target_dir).opkg/ $(mkfs_cur_target_dir)/etc/opkg/
 	rm -rf $(mkfs_cur_target_dir).opkg $(mkfs_cur_target_dir).conf
 	$(call prepare_rootfs,$(mkfs_cur_target_dir),$(TOPDIR)/files)
diff --git a/include/rootfs.mk b/include/rootfs.mk
index f2ed648..f7645f3 100644
--- a/include/rootfs.mk
+++ b/include/rootfs.mk
@@ -43,6 +43,18 @@ opkg = \
 	--add-arch all:100 \
 	--add-arch $(if $(ARCH_PACKAGES),$(ARCH_PACKAGES),$(BOARD)):200
 
+opkg_overwrite = \
+  IPKG_NO_SCRIPT=1 \
+  IPKG_INSTROOT=$(1) \
+  TMPDIR=$(1)/tmp \
+  $(STAGING_DIR_HOST)/bin/opkg \
+	--offline-root $(1) \
+	--force-postinstall \
+	--force-overwrite \
+	--add-dest root:/ \
+	--add-arch all:100 \
+	--add-arch $(if $(ARCH_PACKAGES),$(ARCH_PACKAGES),$(BOARD)):200
+
 TARGET_DIR_ORIG := $(TARGET_ROOTFS_DIR)/root.orig-$(BOARD)
 
 ifdef CONFIG_CLEAN_IPKG
-- 
2.7.4

Or just add "--force-overwrite " in rootfs.mk. In this case "custom_feed" should be the last on the feeds.conf.default

2 Likes