54
54
import re
55
55
import shlex
56
56
import shutil
57
+ import stat
57
58
import subprocess
58
59
import sys
59
60
import venv
@@ -744,18 +745,7 @@ def copy_build_to_webroot(self, http: urllib3.PoolManager) -> None:
744
745
group = self .group ,
745
746
recursive = True ,
746
747
)
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" )
759
749
run ([
760
750
"rsync" ,
761
751
"-a" ,
@@ -770,12 +760,7 @@ def copy_build_to_webroot(self, http: urllib3.PoolManager) -> None:
770
760
# Copy archive files to /archives/
771
761
logging .debug ("Copying dist files." )
772
762
chgrp (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" )
779
764
run (["mkdir" , "-m" , "o+rx" , "-p" , target / "archives" ])
780
765
chgrp (target / "archives" , group = self .group )
781
766
run ([
@@ -907,6 +892,18 @@ def chgrp(
907
892
logging .warning ("Can't change group of %s: %s" , path , str (err ))
908
893
909
894
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
+
910
907
def format_seconds (seconds : float ) -> str :
911
908
hours , remainder = divmod (seconds , 3600 )
912
909
minutes , seconds = divmod (remainder , 60 )
0 commit comments