OpenWrt Forum Archive

Topic: What causes entries in /lib/upgrade/keep.d ?

The content of this topic has been archived on 6 May 2016. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Hi

I'm going to build a package that defines files that should be kept when doing sysupgrade.

Looking around I found a Makefile that does a direct entry:

$(INSTALL_DATA) ./files/firewall.upgrade $(1)/lib/upgrade/keep.d/firewall
see: https://dev.openwrt.org/browser/trunk/p … ?rev=36622

But l also found packages like mosquitto that have an entry in keep.d but nothing in the Makefile that seems to do that:
see: https://github.com/remakeelectric/owrt_ … o/Makefile

I thought the following part of the Makefile would trigger it but one line is missing in keep.d
("/etc/mosquitto/mosquitto.conf" is missing):

define Package/$(PKG_NAME)/conffiles
/etc/mosquitto/mosquitto.conf
/etc/config/mosquitto
endef

So, even if I know how to make an entry to keep.d in the Makefile I'm wondering what else is causing entries (or in other words, what is doing the trick in the mosquitto package? I guess it is "something" in the Makefile that I don't understand)

Thanks!

(1) Do you happen to know how to specify which files or folders get preserved during sysupgrade? or exactly which filenames and folders get preserved?

(2) Is there a folder I can create somewhere so that everything in that folder gets preserved during sysupgrade?

(3) do files and folders under "/trunk/files" get added to BOTH FACTORY and SYS-UPGRADE binaries, or just one?

thanks
-rough

Hi rough

what I have found out there are two places where this can be done:
#1 for per-package keepfile lists:
/lib/upgrade/keep.d/
#2 for user defined keepfile hints
/etc/sysupgrade.conf

The firewall example can be studied here:
https://dev.openwrt.org/browser/trunk/p … ?rev=36622
The Makefile puts a file named firewall into the folder  /lib/upgrade/keep.d/
The file firewall itself contains the following line:
/etc/firewall.user
So in the end the file /etc/firewall.user is preserved when doing sysupgrade.

In sysupgrade.conf you might define folders to be preserved. The file is already there and provides a
template, it contains the following lines:
## This file contains files and directories that should
## be preserved during an upgrade.

# /etc/example.conf
# /etc/openvpn/

I don't know if the folders must always be a subdirectory of /etc
Also I don't know how to answer you question #3.
Just be aware that I'm not very familiar with this topic.

My question in this thread is what else (than directly adding a file in the Makefile) triggers an entry in the directory /lib/upgrade/keep.d

Thanks for your response, I wish I could help you, but as you can see I'm just learning this stuff too.

Those entries are usually created by a "define Package/xxx/conffiles" section in the OpenWrt Makefile with one path per line; the following rules apply:

- Directories or files not existing in the package are added to /lib/upgrade/keep.d/xxx
- Files which do exist in the package are not added to keep.d at all but are just marked as configuration file in the .ipk metadata

Later sysupgrade uses the "opkg list-changed-conffiles", the "/etc/sysupgrade.conf" and the "/lib/upgrade/keep.d/*" entries to assemble the list of files to be kept.

So to summarize: the keep.d mechanism is a fallback for entire configuration directories where no specific files can be tracked (think of directories where users are supposed to put one config per instance) or for configuration files which might exist (e.g. some override config file) but which are not shipped with the package - all other shipped, plain config files are tracked by opkg instead.

Hi jow

thanks a lot for your concise explanation and especially for elaborating on the reason keep.d exists.

Looking at the mosquitto package and applying the rules you described I understand now why /etc/mosquitto/mosquitto.conf is missing in keep.d.
This file exists in the package!

Thanks again
lagagja

The discussion might have continued from here.