1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2024-10-28 03:25:27 +03:00

path-util: also support ".old" and ".new" suffixes and recommend them

~ 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.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2016-04-29 10:17:43 -04:00
parent 2397bc4312
commit 94a0ef6e57
2 changed files with 8 additions and 5 deletions

View 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) {

View File

@ -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)