[PATCH] allow to put files listed in file into installation

David Tardon (via Code Review) gerrit at gerrit.libreoffice.org
Mon Apr 1 05:13:14 PDT 2013


Hi,

I have submitted a patch for review:

    https://gerrit.libreoffice.org/3149

To pull it, you can do:

    git pull ssh://gerrit.libreoffice.org:29418/core refs/changes/49/3149/1

allow to put files listed in file into installation

With this in place, we can replace most of our Zips by Packages.
Extensions and Dictionaries are on the radar as well.

To move an installed file from zip to filelist, do:
1. Convert the Zip_foo.mk to Package_foo.mk . The files must be placed
   under $OUTDIR/files with the exact path they will have in the
   installation (you can find that in scp2).
2. Change the scp2 record:
   - change filename to <package-name>.filelist
   - replace ARCHIVE by FILELIST in Styles
   - change Dir to FILELIST_DIR.

Change-Id: Ie17d0765406081b03dcd44a6a23cf517f2067dd3
---
M instsetoo_native/util/openoffice.lst.in
M scp2/inc/macros.inc
M solenv/bin/modules/installer.pm
A solenv/bin/modules/installer/filelists.pm
M solenv/bin/modules/installer/globals.pm
M solenv/gbuild/Package.mk
M solenv/gbuild/TargetLocations.mk
7 files changed, 125 insertions(+), 6 deletions(-)



diff --git a/instsetoo_native/util/openoffice.lst.in b/instsetoo_native/util/openoffice.lst.in
index c6afdbd..994e640 100644
--- a/instsetoo_native/util/openoffice.lst.in
+++ b/instsetoo_native/util/openoffice.lst.in
@@ -83,7 +83,7 @@
         downloadname    LibreOffice_{productversion}_{os}_install_{languages}
         langpackdownloadname    LibreOffice_{productversion}_languagepack_{os}_install_{languages}
         helppackdownloadname    LibreOffice_{productversion}_helppack_{os}_install_{languages}
-        include         {solarenvpath}/{os}/loader2,.,{localpath}/bin,{solarpath}/bin.{minor}/ooowoure,{solarpath}/bin.{minor}/osl,{solarpath}/bin.{minor}/desktop-integration/{pkgtype},{solarpath}/bin.{minor},{solarpath}/lib.{minor},{solarpath}/pck.{minor}/openoffice,{solarpath}/pck.{minor},{solarpath}/xml.{minor}/office/instance,{solarpath}/xml.{minor},../../external/common,{solarenvpath}/{os}/OOo_external
+        include         {solarenvpath}/{os}/loader2,.,{localpath}/bin,{solarpath}/bin.{minor}/ooowoure,{solarpath}/bin.{minor}/osl,{solarpath}/bin.{minor}/desktop-integration/{pkgtype},{solarpath}/bin.{minor},,{solarpath}/filelists.{minor},{solarpath}/lib.{minor},{solarpath}/pck.{minor}/openoffice,{solarpath}/pck.{minor},{solarpath}/xml.{minor}/office/instance,{solarpath}/xml.{minor},../../external/common,{solarenvpath}/{os}/OOo_external
     }
 }
 
@@ -140,7 +140,7 @@
         downloadname    LibreOfficeDev_{productversion}_{os}_install_{languages}
         langpackdownloadname    LibreOfficeDev_{productversion}_languagepack_{os}_install_{languages}
         helppackdownloadname    LibreOfficeDev_{productversion}_helppack_{os}_install_{languages}
-        include         {solarenvpath}/{os}/loader2,.,{localpath}/bin/dev,{localpath}/bin,{solarpath}/bin.{minor}/osl,{solarpath}/bin.{minor}/desktop-integration/{pkgtype},{solarpath}/bin.{minor},{solarpath}/lib.{minor},{solarpath}/pck.{minor}/openoffice_dev,{solarpath}/pck.{minor}/openoffice,{solarpath}/pck.{minor},{solarpath}/xml.{minor}/office/instance,{solarpath}/xml.{minor},../../external/common,{solarenvpath}/{os}/OOo_external
+        include         {solarenvpath}/{os}/loader2,.,{localpath}/bin/dev,{localpath}/bin,{solarpath}/bin.{minor}/osl,{solarpath}/bin.{minor}/desktop-integration/{pkgtype},{solarpath}/bin.{minor},{solarpath}/filelists.{minor},{solarpath}/lib.{minor},{solarpath}/pck.{minor}/openoffice_dev,{solarpath}/pck.{minor}/openoffice,{solarpath}/pck.{minor},{solarpath}/xml.{minor}/office/instance,{solarpath}/xml.{minor},../../external/common,{solarenvpath}/{os}/OOo_external
     }
 }
 
diff --git a/scp2/inc/macros.inc b/scp2/inc/macros.inc
index 1b537aa..dd4432c 100755
--- a/scp2/inc/macros.inc
+++ b/scp2/inc/macros.inc
@@ -425,6 +425,12 @@
 #define SCP2_URE_JDL_NORMAL(n) SCP2_URE_DL_NORMAL(n)
 #endif
 
+#if defined MACOSX
+#define FILELIST_DIR gid_Dir_Bundle_Contents
+#else
+#define FILELIST_DIR gid_Dir_Brand_Root
+#endif
+
 #include <langmacros.inc>
 
 
diff --git a/solenv/bin/modules/installer.pm b/solenv/bin/modules/installer.pm
index c731d9e..4ec318f 100644
--- a/solenv/bin/modules/installer.pm
+++ b/solenv/bin/modules/installer.pm
@@ -41,6 +41,7 @@
 use installer::environment;
 use installer::epmfile;
 use installer::files;
+use installer::filelists;
 use installer::globals;
 use installer::helppack;
 use installer::languagepack;
@@ -617,6 +618,14 @@
             installer::scriptitems::quoting_illegal_filenames($filesinproductlanguageresolvedarrayref);
         }
 
+        ######################################################################################
+        # Processing files with flag FILELIST and putting listed files into the file list
+        ######################################################################################
+
+        installer::logger::print_message( "... analyzing files with flag FILELIST ...\n" );
+
+        $filesinproductlanguageresolvedarrayref = installer::filelists::resolve_filelist_flag($filesinproductlanguageresolvedarrayref, $pathvariableshashref->{'solarpath'});
+
         #####################################
         # Files with flag SUBST_FILENAME
         #####################################
diff --git a/solenv/bin/modules/installer/filelists.pm b/solenv/bin/modules/installer/filelists.pm
new file mode 100644
index 0000000..7359ece
--- /dev/null
+++ b/solenv/bin/modules/installer/filelists.pm
@@ -0,0 +1,96 @@
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+
+package installer::filelists;
+
+use installer::files;
+use installer::globals;
+use installer::logger;
+use installer::pathanalyzer;
+
+sub resolve_filelist_flag
+{
+    my ($files, $outdir) = @_;
+    my $basedir = $outdir . $installer::globals::separator . $installer::globals::filesdir;
+    my @newfiles = ();
+
+    foreach my $file (@{$files})
+    {
+        my $is_filelist = 0;
+        if ($file->{'Styles'})
+        {
+            if ($file->{'Styles'} =~ /\bFILELIST\b/)
+            {
+                $is_filelist = 1;
+            }
+        }
+
+        if ($is_filelist)
+        {
+            my $filelist_path = $file->{'sourcepath'};
+            my $filelist = read_filelist($filelist_path);
+            if (@{$filelist})
+            {
+                my $destination = $file->{'destination'};
+                installer::pathanalyzer::get_path_from_fullqualifiedname(\$destination);
+
+                foreach my $path (@{$filelist})
+                {
+                    # TODO: check that the file is really under $basedir
+                    # TODO: check existence of the file
+                    my $subpath = substr $path, ((length $basedir) + 1); # drop separator too
+
+                    my %newfile = ();
+                    %newfile = %{$file};
+                    $newfile{'Name'} = $subpath;
+                    $newfile{'sourcepath'} = $path;
+                    $newfile{'destination'} = $destination . $subpath;
+                    $newfile{'filelistname'} = $file->{'Name'};
+                    $newfile{'filelistpath'} = $file->{'sourcepath'};
+
+                    push @newfiles, \%newfile;
+                }
+            }
+            else
+            {
+                installer::logger::print_message("filelist $filelist_path is empty\n");
+            }
+        }
+        else # not a filelist, just pass the current file over
+        {
+            push @newfiles, $file;
+        }
+    }
+
+    return \@newfiles;
+}
+
+sub read_filelist
+{
+    my ($path) = @_;
+    my $content = installer::files::read_file($path);
+    my @filelist = ();
+
+    foreach my $line (@{$content})
+    {
+        chomp $line;
+        foreach my $file (split /\s+/, $line)
+        {
+            if ($file ne "")
+            {
+                push @filelist, $file;
+            }
+        }
+    }
+
+    return \@filelist;
+}
+
+1;
+
+# vim: set expandtab shiftwidth=4 tabstop=4:
diff --git a/solenv/bin/modules/installer/globals.pm b/solenv/bin/modules/installer/globals.pm
index 2d7c649..bfa0b1e 100644
--- a/solenv/bin/modules/installer/globals.pm
+++ b/solenv/bin/modules/installer/globals.pm
@@ -300,6 +300,8 @@
         $iswin = 0;
     }
 
+    $filesdir = "files"; # base dir for files specified by FILELISTs
+
 }
 
 1;
diff --git a/solenv/gbuild/Package.mk b/solenv/gbuild/Package.mk
index 6642a89..2d1719b 100644
--- a/solenv/gbuild/Package.mk
+++ b/solenv/gbuild/Package.mk
@@ -65,13 +65,16 @@
 
 $(call gb_Package_get_target,%) :
 	$(call gb_Output_announce,$*,$(true),PKG,2)
-	mkdir -p $(dir $@) && touch $@
+	rm -f $@ && \
+	mv $(call var2file,$@.tmp,100,$(FILES)) $@
 
 # for other targets that want to create Packages, does not register at Module
 define gb_Package_Package_internal
 gb_Package_SOURCEDIR_$(1) := $(2)
+$(call gb_Package_get_target,$(1)) : FILES :=
 $(call gb_Package_get_clean_target,$(1)) : FILES := $(call gb_Package_get_target,$(1)) $(call gb_Package_get_preparation_target,$(1))
 $(call gb_Package_get_target,$(1)) : $(call gb_Package_get_preparation_target,$(1))
+$(call gb_Package_get_target,$(1)) :| $(dir $(call gb_Package_get_target,$(1))).dir
 
 endef
 
@@ -85,6 +88,7 @@
 
 define gb_Package_add_file
 $(call gb_Package_get_target,$(1)) : $(OUTDIR)/$(2)
+$(call gb_Package_get_target,$(1)) : FILES += $(OUTDIR)/$(2)
 $(call gb_Package_get_clean_target,$(1)) : FILES += $(OUTDIR)/$(2)
 $(call gb_PackagePart_PackagePart,$(2),$$(gb_Package_SOURCEDIR_$(1))/$(3),$(call gb_Package_get_preparation_target,$(1)))
 
diff --git a/solenv/gbuild/TargetLocations.mk b/solenv/gbuild/TargetLocations.mk
index b738b65..dd33c55 100644
--- a/solenv/gbuild/TargetLocations.mk
+++ b/solenv/gbuild/TargetLocations.mk
@@ -40,6 +40,8 @@
 gb_Pagein_get_outdir_target = $(OUTDIR)/bin/pagein-$(1)
 gb_PackagePart_get_destinations = \
 	$(OUTDIR)/bin \
+	$(OUTDIR)/files \
+	$(OUTDIR)/filelists \
 	$(OUTDIR)/inc \
 	$(OUTDIR)/lib \
 	$(OUTDIR)/par \
@@ -50,6 +52,8 @@
 	$(OUTDIR)/xml \
 
 gb_InstallScript_get_target = $(OUTDIR)/bin/$(1)$(gb_InstallScript_EXT)
+gb_Package_get_target = $(OUTDIR)/filelists/$(1).filelist
+gb_Package_get_target_for_build = $(OUTDIR_FOR_BUILD)/filelists/$(1).filelist
 gb_PackagePart_get_target = $(OUTDIR)/$(1)
 gb_Rdb_get_outdir_target = $(OUTDIR)/xml/$(1).rdb
 gb_Rdb_get_outdir_target_for_build = $(OUTDIR_FOR_BUILD)/xml/$(1).rdb
@@ -162,8 +166,6 @@
 gb_ObjCObject_get_target = $(WORKDIR)/ObjCObject/$(1).o
 gb_Pagein_get_target = $(WORKDIR)/Pagein/$(1)
 gb_Package_get_preparation_target = $(WORKDIR)/Package/prepared/$(1)
-gb_Package_get_target = $(WORKDIR)/Package/$(1)
-gb_Package_get_target_for_build = $(WORKDIR_FOR_BUILD)/Package/$(1)
 gb_Postprocess_get_target = $(WORKDIR)/Postprocess/$(1)
 gb_PrecompiledHeader_get_dep_target = $(WORKDIR)/Dep/PrecompiledHeader/$(gb_PrecompiledHeader_DEBUGDIR)/$(1).hxx.gch.d
 gb_PrecompiledHeader_get_target = $(WORKDIR)/PrecompiledHeader/$(gb_PrecompiledHeader_DEBUGDIR)/$(1).hxx.gch
@@ -285,7 +287,6 @@
 	Module \
 	NoexPrecompiledHeader \
 	PackagePart \
-	Package \
 	Pagein \
 	PrecompiledHeader \
 	Pyuno \
@@ -331,6 +332,7 @@
 	Extension \
 	InstallScript \
 	Library \
+	Package \
 	StaticLibrary \
 	UnoApi \
 	UnoApiMerge \

-- 
To view, visit https://gerrit.libreoffice.org/3149
To unsubscribe, visit https://gerrit.libreoffice.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie17d0765406081b03dcd44a6a23cf517f2067dd3
Gerrit-PatchSet: 1
Gerrit-Project: core
Gerrit-Branch: master
Gerrit-Owner: David Tardon <dtardon at redhat.com>



More information about the LibreOffice mailing list