From 1cef6294594a90165ba7f5dadc3374f6b33e032e Mon Sep 17 00:00:00 2001 From: Romain Jobredeaux Date: Thu, 19 May 2022 11:11:51 -0400 Subject: [PATCH] Allow empty zip file in extra files in install command. Test: m Bug: 229901709 Change-Id: I4c8d1b16f2232d4cda75467615779145d2c7315e --- android/makevars.go | 3 ++- android/module.go | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/android/makevars.go b/android/makevars.go index ece7091b6..a74185a5c 100644 --- a/android/makevars.go +++ b/android/makevars.go @@ -472,7 +472,8 @@ func (s *makeVarsSingleton) writeInstalls(installs, symlinks []katiInstall) []by fmt.Fprintf(buf, "\tchmod +x $@\n") } if extraFiles := install.extraFiles; extraFiles != nil { - fmt.Fprintf(buf, "\tunzip -qDD -d '%s' '%s'\n", extraFiles.dir.String(), extraFiles.zip.String()) + fmt.Fprintf(buf, "\t( unzip -qDD -d '%s' '%s' 2>&1 | grep -v \"zipfile is empty\"; exit $${PIPESTATUS[0]} ) || \\\n", extraFiles.dir.String(), extraFiles.zip.String()) + fmt.Fprintf(buf, "\t ( code=$$?; if [ $$code -ne 0 -a $$code -ne 1 ]; then exit $$code; fi )\n") } fmt.Fprintln(buf) } diff --git a/android/module.go b/android/module.go index ab68e24f1..7285a2f21 100644 --- a/android/module.go +++ b/android/module.go @@ -3208,8 +3208,9 @@ func (m *moduleContext) installFile(installPath InstallPath, name string, srcPat extraCmds := "" if extraZip != nil { - extraCmds += fmt.Sprintf(" && unzip -qDD -d '%s' '%s'", + extraCmds += fmt.Sprintf(" && ( unzip -qDD -d '%s' '%s' 2>&1 | grep -v \"zipfile is empty\"; exit $${PIPESTATUS[0]} )", extraZip.dir.String(), extraZip.zip.String()) + extraCmds += " || ( code=$$?; if [ $$code -ne 0 -a $$code -ne 1 ]; then exit $$code; fi )" implicitDeps = append(implicitDeps, extraZip.zip) }