Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(924)

Unified Diff: lib/naclports/binary_package.py

Issue 1285953002: Switch devenv to use pkg packages (Closed) Base URL: https://chromium.googlesource.com/external/naclports.git@toolchain_install
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « build_tools/common.sh ('k') | lib/naclports/bsd_pkg.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/naclports/binary_package.py
diff --git a/lib/naclports/binary_package.py b/lib/naclports/binary_package.py
index 38a4da95319f88efe81a4d985aa4a73a3e49274b..3b8a0045cc1a6dbb4cc4b63f4756a2e434aab7ba 100644
--- a/lib/naclports/binary_package.py
+++ b/lib/naclports/binary_package.py
@@ -14,6 +14,13 @@ PAYLOAD_DIR = 'payload'
INSTALL_PREFIX = '/naclports-dummydir'
ELF_MAGIC = '\x7fELF'
+PEXE_MAGIC = 'PEXE'
+
+def MakeDirIfNeeded(filename):
+ dirname = os.path.dirname(filename)
+ if not os.path.isdir(dirname):
+ util.Makedirs(dirname)
+
def IsElfFile(filename):
if os.path.islink(filename):
@@ -23,6 +30,14 @@ def IsElfFile(filename):
return header == ELF_MAGIC
+def IsPexeFile(filename):
+ if os.path.islink(filename):
+ return False
+ with open(filename) as f:
+ header = f.read(4)
+ return header == PEXE_MAGIC
+
+
def InstallFile(filename, old_root, new_root):
"""Install a single file by moving it into a new location.
@@ -43,7 +58,7 @@ def InstallFile(filename, old_root, new_root):
# When install binarie ELF files into the toolchain direcoties, remove
# the X bit so that they do not found when searching the PATH.
- if IsElfFile(newname):
+ if IsElfFile(newname) or IsPexeFile(newname):
mode = os.stat(newname).st_mode
mode = mode & ~(stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH)
os.chmod(newname, mode)
@@ -149,6 +164,11 @@ class BinaryPackage(package.Package):
self._Install(force)
def _Install(self, force):
+ if self.TOOLCHAIN_INSTALL != '0':
+ self._InstallFiles(force)
+ self.WriteStamp()
+
+ def _InstallFiles(self, force):
dest = util.GetInstallRoot(self.config)
dest_tmp = os.path.join(dest, 'install_tmp')
if os.path.exists(dest_tmp):
@@ -194,11 +214,11 @@ class BinaryPackage(package.Package):
RelocateFile(name, dest)
self.WriteFileList(names)
- self.WriteStamp()
def WriteStamp(self):
"""Write stamp file containing pkg_info."""
filename = util.GetInstallStamp(self.NAME, self.config)
+ MakeDirIfNeeded(filename)
util.LogVerbose('stamp: %s' % filename)
pkg_info = self.GetPkgInfo()
with open(filename, 'w') as f:
@@ -207,9 +227,7 @@ class BinaryPackage(package.Package):
def WriteFileList(self, file_names):
"""Write the file list for this package."""
filename = self.GetListFile()
- dirname = os.path.dirname(filename)
- if not os.path.isdir(dirname):
- util.Makedirs(dirname)
+ MakeDirIfNeeded(filename)
with open(filename, 'w') as f:
for name in file_names:
f.write(name + '\n')
« no previous file with comments | « build_tools/common.sh ('k') | lib/naclports/bsd_pkg.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698