5454import re
5555import shlex
5656import shutil
57+ import stat
5758import subprocess
5859import sys
5960import venv
@@ -744,18 +745,7 @@ def copy_build_to_webroot(self, http: urllib3.PoolManager) -> None:
744745group = self .group ,
745746recursive = True ,
746747 )
747- run (["chmod" ,"-R" ,"o+r" ,self .checkout / "Doc" / "build" / "html" ])
748- run ([
749- "find" ,
750- self .checkout / "Doc" / "build" / "html" ,
751- "-type" ,
752- "d" ,
753- "-exec" ,
754- "chmod" ,
755- "o+x" ,
756- "{}" ,
757- ";" ,
758- ])
748+ chmod_make_readable (self .checkout / "Doc" / "build" / "html" )
759749run ([
760750"rsync" ,
761751"-a" ,
@@ -770,12 +760,7 @@ def copy_build_to_webroot(self, http: urllib3.PoolManager) -> None:
770760# Copy archive files to /archives/
771761logging .debug ("Copying dist files." )
772762chgrp (self .checkout / "Doc" / "dist" ,group = self .group ,recursive = True )
773- run ([
774- "chmod" ,
775- "-R" ,
776- "o+r" ,
777- self .checkout / "Doc" / "dist" ,
778- ])
763+ chmod_make_readable (self .checkout / "Doc" / "dist" )
779764run (["mkdir" ,"-m" ,"o+rx" ,"-p" ,target / "archives" ])
780765chgrp (target / "archives" ,group = self .group )
781766run ([
@@ -907,6 +892,18 @@ def chgrp(
907892logging .warning ("Can't change group of %s: %s" ,path ,str (err ))
908893
909894
895+ def chmod_make_readable (path :Path ,/ ,mode :int = stat .S_IROTH )-> None :
896+ if not path .is_dir ():
897+ raise ValueError
898+
899+ path .chmod (path .stat ().st_mode | stat .S_IROTH | stat .S_IXOTH )# o+rx
900+ for p in path .rglob ("*" ):
901+ if p .is_dir ():
902+ p .chmod (p .stat ().st_mode | stat .S_IROTH | stat .S_IXOTH )# o+rx
903+ else :
904+ p .chmod (p .stat ().st_mode | stat .S_IROTH )# o+r
905+
906+
910907def format_seconds (seconds :float )-> str :
911908hours ,remainder = divmod (seconds ,3600 )
912909minutes ,seconds = divmod (remainder ,60 )