Author: jim
Date: Wed Jan 16 13:50:09 2019
New Revision: 1851443

URL: http://svn.apache.org/viewvc?rev=1851443&view=rev
Log:
Use fakeroot instead of our custom getuid.c LD_PRELOAD hack if available when 
creating Debian packages. This is because epm and dpkg (et.al.) need to be 
fooled into thinking that root is creating these packages for the correct 
permissions.

Modified:
    openoffice/trunk/main/configure.ac
    openoffice/trunk/main/set_soenv.in
    openoffice/trunk/main/setup_native/scripts/source/getuid.c
    openoffice/trunk/main/solenv/bin/modules/installer/download.pm
    openoffice/trunk/main/solenv/bin/modules/installer/epmfile.pm
    openoffice/trunk/main/solenv/bin/modules/installer/worker.pm
    openoffice/trunk/main/sysui/desktop/debian/makefile.mk

Modified: openoffice/trunk/main/configure.ac
URL: 
http://svn.apache.org/viewvc/openoffice/trunk/main/configure.ac?rev=1851443&r1=1851442&r2=1851443&view=diff
==============================================================================
--- openoffice/trunk/main/configure.ac (original)
+++ openoffice/trunk/main/configure.ac Wed Jan 16 13:50:09 2019
@@ -3559,6 +3559,10 @@ msi - Windows .msi
       if test "$DPKG" = "no"; then
          AC_MSG_ERROR([dpkg needed for deb creation. Install dpkg.])
       fi
+      AC_PATH_PROG(FAKEROOT, fakeroot, no)
+      if test "$FAKEROOT" = "no"; then
+         AC_MSG_WARN([fakeroot recommended for deb creation. Will try with 
getuid.so hack.])
+      fi
    fi
    if echo "$PKGFORMAT" | $EGREP osx 2>&1 >/dev/null; then
       if test "$_os" = "Darwin"; then
@@ -3608,6 +3612,7 @@ msi - Windows .msi
    fi
    AC_SUBST(RPM)
    AC_SUBST(DPKG)
+   AC_SUBST(FAKEROOT)
    AC_SUBST(PKGMK)
 else
    AC_MSG_RESULT([no])

Modified: openoffice/trunk/main/set_soenv.in
URL: 
http://svn.apache.org/viewvc/openoffice/trunk/main/set_soenv.in?rev=1851443&r1=1851442&r2=1851443&view=diff
==============================================================================
--- openoffice/trunk/main/set_soenv.in (original)
+++ openoffice/trunk/main/set_soenv.in Wed Jan 16 13:50:09 2019
@@ -1806,6 +1806,7 @@ ToFile( "ENABLE_HYPHEN",  "@ENABLE_HYPHEN
 ToFile( "PERL",              $PERL,              "e" );
 ToFile( "RPM",               "@RPM@",            "e" );
 ToFile( "DPKG",              "@DPKG@",           "e" );
+ToFile( "FAKEROOT",          "@FAKEROOT@",       "e" );
 ToFile( "PKGMK",             "@PKGMK@",          "e" );
 ToFile( "GNUMAKE",           "@GNUMAKE@",        "e" );
 ToFile( "GNUTAR",            "@GNUTAR@",         "e" );

Modified: openoffice/trunk/main/setup_native/scripts/source/getuid.c
URL: 
http://svn.apache.org/viewvc/openoffice/trunk/main/setup_native/scripts/source/getuid.c?rev=1851443&r1=1851442&r2=1851443&view=diff
==============================================================================
--- openoffice/trunk/main/setup_native/scripts/source/getuid.c (original)
+++ openoffice/trunk/main/setup_native/scripts/source/getuid.c Wed Jan 16 
13:50:09 2019
@@ -111,10 +111,11 @@ int fstatat64(int fildes, const char *pa
 }
 #elif  defined LINUX
 
-uid_t getuid  (void) {return 0;}
-uid_t geteuid (void) {return 0;}
+uid_t getuid  (void)    {return 0;}
+uid_t geteuid (void)    {return 0;}
+int setgid    (gid_t p) {return 0;}
 
-/* This is to fool tar */
+/* This is to fool epm, tar, dpkg, et.al. into thinking we are root */
 #ifdef X86_64
 int __lxstat(int n, const char *path, struct stat *buf)
 {

Modified: openoffice/trunk/main/solenv/bin/modules/installer/download.pm
URL: 
http://svn.apache.org/viewvc/openoffice/trunk/main/solenv/bin/modules/installer/download.pm?rev=1851443&r1=1851442&r2=1851443&view=diff
==============================================================================
--- openoffice/trunk/main/solenv/bin/modules/installer/download.pm (original)
+++ openoffice/trunk/main/solenv/bin/modules/installer/download.pm Wed Jan 16 
13:50:09 2019
@@ -303,7 +303,12 @@ sub tar_package
        my ( $installdir, $tarfilename, $getuidlibrary) = @_;
 
        my $ldpreloadstring = "";
-       if ( $getuidlibrary ne "" ) { $ldpreloadstring = "LD_PRELOAD=" . 
$getuidlibrary; }
+
+       if ($ENV{'FAKEROOT'} ne "no") {
+               $ldpreloadstring = "fakeroot"
+       } else {
+               if ( $getuidlibrary ne "" ) { $ldpreloadstring = "LD_PRELOAD=" 
. $getuidlibrary; }
+       }
 
        my $systemcall = "cd $installdir; $ldpreloadstring tar -cf - * > 
$tarfilename";
        
@@ -367,8 +372,14 @@ sub create_tar_gz_file_from_package
        $installer::globals::downloadfileextension = ".tar.gz";
        my $targzname = $packagename . 
$installer::globals::downloadfileextension;
        $installer::globals::downloadfilename = $targzname;
+
        my $ldpreloadstring = "";
-       if ( $getuidlibrary ne "" ) { $ldpreloadstring = "LD_PRELOAD=" . 
$getuidlibrary; }
+
+       if ($ENV{'FAKEROOT'} ne "no") {
+               $ldpreloadstring = "fakeroot"
+       } else {
+               if ( $getuidlibrary ne "" ) { $ldpreloadstring = "LD_PRELOAD=" 
. $getuidlibrary; }
+       }
 
        my $systemcall = "cd $installdir; $ldpreloadstring tar -cf - 
$packagename | gzip > $targzname";
     $installer::logger::Info->printf("... %s ...\n", $systemcall);
@@ -788,7 +799,12 @@ sub create_tar_gz_file_from_directory
        installer::pathanalyzer::get_path_from_fullqualifiedname(\$changedir);
 
        my $ldpreloadstring = "";
-       if ( $getuidlibrary ne "" ) { $ldpreloadstring = "LD_PRELOAD=" . 
$getuidlibrary; }
+
+       if ($ENV{'FAKEROOT'} ne "no") {
+               $ldpreloadstring = "fakeroot"
+       } else {
+               if ( $getuidlibrary ne "" ) { $ldpreloadstring = "LD_PRELOAD=" 
. $getuidlibrary; }
+       }
 
        $installer::globals::downloadfileextension = ".tar.gz";
        $installer::globals::downloadfilename = $downloadfilename . 
$installer::globals::downloadfileextension;

Modified: openoffice/trunk/main/solenv/bin/modules/installer/epmfile.pm
URL: 
http://svn.apache.org/viewvc/openoffice/trunk/main/solenv/bin/modules/installer/epmfile.pm?rev=1851443&r1=1851442&r2=1851443&view=diff
==============================================================================
--- openoffice/trunk/main/solenv/bin/modules/installer/epmfile.pm (original)
+++ openoffice/trunk/main/solenv/bin/modules/installer/epmfile.pm Wed Jan 16 
13:50:09 2019
@@ -887,10 +887,20 @@ sub get_ld_preload_string
 
        my $getuidlibraryname = "getuid.so";
 
+       my $ldpreloadstring;
+
        my $getuidlibraryref = 
installer::scriptitems::get_sourcepath_from_filename_and_includepath(\$getuidlibraryname,
 $includepatharrayref, 0);
-       if ($$getuidlibraryref eq "") { installer::exiter::exit_program("ERROR: 
Could not find $getuidlibraryname!", "get_ld_preload_string"); }
 
-       my $ldpreloadstring = "LD_PRELOAD=" . $$getuidlibraryref;
+       if ($ENV{'FAKEROOT'} ne "no") {
+
+               $ldpreloadstring = "fakeroot"
+
+       } else {
+
+               if ($$getuidlibraryref eq "") { 
installer::exiter::exit_program("ERROR: Could not find $getuidlibraryname!", 
"get_ld_preload_string"); }
+
+               my $ldpreloadstring = "LD_PRELOAD=" . $$getuidlibraryref;
+       }
        
        return $ldpreloadstring;
 }
@@ -914,7 +924,7 @@ sub call_epm
        my $outdirstring = "";
        if ( $installer::globals::epmoutpath ne "" ) { $outdirstring = " 
--output-dir $installer::globals::epmoutpath"; }
        
-       # Debian package build needs a LD_PRELOAD for correct rights
+       # Debian package build needs fakeroot or our LD_PRELOAD hack for 
correct rights
        
        my $ldpreloadstring = "";
        

Modified: openoffice/trunk/main/solenv/bin/modules/installer/worker.pm
URL: 
http://svn.apache.org/viewvc/openoffice/trunk/main/solenv/bin/modules/installer/worker.pm?rev=1851443&r1=1851442&r2=1851443&view=diff
==============================================================================
--- openoffice/trunk/main/solenv/bin/modules/installer/worker.pm (original)
+++ openoffice/trunk/main/solenv/bin/modules/installer/worker.pm Wed Jan 16 
13:50:09 2019
@@ -3199,7 +3199,12 @@ sub tar_package
        my ( $installdir, $packagename, $tarfilename, $getuidlibrary) = @_;
 
        my $ldpreloadstring = "";
-       if ( $getuidlibrary ne "" ) { $ldpreloadstring = "LD_PRELOAD=" . 
$getuidlibrary; }
+
+       if ($ENV{'FAKEROOT'} ne "no") {
+               $ldpreloadstring = "fakeroot"
+       } else {
+               if ( $getuidlibrary ne "" ) { $ldpreloadstring = "LD_PRELOAD=" 
. $getuidlibrary; }
+       }
 
        my $systemcall = "cd $installdir; $ldpreloadstring tar -cf - 
$packagename > $tarfilename";
        # my $systemcall = "cd $installdir; $ldpreloadstring tar -cf - * > 
$tarfilename";
@@ -3238,7 +3243,12 @@ sub untar_package
        my ( $installdir, $tarfilename, $getuidlibrary) = @_;
 
        my $ldpreloadstring = "";
-       if ( $getuidlibrary ne "" ) { $ldpreloadstring = "LD_PRELOAD=" . 
$getuidlibrary; }
+
+       if ($ENV{'FAKEROOT'} ne "no") {
+               $ldpreloadstring = "fakeroot"
+       } else {
+               if ( $getuidlibrary ne "" ) { $ldpreloadstring = "LD_PRELOAD=" 
. $getuidlibrary; }
+       }
 
        my $systemcall = "cd $installdir; $ldpreloadstring tar -xf 
$tarfilename";
        

Modified: openoffice/trunk/main/sysui/desktop/debian/makefile.mk
URL: 
http://svn.apache.org/viewvc/openoffice/trunk/main/sysui/desktop/debian/makefile.mk?rev=1851443&r1=1851442&r2=1851443&view=diff
==============================================================================
--- openoffice/trunk/main/sysui/desktop/debian/makefile.mk (original)
+++ openoffice/trunk/main/sysui/desktop/debian/makefile.mk Wed Jan 16 13:50:09 
2019
@@ -45,6 +45,12 @@ DEBFILES=$(foreach,i,{$(PRODUCTLIST)} $(
 
 .ENDIF
 
+.IF "$(FAKEROOT)"!="no"
+FAKEROOT2="fakeroot"
+.ELSE
+FAKEROOT2="LD_PRELOAD=$(SOLARBINDIR)/getuid.so"
+.ENDIF
+
 # --- Targets -------------------------------------------------------
 
 .INCLUDE :  target.mk
@@ -85,7 +91,7 @@ $(DEBFILES) : makefile.mk control postin
        @chmod a+rx $(MISC)$/$(@:b)$/DEBIAN $(MISC)/$(@:b)/DEBIAN/post* 
$(MISC)/$(@:b)/DEBIAN/pre*
        @chmod g-s $(MISC)/$(@:b)/DEBIAN
        @mkdir -p $(PKGDIR)
-       /bin/bash -c "LD_PRELOAD=$(SOLARBINDIR)/getuid.so dpkg-deb --build 
$(MISC)/$(@:b) $@" 
+       /bin/bash -c "$(FAKEROOT2) dpkg-deb --build $(MISC)/$(@:b) $@" 
        $(RM) -r $(MISC)$/$(@:b)
 #      @chmod -R g+w $(MISC)/$(TARGET)/$(DEBFILE:f)
 


Reply via email to