]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
path-util: also support ".old" and ".new" suffixes and recommend them 3151/head
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 29 Apr 2016 14:17:43 +0000 (10:17 -0400)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 29 Apr 2016 14:21:07 +0000 (10:21 -0400)
~ suffix works fine, but looks to much like it the file is supposed to be
automatically cleaned up. For new versions of configuration files installers
might want to using something that looks more permanent like foobar.new.
So let's add treat ".old" and ".new" as special.

Update test to match.

src/basic/path-util.c
test/sysv-generator-test.py

index bcf72913df96617d92d88aca945f8cdaabf3d6d8..b2fa81a294c46cf2e3898a2c47c195fef0902356 100644 (file)
@@ -781,8 +781,8 @@ bool hidden_or_backup_file(const char *filename) {
          *    The generic suffixes "~" and ".bak" for backup files
          *    The generic prefix "." for hidden files
          *
-         * Thus, if a new package manager "foopkg" wants its own set of "foopkg-new", "foopkg-old", "foopkg-dist" or so
-         * registered, let's refuse that and ask them to use "foopkg-new.bak" or "foopkg-new~" instead.
+         * Thus, if a new package manager "foopkg" wants its own set of ".foopkg-new", ".foopkg-old", ".foopkg-dist"
+         * or so registered, let's refuse that and ask them to use ".foopkg.new", ".foopkg.old" or ".foopkg~" instead.
          */
 
         return STR_IN_SET(p + 1,
@@ -800,7 +800,9 @@ bool hidden_or_backup_file(const char *filename) {
                           "ucf-old",
                           "ucf-dist",
                           "swp",
-                          "bak");
+                          "bak",
+                          "old",
+                          "new");
 }
 
 bool is_device_path(const char *path) {
index aadc29ebebeb3d62f5cc1cc1004344daa5466609..838dd57a6f087e3567641d032d741e30ce8c09f3 100755 (executable)
@@ -397,11 +397,12 @@ class SysvGeneratorTest(unittest.TestCase):
         # backup files (not enabled in rcN.d/)
         shutil.copy(script, script + '.bak')
         shutil.copy(script, script + '.old')
+        shutil.copy(script, script + '.tmp')
+        shutil.copy(script, script + '.new')
 
         err, results = self.run_generator()
         print(err)
-        self.assertEqual(sorted(results),
-                         ['foo.bak.service', 'foo.old.service', 'foo.service'])
+        self.assertEqual(sorted(results), ['foo.service', 'foo.tmp.service'])
 
         # ensure we don't try to create a symlink to itself
         self.assertNotIn('itself', err)