Blame SOURCES/BZ-1097383-usr-readonly.patch

5e9bef
commit 507182919894e9bf75b08a75cb22c49d852c8278
5e9bef
Author: James Antill <james@and.org>
5e9bef
Date:   Wed May 21 15:14:55 2014 -0400
5e9bef
5e9bef
    Check /usr for writability before running a transaction.
5e9bef
5e9bef
diff --git a/docs/yum.conf.5 b/docs/yum.conf.5
5e9bef
index 4ec7689..c39544d 100644
5e9bef
--- a/docs/yum.conf.5
5e9bef
+++ b/docs/yum.conf.5
5e9bef
@@ -892,6 +892,11 @@ shouldn't be needed as yum should always solve or fail, however it has been
5e9bef
 observed that it can loop forever with very large system upgrades. Setting
5e9bef
 this to `0' (or "<forever>") makes yum try forever. Default is `100'.
5e9bef
 
5e9bef
+.IP
5e9bef
+\fBusr_w_check\fR
5e9bef
+Either `0' or `1'. Set this to `0' to disable the checking for writability on
5e9bef
+/usr in the installroot (when going into the depsolving stage). Default is `1'
5e9bef
+(perform the check).
5e9bef
 
5e9bef
 .SH "[repository] OPTIONS"
5e9bef
 .LP 
5e9bef
diff --git a/yum/config.py b/yum/config.py
5e9bef
index 7bb56d0..f0f4e96 100644
5e9bef
--- a/yum/config.py
5e9bef
+++ b/yum/config.py
5e9bef
@@ -906,6 +906,8 @@ class YumConf(StartupConf):
5e9bef
 
5e9bef
     check_config_file_age = BoolOption(True)
5e9bef
 
5e9bef
+    usr_w_check = BoolOption(True)
5e9bef
+
5e9bef
     _reposlist = []
5e9bef
 
5e9bef
     def dump(self):
5e9bef
diff --git a/yummain.py b/yummain.py
5e9bef
index fa76af8..ee8d632 100755
5e9bef
--- a/yummain.py
5e9bef
+++ b/yummain.py
5e9bef
@@ -209,6 +209,17 @@ def main(args):
5e9bef
             logger.critical(msg)
5e9bef
         if unlock(): return 200
5e9bef
         return 3
5e9bef
+
5e9bef
+    # Mainly for ostree, but might be useful for others.
5e9bef
+    if base.conf.usr_w_check:
5e9bef
+        usrinstpath = base.conf.installroot + "/usr"
5e9bef
+        usrinstpath = usrinstpath.replace('//', '/')
5e9bef
+        if not os.access(usrinstpath, os.W_OK):
5e9bef
+            logger.critical(_('No write access to %s directory') % usrinstpath)
5e9bef
+            logger.critical(_('  Maybe this is an ostree image?'))
5e9bef
+            logger.critical(_('  To disable you can use --setopt=usr_w_check=false'))
5e9bef
+            if unlock(): return 200
5e9bef
+            return 1
5e9bef
             
5e9bef
     # Depsolve stage
5e9bef
     verbose_logger.log(logginglevels.INFO_2, _('Resolving Dependencies'))
5e9bef
commit 6e64b142014dc3c5489aed7966f0948948054fb7
5e9bef
Author: James Antill <james@and.org>
5e9bef
Date:   Wed May 21 18:29:28 2014 -0400
5e9bef
5e9bef
    Check for existance, so mock etc. is happy.
5e9bef
5e9bef
diff --git a/yummain.py b/yummain.py
5e9bef
index ee8d632..24bbe6c 100755
5e9bef
--- a/yummain.py
5e9bef
+++ b/yummain.py
5e9bef
@@ -214,7 +214,8 @@ def main(args):
5e9bef
     if base.conf.usr_w_check:
5e9bef
         usrinstpath = base.conf.installroot + "/usr"
5e9bef
         usrinstpath = usrinstpath.replace('//', '/')
5e9bef
-        if not os.access(usrinstpath, os.W_OK):
5e9bef
+        if (os.path.exists(usrinstpath) and
5e9bef
+            not os.access(usrinstpath, os.W_OK)):
5e9bef
             logger.critical(_('No write access to %s directory') % usrinstpath)
5e9bef
             logger.critical(_('  Maybe this is an ostree image?'))
5e9bef
             logger.critical(_('  To disable you can use --setopt=usr_w_check=false'))