From 224641c4b5cd7489167bc06d611f09db2cfe12df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Mon, 17 Feb 2014 23:18:37 +0100 Subject: [PATCH] Install scripts can define a NULL path... ... don't try to call InitPath() then. Also replace more hard-coded paths. Added TODO about refactoring this code and not using hard-coded paths myself, which is no better than these scripts. --- src/apps/packageinstaller/PackageItem.cpp | 26 ++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/apps/packageinstaller/PackageItem.cpp b/src/apps/packageinstaller/PackageItem.cpp index 8456ac8084..f09d30339e 100644 --- a/src/apps/packageinstaller/PackageItem.cpp +++ b/src/apps/packageinstaller/PackageItem.cpp @@ -584,15 +584,39 @@ PackageScript::DoInstall(const char* path, ItemState* state) // but it would be less save. For example, an app // could have a folder named "config/be..." inside // its installation folder. + // TODO: Use find_paths() or we are no better than + // these scripts. script.ReplaceAll( "~/config/be", "~/config/settings/deskbar/menu"); script.ReplaceAll( "/boot/home/config/be", "/boot/home/config/settings/deskbar/menu"); + // Rewrite all sorts of other old BeOS paths + script.ReplaceAll( + "/boot/preferences", + "/boot/system/preferences"); + script.ReplaceAll( + "~/config/add-ons/Screen\\ Savers", + "~/config/non-packaged/add-ons/Screen\\ Savers"); + // TODO: More. These should also be put into a + // common source location, since it can also be used + // for the retargetting of install file locations. + // Packages seem to declare which system paths they + // use, and then package items can reference one of + // those global paths by index. A more elegent solution + // compared to what happens now in InitPath() would be + // to replace those global package paths. Or maybe + // that's more fragile... but a common source for + // the rewriting of BeOS paths is needed. + + printf("%s\n", script.String()); BPath workingDirectory; - ret = InitPath(path, &workingDirectory); + if (path != NULL) + ret = InitPath(path, &workingDirectory); + else + ret = workingDirectory.SetTo("."); if (ret == B_OK) ret = _RunScript(workingDirectory.Path(), script); }