From patchwork Sun Apr 8 17:23:00 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Udo Richter X-Patchwork-Id: 12940 Received: from mail.tu-berlin.de ([130.149.7.33]) by www.linuxtv.org with esmtp (Exim 4.72) (envelope-from ) id 1SGvpP-0001zU-Pv for vdr@linuxtv.org; Sun, 08 Apr 2012 19:23:28 +0200 X-tubIT-Incoming-IP: 213.165.64.22 Received: from mailout-de.gmx.net ([213.165.64.22]) by mail.tu-berlin.de (exim-4.75/mailfrontend-4) with smtp for id 1SGvpP-0001Xi-BH; Sun, 08 Apr 2012 19:23:03 +0200 Received: (qmail invoked by alias); 08 Apr 2012 17:23:01 -0000 Received: from p549D494D.dip0.t-ipconnect.de (EHLO localhost) [84.157.73.77] by mail.gmx.net (mp032) with SMTP; 08 Apr 2012 19:23:01 +0200 X-Authenticated: #1417946 X-Provags-ID: V01U2FsdGVkX1/aSyUymIPaCyaJK6BIHCjLSHbzGQbHM3RgxDFK6R OxujDd91oPVr8M Message-ID: <4F81C974.6030809@gmx.de> Date: Sun, 08 Apr 2012 19:23:00 +0200 From: Udo Richter User-Agent: Mozilla/5.0 (X11; Linux i686; rv:12.0) Gecko/20120404 Thunderbird/12.0 MIME-Version: 1.0 To: VDR Mailing List References: <4F802386.2080706@gmx.de> <4F8142C8.4040005@gmx.de> In-Reply-To: <4F8142C8.4040005@gmx.de> X-Y-GMX-Trusted: 0 X-PMX-Version: 5.6.1.2065439, Antispam-Engine: 2.7.2.376379, Antispam-Data: 2012.4.8.171231 X-PMX-Spam: Gauge=IIIIIIII, Probability=8%, Report=' HTML_00_01 0.05, HTML_00_10 0.05, MIME_TEXT_ONLY_MP_MIXED 0.05, MSGID_ADDED_BY_MTA 0.05, BODYTEXTP_SIZE_3000_LESS 0, BODY_SIZE_10000_PLUS 0, __ANY_URI 0, __BAT_BOUNDARY 0, __BOUNCE_CHALLENGE_SUBJ 0, __BOUNCE_NDR_SUBJ_EXEMPT 0, __CP_MEDIA_BODY 0, __CT 0, __CTYPE_HAS_BOUNDARY 0, __CTYPE_MULTIPART 0, __CTYPE_MULTIPART_MIXED 0, __HAS_MSGID 0, __MIME_TEXT_ONLY 0, __MIME_VERSION 0, __MOZILLA_MSGID 0, __SANE_MSGID 0, __TO_MALFORMED_2 0, __URI_NO_MAILTO 0, __URI_NO_PATH 0, __URI_NO_WWW 0, __USER_AGENT 0' X-LSpam-Score: -1.1 (-) X-LSpam-Report: No, score=-1.1 required=5.0 tests=BAYES_00=-1.9, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793 autolearn=no Subject: Re: [vdr] Filesystem hierachy standard patch needs review. X-BeenThere: vdr@linuxtv.org X-Mailman-Version: 2.1.13 Precedence: list Reply-To: VDR Mailing List List-Id: VDR Mailing List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 08 Apr 2012 17:23:28 -0000 Status: O X-Status: X-Keywords: X-UID: 26049 Am 08.04.2012 09:48, schrieb Manuel Reimer: > It is difficult to read your description (and no, I didn't understand > it). How would you want to document this in a way, someone actually > understands it? I guess I have to find a way to be more clear... Ok, second attempt: - Makefile does not set CACHEDIR and RESDIR - Make.config *can* set CACHEDIR and RESDIR, or not. - If --cachedir or --resdir is set by command line, use them. - If not, default to CACHEDIR and RESDIR. - If CACHEDIR or RESDIR is not set (empty string), fall back to whatever --video and --config is set to. Patched patch attached. ;) Needs documentation updated though. Cheers, Udo diff -ruN vdr-1.7.27/INSTALL vdr-1.7.27.patched//INSTALL --- vdr-1.7.27/INSTALL 2012-02-27 12:03:14.000000000 +0100 +++ vdr-1.7.27.patched//INSTALL 2012-04-06 09:43:38.590832504 +0200 @@ -375,6 +375,18 @@ VDR archive into your video directory (or into your config directory, respectively, in case you have redirected it with the -c option). +If you prefer to have your system set up according to the FHS +("File system Hierarchy Standard") and thus have all your files spread +around the entire file system, you can do this by adding a Make.config +file with the following settings + +CACHEDIR = /var/cache/vdr +CONFDIR = /var/lib/vdr +LOCDIR = $(PREFIX)/share/locale +PLUGINLIBDIR = $(PREFIX)/lib/vdr +RESDIR = $(PREFIX)/share/vdr +VIDEODIR = /srv/vdr/video0 + Setting up DiSEqC: ------------------ diff -ruN vdr-1.7.27/Make.config.template vdr-1.7.27.patched//Make.config.template --- vdr-1.7.27/Make.config.template 2012-03-20 12:20:13.000000000 +0100 +++ vdr-1.7.27.patched//Make.config.template 2012-04-06 09:43:38.591832504 +0200 @@ -33,6 +33,8 @@ PLUGINLIBDIR = $(PLUGINDIR)/lib VIDEODIR = /video CONFDIR = $(VIDEODIR) +#CACHEDIR = $(VIDEODIR) +#RESDIR = $(CONFDIR) ### The remote control: diff -ruN vdr-1.7.27/Makefile vdr-1.7.27.patched//Makefile --- vdr-1.7.27/Makefile 2012-03-11 16:33:57.000000000 +0100 +++ vdr-1.7.27.patched//Makefile 2012-04-06 10:06:28.004832504 +0200 @@ -29,6 +29,8 @@ VIDEODIR = /video CONFDIR = $(VIDEODIR) +#CACHEDIR = $(VIDEODIR) +#RESDIR = $(CONFDIR) DOXYGEN ?= /usr/bin/doxygen DOXYFILE = Doxyfile @@ -71,6 +73,8 @@ DEFINES += -DVIDEODIR=\"$(VIDEODIR)\" DEFINES += -DCONFDIR=\"$(CONFDIR)\" DEFINES += -DPLUGINDIR=\"$(PLUGINLIBDIR)\" +DEFINES += -DCACHEDIR=\"$(CACHEDIR)\" +DEFINES += -DRESDIR=\"$(RESDIR)\" DEFINES += -DLOCDIR=\"$(LOCDIR)\" # The version numbers of VDR and the plugin API (taken from VDR's "config.h"): @@ -112,6 +116,8 @@ @echo "configdir=$(CONFDIR)" >> $@ @echo "videodir=$(VIDEODIR)" >> $@ @echo "plugindir=$(PLUGINLIBDIR)" >> $@ + @echo "cachedir=$(CACHEDIR)" >> $@ + @echo "resdir=$(RESDIR)" >> $@ @echo "localedir=$(LOCDIR)" >> $@ @echo "apiversion=$(APIVERSION)" >> $@ @echo "cflags=$(CXXFLAGS) $(DEFINES) -I\$${includedir}" >> $@ @@ -183,7 +189,7 @@ # Install the files: -install: install-bin install-conf install-doc install-plugins install-i18n install-includes install-pc +install: install-bin install-dirs install-conf install-doc install-plugins install-i18n install-includes install-pc # VDR binary: @@ -193,12 +199,15 @@ # Configuration files: -install-conf: +install-dirs: @mkdir -p $(DESTDIR)$(VIDEODIR) - @if [ ! -d $(DESTDIR)$(CONFDIR) ]; then\ - mkdir -p $(DESTDIR)$(CONFDIR);\ - cp *.conf $(DESTDIR)$(CONFDIR);\ - fi + @mkdir -p $(DESTDIR)$(CONFDIR) + @mkdir -p $(DESTDIR)$(RESDIR) + @mkdir -p $(DESTDIR)$(CACHEDIR) + +install-conf: + @cp *.conf $(DESTDIR)$(CONFDIR) + # Documentation: diff -ruN vdr-1.7.27/PLUGINS.html vdr-1.7.27.patched//PLUGINS.html --- vdr-1.7.27/PLUGINS.html 2012-03-09 10:49:29.000000000 +0100 +++ vdr-1.7.27.patched//PLUGINS.html 2012-04-06 09:43:38.594832504 +0200 @@ -82,7 +82,7 @@
  • Wakeup
  • Setup parameters
  • The Setup menu -
  • Configuration files +
  • Additional files
  • Internationalization
  • Custom services
  • SVDRP commands @@ -885,39 +885,55 @@ your setup parameters and use that one to copy all parameters with one single statement (like VDR does with its cSetup class). -

    Configuration files

    +

    Additional files

    I want my own stuff!

    -There may be situations where a plugin requires configuration files of its own, maybe -for data that can't be stored in the simple setup parameters -of VDR, or maybe because it needs to launch other programs that simply need a separate -configuration file. While the plugin is free to store such files anywhere it -sees fit, it might be a good idea to put them in a common place, preferably -where other configuration data already exists. VDR provides the function +There may be situations where a plugin requires own files. While the plugin is +free to store such files anywhere it sees fit, it might be a good idea to put them in a common +place, preferably where such data already exists. +

    +configuration files, maybe for data that can't be stored in the simple +setup parameters of VDR, or maybe because it needs to +launch other programs that simply need a separate configuration file. +

    +cache files, to store data so that future requests for that data can be served faster. The data +that is stored within a cache might be values that have been computed earlier or duplicates of +original values that are stored elsewhere. +

    +resource files, for providing additional files, like pictures, movie clips or channel logos. +

    +Threfore VDR provides three functions

     const char *ConfigDirectory(const char *PluginName = NULL);
     

    +

    +const char *CacheDirectory(const char *PluginName = NULL);
    +

    +

    +const char *ResourceDirectory(const char *PluginName = NULL);
    +

    -which returns a string containing the directory that VDR uses for its own configuration -files (defined through the -c option in the call to VDR), extended by +each of these return a string containing the directory that VDR uses for its own +files (defined through the options in the call to VDR), extended by "/plugins". So assuming the VDR configuration directory is /video (the default if no -c or -v option is given), a call to ConfigDirectory() will return /video/plugins. The first call to ConfigDirectory() will automatically make sure that the plugins subdirectory will exist. If, for some reason, this cannot be achieved, NULL -will be returned. +will be returned. The behavoir of CacheDirectory() and ResourceDirectory() +is similar

    The additional plugins directory is used to keep files from plugins apart from those of VDR itself, making sure there will be no name clashes. If a plugin -needs only one extra configuration file, it is suggested that this file be named -name.conf, where name shall be the name of the plugin. +needs only one extra file, it is suggested that this file be named name.*, +where name shall be the name of the plugin.

    If a plugin needs more than one such file, it is suggested that the plugin stores these in a subdirectory of its own, named after the plugin. To easily get such a name -the ConfigDirectory() function can be given an additional string that will -be appended to the returned directory name, as in +the functions can be given an additional string that will be appended to the returned +directory name, as in

     const char *MyConfigDir = ConfigDirectory(Name());
    @@ -928,13 +944,13 @@
     (or return NULL in case of an error).
     

    -The returned string is statically allocated and will be overwritten by subsequent -calls to ConfigDirectory()! +The returned strings are statically allocated and will be overwritten by subsequent +calls!

    -The ConfigDirectory() function is a static member function of the cPlugin -class. This allows it to be called even from outside any member function of the derived -plugin class, by writing +The ConfigDirectory(), CacheDirectory() and ResourceDirectory() +functions are static member functions of the cPlugin class. This allows them to be +called even from outside any member function of the derived plugin class, by writing

     const char *MyConfigDir = cPlugin::ConfigDirectory();
    diff -ruN vdr-1.7.27/plugin.c vdr-1.7.27.patched//plugin.c
    --- vdr-1.7.27/plugin.c	2012-03-11 14:56:02.000000000 +0100
    +++ vdr-1.7.27.patched//plugin.c	2012-04-06 09:43:38.595832504 +0200
    @@ -26,6 +26,8 @@
     // --- cPlugin ---------------------------------------------------------------
     
     char *cPlugin::configDirectory = NULL;
    +char *cPlugin::cacheDirectory = NULL;
    +char *cPlugin::resourceDirectory = NULL;
     
     cPlugin::cPlugin(void)
     {
    @@ -145,6 +147,36 @@
       return MakeDirs(buffer, true) ? *buffer : NULL;
     }
     
    +void cPlugin::SetCacheDirectory(const char *Dir)
    +{
    +  free(cacheDirectory);
    +  cacheDirectory = strdup(Dir);
    +}
    +
    +const char *cPlugin::CacheDirectory(const char *PluginName)
    +{
    +  static cString buffer;
    +  if (!cThread::IsMainThread())
    +     esyslog("ERROR: plugin '%s' called cPlugin::CacheDirectory(), which is not thread safe!", PluginName ? PluginName : "");
    +  buffer = cString::sprintf("%s/plugins%s%s", cacheDirectory, PluginName ? "/" : "", PluginName ? PluginName : "");
    +  return MakeDirs(buffer, true) ? *buffer : NULL;
    +}
    +
    +void cPlugin::SetResourceDirectory(const char *Dir)
    +{
    +  free(resourceDirectory);
    +  resourceDirectory = strdup(Dir);
    +}
    +
    +const char *cPlugin::ResourceDirectory(const char *PluginName)
    +{
    +  static cString buffer;
    +  if (!cThread::IsMainThread())
    +     esyslog("ERROR: plugin '%s' called cPlugin::ResourceDirectory(), which is not thread safe!", PluginName ? PluginName : "");
    +  buffer = cString::sprintf("%s/plugins%s%s", resourceDirectory, PluginName ? "/" : "", PluginName ? PluginName : "");
    +  return MakeDirs(buffer, true) ? *buffer : NULL;
    +}
    +
     // --- cDll ------------------------------------------------------------------
     
     cDll::cDll(const char *FileName, const char *Args)
    diff -ruN vdr-1.7.27/plugin.h vdr-1.7.27.patched//plugin.h
    --- vdr-1.7.27/plugin.h	2012-03-11 14:55:56.000000000 +0100
    +++ vdr-1.7.27.patched//plugin.h	2012-04-06 09:43:38.596832504 +0200
    @@ -22,6 +22,8 @@
       friend class cPluginManager;
     private:
       static char *configDirectory;
    +  static char *cacheDirectory;
    +  static char *resourceDirectory;
       const char *name;
       bool started;
       void SetName(const char *s);
    @@ -57,6 +59,12 @@
     
       static void SetConfigDirectory(const char *Dir);
       static const char *ConfigDirectory(const char *PluginName = NULL);
    +
    +  static void SetCacheDirectory(const char *Dir);
    +  static const char *CacheDirectory(const char *PluginName = NULL);
    +
    +  static void SetResourceDirectory(const char *Dir);
    +  static const char *ResourceDirectory(const char *PluginName = NULL);
       };
     
     class cDll : public cListObject {
    diff -ruN vdr-1.7.27/vdr.1 vdr-1.7.27.patched//vdr.1
    --- vdr-1.7.27/vdr.1	2012-02-27 12:01:17.000000000 +0100
    +++ vdr-1.7.27.patched//vdr.1	2012-04-06 09:43:38.596832504 +0200
    @@ -42,6 +42,9 @@
     .BI \-a\  cmd ,\ \-\-audio= cmd
     Send Dolby Digital audio to stdin of command \fIcmd\fR.
     .TP
    +.BI \-\-cachedir= dir
    +save cache files in \fIdir\fR.
    +.TP
     .BI \-c\  dir ,\ \-\-config= dir
     Read config files from directory \fIdir\fR
     (default is to read them from the video directory).
    @@ -157,6 +160,9 @@
     Call \fIcmd\fR before and after a recording. See the file \fIINSTALL\fR for
     more information.
     .TP
    +.BI \-\-resdir= dir
    +read resource files from \fIdir\fR.
    +.TP
     .BI \-s\  cmd ,\ \-\-shutdown= cmd
     Call \fIcmd\fR to shutdown the computer. See the file \fIINSTALL\fR for more
     information.
    diff -ruN vdr-1.7.27/vdr.c vdr-1.7.27.patched//vdr.c
    --- vdr-1.7.27/vdr.c	2012-03-14 10:09:19.000000000 +0100
    +++ vdr-1.7.27.patched//vdr.c	2012-04-06 09:45:15.546832504 +0200
    @@ -181,15 +181,19 @@
     #define DEFAULTWATCHDOG     0 // seconds
     #define DEFAULTCONFDIR CONFDIR
     #define DEFAULTPLUGINDIR PLUGINDIR
    +#define DEFAULTCACHEDIR CACHEDIR
     #define DEFAULTEPGDATAFILENAME "epg.data"
    +#define DEFAULTRESDIR RESDIR
     
       bool StartedAsRoot = false;
       const char *VdrUser = NULL;
       bool UserDump = false;
       int SVDRPport = DEFAULTSVDRPPORT;
       const char *AudioCommand = NULL;
    +  const char *CacheDirectory = NULL;
       const char *ConfigDirectory = NULL;
       const char *EpgDataFileName = DEFAULTEPGDATAFILENAME;
    +  const char *ResourceDirectory = NULL;
       bool DisplayHelp = false;
       bool DisplayVersion = false;
       bool DaemonMode = false;
    @@ -215,6 +219,7 @@
     
       static struct option long_options[] = {
           { "audio",    required_argument, NULL, 'a' },
    +      { "cachedir", required_argument, NULL, 'c' | 0x100 },
           { "config",   required_argument, NULL, 'c' },
           { "daemon",   no_argument,       NULL, 'd' },
           { "device",   required_argument, NULL, 'D' },
    @@ -234,6 +239,7 @@
           { "plugin",   required_argument, NULL, 'P' },
           { "port",     required_argument, NULL, 'p' },
           { "record",   required_argument, NULL, 'r' },
    +      { "resdir",   required_argument, NULL, 'r' | 0x200 },
           { "shutdown", required_argument, NULL, 's' },
           { "split",    no_argument,       NULL, 's' | 0x100 },
           { "terminal", required_argument, NULL, 't' },
    @@ -251,6 +257,9 @@
             switch (c) {
               case 'a': AudioCommand = optarg;
                         break;
    +          case 'c' | 0x100:
    +                    CacheDirectory = optarg;
    +                    break;
               case 'c': ConfigDirectory = optarg;
                         break;
               case 'd': DaemonMode = true; break;
    @@ -348,6 +357,9 @@
                         break;
               case 'r': cRecordingUserCommand::SetCommand(optarg);
                         break;
    +          case 'r' | 0x200:
    +                    ResourceDirectory = optarg;
    +                    break;
               case 's': ShutdownHandler.SetShutdownCommand(optarg);
                         break;
               case 's' | 0x100:
    @@ -413,6 +425,7 @@
          if (DisplayHelp) {
             printf("Usage: vdr [OPTIONS]\n\n"          // for easier orientation, this is column 80|
                    "  -a CMD,   --audio=CMD    send Dolby Digital audio to stdin of command CMD\n"
    +               "            --cachedir=DIR save cache files in DIR (default: %s)\n"
                    "  -c DIR,   --config=DIR   read config files from DIR (default: %s)\n"
                    "  -d,       --daemon       run in daemon mode\n"
                    "  -D NUM,   --device=NUM   use only the given DVB device (NUM = 0, 1, 2...)\n"
    @@ -449,6 +462,7 @@
                    "                           0 turns off SVDRP\n"
                    "  -P OPT,   --plugin=OPT   load a plugin defined by the given options\n"
                    "  -r CMD,   --record=CMD   call CMD before and after a recording\n"
    +               "            --resdir=DIR   read resource files from DIR (default: %s)\n"
                    "  -s CMD,   --shutdown=CMD call CMD to shutdown the computer\n"
                    "            --split        split edited files at the editing marks (only\n"
                    "                           useful in conjunction with --edit)\n"
    @@ -463,6 +477,7 @@
                    "  -w SEC,   --watchdog=SEC activate the watchdog timer with a timeout of SEC\n"
                    "                           seconds (default: %d); '0' disables the watchdog\n"
                    "\n",
    +               strcmp(DEFAULTCACHEDIR, "") ? DEFAULTCACHEDIR : VideoDirectory,
                    DEFAULTCONFDIR,
                    DEFAULTEPGDATAFILENAME,
                    MAXVIDEOFILESIZEDEFAULT,
    @@ -470,6 +485,7 @@
                    LIRC_DEVICE,
                    LOCDIR,
                    DEFAULTSVDRPPORT,
    +               strcmp(DEFAULTRESDIR, "") ? DEFAULTRESDIR : DEFAULTCONFDIR,
                    VideoDirectory,
                    DEFAULTWATCHDOG
                    );
    @@ -577,14 +593,39 @@
       if (!PluginManager.LoadPlugins(true))
          EXIT(2);
     
    -  // Configuration data:
    +  // Configuration directory:
     
       if (!ConfigDirectory)
          ConfigDirectory = DEFAULTCONFDIR;
     
       cPlugin::SetConfigDirectory(ConfigDirectory);
    +
    +  // Cache directory:
    +
    +  if (!CacheDirectory) {
    +     CacheDirectory = DEFAULTCACHEDIR;
    +     if (!CacheDirectory[0])
    +        CacheDirectory = VideoDirectory;
    +     }
    +
    +  cPlugin::SetCacheDirectory(CacheDirectory);
    +
    +  // Resource directory:
    +
    +  if (!ResourceDirectory) {
    +     ResourceDirectory = DEFAULTRESDIR;
    +     if (!ResourceDirectory[0])
    +        ResourceDirectory = ConfigDirectory;
    +     }
    +
    +  cPlugin::SetResourceDirectory(ResourceDirectory);
    +
    +  // Themes directory:
    +
       cThemes::SetThemesDirectory(AddDirectory(ConfigDirectory, "themes"));
     
    +  // Configuration data:
    +
       Setup.Load(AddDirectory(ConfigDirectory, "setup.conf"));
       Sources.Load(AddDirectory(ConfigDirectory, "sources.conf"), true, true);
       Diseqcs.Load(AddDirectory(ConfigDirectory, "diseqc.conf"), true, Setup.DiSEqC);
    @@ -618,7 +653,7 @@
             EpgDataFileName = DEFAULTEPGDATAFILENAME;
             }
          else if (*EpgDataFileName != '/' && *EpgDataFileName != '.')
    -        EpgDirectory = VideoDirectory;
    +        EpgDirectory = CacheDirectory;
          if (EpgDirectory)
             cSchedules::SetEpgDataFileName(AddDirectory(EpgDirectory, EpgDataFileName));
          else