jketterl / codecserver

Modular audio codec server
GNU General Public License v3.0
15 stars 5 forks source link

Configuration file 'codecserver.conf' does not get installed #2

Closed fventuri closed 3 years ago

fventuri commented 3 years ago

Jakob, it looks like the configuration file codecserver.conf does not get installed when running the command sudo make install.

I was able to fix the problem here by adding this line to the top CMakeLists.txt:

add_subdirectory(conf)

and creating a very simple cmake config file conf/CMakeLists.txt with this content:

install(FILES
    codecserver.conf
    DESTINATION etc/codecserver
)

Feel free to make these (or similar) changes if you see the same problem; if it makes your life easier, I can create a pull request.

73, Franco K4VZ

jketterl commented 3 years ago

I already had something similar in the cmake files at some point, and while it worked fine for an initial installation, there's problems with cmake potentially overwriting the user configuration during subsequent runs. I haven't looked this up in detail, but I think this happens whenever the file in the repository has a newer timestamp than the installed file.

I have not found any more suitable handling in cmake, and I have not gotten round to building something myself, so I left this as a manual step for now. The Debian packaging has some extra install lines for this file, and they work fine because dpkg has special handling for configs (anything under /etc is assumed to be a config file automatically).

fventuri commented 3 years ago

Jakob, good point.

if(NOT EXISTS "${CMAKE_INSTALL_PREFIX}/etc/codecserver/codecserver.conf")
    install(FILES
        codecserver.conf
        DESTINATION etc/codecserver
    )
endif()

Franco

jketterl commented 3 years ago

Sorry, but I'm afraid this needs more thought. I've just tried the snippet (with some modification, see below), but I've already had an overwrite on the first try. My suspicion is that the protecting condition is only executed when cmake itself runs, but not during the actual make install call. If I repeat the cmake command line call before the second make install call, the file is omitted as expected.

Modifications to make use of GnuInstallDirs:

if(NOT EXISTS "${CMAKE_INSTALL_FULL_SYSCONFDIR}/codecserver/codecserver.conf")
    install(FILES
        ../../conf/codecserver.conf
        DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}/codecserver
    )
endif()

There's probably a very simple, obvious solution, I'll leave this for now. I'm pretty sure that one day I'll find it by accident :smile:

fventuri commented 3 years ago

No problem at all Jakob! I appreciate all your work on OpenWebRX.

73, Franco K4VZ