From 831369f65385752ee9c3b6490da8f093b2211658 Mon Sep 17 00:00:00 2001 From: James Turner Date: Fri, 27 Apr 2018 15:25:13 +0100 Subject: [PATCH] Packages: add archive-path XML support Allow the in-archive file path to differ from the after-install path. Requested to allow easier operation with GitHub/Labs zip generation. --- simgear/package/CatalogTest.cxx | 2 +- simgear/package/Install.cxx | 9 ++++++++- simgear/package/catalogTest1/catalog.xml | 3 ++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/simgear/package/CatalogTest.cxx b/simgear/package/CatalogTest.cxx index f61763c2..8e752e82 100644 --- a/simgear/package/CatalogTest.cxx +++ b/simgear/package/CatalogTest.cxx @@ -593,7 +593,7 @@ void testInstallArchiveType(HTTP::Client* cl) SGPath p(rootPath); p.append("org.flightgear.test.catalog1"); p.append("Aircraft"); - p.append("movies_6789"); // FIXME once archive-dir support is decided + p.append("movies"); SG_CHECK_EQUAL(p, ins->path()); diff --git a/simgear/package/Install.cxx b/simgear/package/Install.cxx index 96cd11e6..78272005 100644 --- a/simgear/package/Install.cxx +++ b/simgear/package/Install.cxx @@ -169,7 +169,12 @@ protected: // build a path like /path/to/packages/org.some.catalog/Aircraft/extract_xxxx/MyAircraftDir SGPath extractedPath = m_extractPath; - extractedPath.append(m_owner->package()->dirName()); + if (m_owner->package()->properties()->hasChild("archive-path")) { + extractedPath.append(m_owner->package()->properties()->getStringValue("archive-path")); + } else { + extractedPath.append(m_owner->package()->dirName()); + } + // rename it to path/to/packages/org.some.catalog/Aircraft/MyAircraftDir bool ok = extractedPath.rename(m_owner->path()); @@ -179,6 +184,8 @@ protected: } // extract_xxxx directory is now empty, so remove it + // (note it might not be empty if the archive contained some other + // files, but we delete those in such a case if (m_extractPath.exists()) { simgear::Dir(m_extractPath).remove(); } diff --git a/simgear/package/catalogTest1/catalog.xml b/simgear/package/catalogTest1/catalog.xml index 1b8b7b59..2a46604f 100644 --- a/simgear/package/catalogTest1/catalog.xml +++ b/simgear/package/catalogTest1/catalog.xml @@ -183,10 +183,11 @@ movies movies files for test catalog aircraft 10 - movies_6789 + movies http://localhost:2000/catalogTest1/movies?wierd=foo;bar=thing zip + movies_6789 232 e5f89c3f1ed1bdda16174c868f3c7b30