SynoCommunity / spksrc

Cross compilation framework to create native packages for the Synology's NAS
https://synocommunity.com
Other
3.03k stars 1.23k forks source link

New package development: Where to store config files? #2466

Closed eelcohn closed 6 years ago

eelcohn commented 8 years ago

Hi,

I've been working on a new package called Eggdrop which is an IRC bot. Standard location for the binary files is /volume1/@appstore/[package]/ but what is the standard location for config files? Ideally I would like to put them in a place so that it shows up in the application list in HyperBackup. Any ideas how to do this?

KaraokeStu commented 8 years ago

I believe the standard location would be in a conf folder within the package location (and the best way to reference this is /var/packages/[package]/target/conf as this will deal with people like me who install to /volume2 ;)

@Diaoul any input on this?

Diaoul commented 8 years ago

Using spksrc the standard way to put configuration files is in the var folder under /usr/local/{package}/. This directory is preserved when upgrading. There are plenty of packages using this, take a look.

Diaoul commented 8 years ago

As for the application to show in HyperBackup I don't know how to do that. I suggested the feature long ago to Synology and they implemented it without telling any details. It seems more and more packages are using this (Surveillance, Note, etc.). In DSM 3 there was just Photo Station. Maybe open one of those packages and check inside?

eelcohn commented 8 years ago

Ok, I've checked about 15 Synology packages for DSM6.0 and none of them store anything in /usr/local/{package}/ . They either store config files at ${SYNOPKG_PKGPATH}/target/ (which points to /var/packages/{package}/target/), or they store it at /var/packages/{package}/etc which points to /usr/syno/etc/packages/{package}. The /usr/local/{package}/ seems only to be used in DSM5.2 and lower (can anyone confirm this)?

As long as it's compliant with the spksrc philosophy, I think I'm going with the /var/packages/{package}/etc/ dir, since this dir is preserved when upgrading.

eelcohn commented 8 years ago

As for the HyperBackup integration: it seems that this is accomplished by a couple of fairly simple scripts. I've not been able to get it up and running, but I'm working on that. To keep the threads clean, I'll post my findings in a different issue :)

Diaoul commented 8 years ago

@eelcohuininga: /usr/local/{package}/ in spksrc is a symlink to /var/packages/{package}/target/

eelcohn commented 8 years ago

@Diaoul : thanks, I understand. It's just that I've checked about 15+ official Synology DSM6.0 packages and not a single one creates a symlink in /usr/local/{package}. I'm wondering if Synology decided to drop this symlink in DSM6.0, and decided to store all conf files in $SYNOPKG_PKGDEST/target/ or $SYNOPKG_PKGDEST/etc/ Since I don't have access to a diskstation with DSM5.2 or lower anymore, I cannot check if /usr/local/{package} was a regular before DSM6.0

Diaoul commented 8 years ago

Yes this was way things were done in DSM 3.x and 4.x, not sure about 5.x but the fact that /var/packages/{package}/ is a symlink to /volume1/@appstore/{package}/ is fairly new so we had to create one ourself. Also, /var/packages/{package}/etc/ is quite new as well. I have not tested but I believe this directory isn't removed by package updates or Synology has a new way of keeping data between update.

As far as packaging goes, if you want your package available on SynoCommunity you should conform to the way things are done in spksrc. This makes the maintenance much easier to have all packages following the same rules.

eelcohn commented 8 years ago

I've tested several packages and I can confirm that when DSM6 installs a package, it creates two folders:

/volume1/@appstore/{package}
/usr/syno/etc/packages/{package}

...and two symlinks:

/var/packages/{package}/target ---> /volume1/@appstore/{package}
/var/packages/{package}/etc ---> /usr/syno/etc/packages/{package}

DSM6 always creates these folders and symlinks wether they're used by the package or not.

I can also confirm that data in /usr/syno/etc/packages/{package} is not removed when a package is updated, or even removed. So this location is more of a 'permanent' conf file storage, while conf files stored in /var/packages/{package}/target/etc is more of a 'volatile' storage.

I understand the rules for creating SynoCommunity packages. A solution might be to do something like this in the installer.sh scripts:

if [ "${SYNOPKG_DSM_VERSION_MAJOR}" < 6 ]; then
mkdir /usr/local/${PACKAGE}
elif
ln -l /usr/syno/etc/packages/{package} /usr/local/${PACKAGE}
fi

This way the 'permament' conf files are stored in a location that is backwards compatible with SynoCommunity, and is also compliant with DSM6's way of storing 'permanent' conf files. What do you think @Diaoul?

Safihre commented 6 years ago

Closing due to age. In this repo we now use the Generic Service approach that takes care of the upgrade process and upgrade safekeeping. Can be re-opened in case of issues or questions.