[elbe-devel] [PATCH 12/25] py3: fixup file mode

Manuel Traut manut at linutronix.de
Mon Dec 11 10:11:06 CET 2017


py3 uses 0o644 instead of 0644, py2 supports both, so use first one.

Signed-off-by: Manuel Traut <manut at linutronix.de>
---
 elbepack/cdroms.py        | 12 ++++++------
 elbepack/commands/init.py |  2 +-
 elbepack/db.py            |  4 ++--
 elbepack/debpkg.py        |  2 +-
 elbepack/efilesystem.py   |  2 +-
 elbepack/filesystem.py    |  2 +-
 elbepack/finetuning.py    |  2 +-
 elbepack/rfs.py           |  7 +++----
 elbepack/updatepkg.py     |  6 +++---
 elbepack/virtapt.py       |  2 +-
 10 files changed, 20 insertions(+), 21 deletions(-)

diff --git a/elbepack/cdroms.py b/elbepack/cdroms.py
index 51c5cdf2..1755aaae 100644
--- a/elbepack/cdroms.py
+++ b/elbepack/cdroms.py
@@ -178,17 +178,17 @@ def mk_binary_cdrom(rfs, arch, codename, init_codename, xml, target, log, cdrom_
     # to make the installer accept this as a CDRom
     repo_fs = Filesystem( repo_path )
     repo_fs.mkdir_p (".disk")
-    repo_fs.write_file (".disk/base_installable", 0644, "main\n")
-    repo_fs.write_file (".disk/base_components", 0644, "main\n")
-    repo_fs.write_file (".disk/cd_type", 0644, "not_complete\n")
-    repo_fs.write_file (".disk/info", 0644, "elbe inst cdrom - full cd\n")
+    repo_fs.write_file (".disk/base_installable", 0o644, "main\n")
+    repo_fs.write_file (".disk/base_components", 0o644, "main\n")
+    repo_fs.write_file (".disk/cd_type", 0o644, "not_complete\n")
+    repo_fs.write_file (".disk/info", 0o644, "elbe inst cdrom - full cd\n")
     repo_fs.symlink (".", "debian", allow_exists=True)
-    repo_fs.write_file ("md5sum.txt", 0644, "")
+    repo_fs.write_file ("md5sum.txt", 0o644, "")
 
     # write source xml onto cdrom
     xml.xml.write (repo_fs.fname ('source.xml'))
 
     target_repo_fs = Filesystem( target_repo_path )
-    target_repo_fs.write_file (".aptignr", 0644, "")
+    target_repo_fs.write_file (".aptignr", 0o644, "")
 
     return repo.buildiso( os.path.join( target, "bin-cdrom.iso" ) )
diff --git a/elbepack/commands/init.py b/elbepack/commands/init.py
index 1a009b49..245bc8fe 100644
--- a/elbepack/commands/init.py
+++ b/elbepack/commands/init.py
@@ -174,7 +174,7 @@ def run_command( argv ):
             write_template(os.path.join(out_path,o), os.path.join(init_template_dir, t), d, linebreak=False )
 
         if t in make_executable:
-            os.chmod( os.path.join(out_path,o), 0755 )
+            os.chmod( os.path.join(out_path,o), 0o755 )
 
     shutil.copyfile( args[0],
        os.path.join(out_path, "source.xml" ) )
diff --git a/elbepack/db.py b/elbepack/db.py
index 5bd32211..fa322a2e 100644
--- a/elbepack/db.py
+++ b/elbepack/db.py
@@ -149,7 +149,7 @@ class ElbeDB(object):
             with open (builddir+"/postbuild.sh", 'w') as dst:
                 copyfileobj (postbuild_file, dst)
 
-            os.chmod (builddir+"/postbuild.sh", 0755)
+            os.chmod (builddir+"/postbuild.sh", 0o755)
             dos2unix (builddir+"/postbuild.sh")
 
             return self._update_project_file( s, builddir, "postbuild.sh",
@@ -183,7 +183,7 @@ class ElbeDB(object):
             with open (builddir+"/save.sh", 'w') as dst:
                 copyfileobj (savesh_file, dst)
 
-            os.chmod (builddir+"/save.sh", 0755)
+            os.chmod (builddir+"/save.sh", 0o755)
             dos2unix (builddir+"/save.sh")
 
             return self._update_project_file( s, builddir, "save.sh",
diff --git a/elbepack/debpkg.py b/elbepack/debpkg.py
index ba15b18f..31ec69b4 100644
--- a/elbepack/debpkg.py
+++ b/elbepack/debpkg.py
@@ -51,7 +51,7 @@ def build_binary_deb( name, arch, version, description, files, deps, target_dir
     pkgdir = os.path.join( tmpdir, pkgfname )
 
     os.system( 'mkdir -p "%s"' % os.path.join( pkgdir, "DEBIAN" ) )
-    write_file( os.path.join( pkgdir, "DEBIAN" , "control" ), 0644, gen_controlfile(name, version, arch, description, deps) )
+    write_file( os.path.join( pkgdir, "DEBIAN" , "control" ), 0o644, gen_controlfile(name, version, arch, description, deps) )
 
     for (fname, instpath) in files:
         full_instpath = os.path.join( pkgdir, instpath )
diff --git a/elbepack/efilesystem.py b/elbepack/efilesystem.py
index be7d7e25..96ce0ad4 100644
--- a/elbepack/efilesystem.py
+++ b/elbepack/efilesystem.py
@@ -197,7 +197,7 @@ class ChRootFilesystem(ElbeFilesystem):
 
         self.mkdir_p ("usr/sbin")
         self.write_file ("usr/sbin/policy-rc.d",
-            0755, "#!/bin/sh\nexit 101\n")
+            0o755, "#!/bin/sh\nexit 101\n")
 
         self.mount()
         return self
diff --git a/elbepack/filesystem.py b/elbepack/filesystem.py
index fb76756b..63dd8953 100644
--- a/elbepack/filesystem.py
+++ b/elbepack/filesystem.py
@@ -122,7 +122,7 @@ class Filesystem(object):
         fp.close()
         return retval
 
-    def mkdir_p (self, newdir, mode=0755):
+    def mkdir_p (self, newdir, mode=0o755):
         """works the way a good mkdir -p would...
                 - already exists, silently complete
                 - regular file in the way, raise an exception
diff --git a/elbepack/finetuning.py b/elbepack/finetuning.py
index 0020e020..64bfec81 100644
--- a/elbepack/finetuning.py
+++ b/elbepack/finetuning.py
@@ -340,7 +340,7 @@ class UpdatedAction(FinetuningAction):
             with open ((target.path + '/pub.key'), 'wb') as tkey:
                 tkey.write (key.getvalue ())
 
-            target.mkdir_p ("/var/cache/elbe/gnupg", mode=0700)
+            target.mkdir_p ("/var/cache/elbe/gnupg", mode=0o700)
             with target:
                 os.environ ['GNUPGHOME'] = target.path + "/var/cache/elbe/gnupg"
                 log.do ("gpg --import " + target.path + "/pub.key")
diff --git a/elbepack/rfs.py b/elbepack/rfs.py
index fa6ac8dd..a0bfdbdb 100644
--- a/elbepack/rfs.py
+++ b/elbepack/rfs.py
@@ -55,8 +55,7 @@ class BuildEnv ():
         if not self.rfs.isfile( "etc/elbe_version" ):
             # avoid starting daemons inside the buildenv
             self.rfs.mkdir_p ("usr/sbin")
-            self.rfs.write_file ("usr/sbin/policy-rc.d",
-                0755, "#!/bin/sh\nexit 101\n")
+            self.rfs.write_file ("usr/sbin/policy-rc.d", 0o755, "#!/bin/sh\nexit 101\n")
             self.debootstrap ()
             self.fresh_debootstrap = True
             self.need_dumpdebootstrap = True
@@ -221,13 +220,13 @@ class BuildEnv ():
         if self.rfs.exists("etc/apt/sources.list"):
             self.rfs.remove("etc/apt/sources.list")
 
-        self.rfs.write_file ("etc/apt/sources.list", 0644, mirror)
+        self.rfs.write_file ("etc/apt/sources.list", 0o644, mirror)
 
         self.rfs.mkdir_p( "var/cache/elbe" )
 
         preseed = get_preseed( self.xml )
         preseed_txt = preseed_to_text( preseed )
-        self.rfs.write_file( "var/cache/elbe/preseed.txt", 0644, preseed_txt )
+        self.rfs.write_file( "var/cache/elbe/preseed.txt", 0o644, preseed_txt )
         with self.rfs:
             self.log.chroot( self.rfs.path, 'debconf-set-selections < %s' % self.rfs.fname("var/cache/elbe/preseed.txt") )
 
diff --git a/elbepack/updatepkg.py b/elbepack/updatepkg.py
index 405a6538..409c3959 100644
--- a/elbepack/updatepkg.py
+++ b/elbepack/updatepkg.py
@@ -134,14 +134,14 @@ def gen_update_pkg (project, xml_filename, upd_filename,
 
     if project.presh_file:
         copyfile (project.presh_file, update + '/pre.sh')
-        os.chmod (update + '/pre.sh', 0755)
+        os.chmod (update + '/pre.sh', 0o755)
 
     if project.postsh_file:
         copyfile (project.postsh_file, update + '/post.sh')
-        os.chmod (update + '/post.sh', 0755)
+        os.chmod (update + '/post.sh', 0o755)
 
     if cmd_dir:
-        inlucdedir (update, 'cmd', cmd_dir, mode=0755)
+        inlucdedir (update, 'cmd', cmd_dir, mode=0o755)
 
     if cfg_dir:
         inlucdedir (update, 'conf', cfg_dir)
diff --git a/elbepack/virtapt.py b/elbepack/virtapt.py
index 8adb7859..53607ad7 100644
--- a/elbepack/virtapt.py
+++ b/elbepack/virtapt.py
@@ -86,7 +86,7 @@ class VirtApt:
         #print "updating in progress", obj
         return True
 
-    def mkdir_p (self, newdir, mode=0755):
+    def mkdir_p (self, newdir, mode=0o755):
         """works the way a good mkdir -p would...
                 - already exists, silently complete
                 - regular file in the way, raise an exception
-- 
2.15.1




More information about the elbe-devel mailing list