8686UNKNOWN_ABSPATH = Path ("/usr/bin/true" )
8787UNKNOWN_VERSION = cast (SemVer , SemVer .parse ("999.999.999" ))
8888
89+
90+ def env_flag_is_true (name : str ) -> bool :
91+ return os .getenv (name , "" ).strip ().lower () in {"1" , "true" , "yes" , "on" }
92+
93+
8994################## VALIDATORS #######################################
9095
9196NEVER_CACHE = (
@@ -409,6 +414,10 @@ def EUID(self) -> int:
409414
410415 return self .detect_euid ()
411416
417+ @property
418+ def DRY_RUN (self ) -> bool :
419+ return self ._dry_run or env_flag_is_true ("DRY_RUN" )
420+
412421 @computed_field
413422 @property
414423 def INSTALLER_BIN_ABSPATH (self ) -> HostBinPath | None :
@@ -856,7 +865,7 @@ def exec(
856865 f"cwd must be a valid, accessible directory: { cwd } "
857866 )
858867 cmd = [str (bin_abspath ), * (str (arg ) for arg in cmd )]
859- if self ._dry_run :
868+ if self .DRY_RUN :
860869 logger .info (
861870 "DRY RUN (%s): %s" ,
862871 self .__class__ .__name__ ,
@@ -883,7 +892,7 @@ def drop_privileges():
883892 except Exception :
884893 pass
885894
886- if self ._dry_run :
895+ if self .DRY_RUN :
887896 return subprocess .CompletedProcess (cmd , 0 , "" , "skipped (dry run)" )
888897
889898 return subprocess .run (
@@ -1103,7 +1112,7 @@ def install(
11031112 if not quiet :
11041113 raise
11051114
1106- if self ._dry_run :
1115+ if self .DRY_RUN :
11071116 # return fake ShallowBinary if we're just doing a dry run
11081117 # no point trying to get real abspath or version if nothing was actually installed
11091118 return ShallowBinary .model_validate (
@@ -1200,7 +1209,7 @@ def update(
12001209 if not quiet :
12011210 raise
12021211
1203- if self ._dry_run :
1212+ if self .DRY_RUN :
12041213 return ShallowBinary .model_validate (
12051214 {
12061215 "name" : bin_name ,
@@ -1289,7 +1298,7 @@ def uninstall(
12891298
12901299 self .invalidate_cache (bin_name )
12911300
1292- if self ._dry_run :
1301+ if self .DRY_RUN :
12931302 return True
12941303
12951304 if uninstall_result is not False :
0 commit comments