View | Details | Raw Unified | Return to bug 240177 | Differences between
and this patch

Collapse All | Expand All

(-)sysutils/iocage/Makefile (-2 / +5 lines)
Lines 2-7 Link Here
2
2
3
PORTNAME=	iocage
3
PORTNAME=	iocage
4
PORTVERSION=	1.1
4
PORTVERSION=	1.1
5
PORTREVISION=	1
5
CATEGORIES=	sysutils python
6
CATEGORIES=	sysutils python
6
PKGNAMEPREFIX=	${PYTHON_PKGNAMEPREFIX}
7
PKGNAMEPREFIX=	${PYTHON_PKGNAMEPREFIX}
7
8
Lines 22-34 Link Here
22
		${PYTHON_PKGNAMEPREFIX}requests>=2.11.1:www/py-requests@${PY_FLAVOR} \
23
		${PYTHON_PKGNAMEPREFIX}requests>=2.11.1:www/py-requests@${PY_FLAVOR} \
23
		${PYTHON_PKGNAMEPREFIX}libzfs>=1.0.2:devel/py-libzfs@${PY_FLAVOR} \
24
		${PYTHON_PKGNAMEPREFIX}libzfs>=1.0.2:devel/py-libzfs@${PY_FLAVOR} \
24
		${PYTHON_PKGNAMEPREFIX}dulwich>0:devel/dulwich@${PY_FLAVOR} \
25
		${PYTHON_PKGNAMEPREFIX}dulwich>0:devel/dulwich@${PY_FLAVOR} \
25
		${PYTHON_PKGNAMEPREFIX}dnspython>0:dns/py-dnspython@${PY_FLAVOR}
26
		${PYTHON_PKGNAMEPREFIX}dnspython>0:dns/py-dnspython@${PY_FLAVOR} \
27
		merge:devel/rcs57
26
28
27
NO_ARCH=	yes
28
USES=		python:3.6+
29
USES=		python:3.6+
29
USE_GITHUB=	yes
30
USE_GITHUB=	yes
30
USE_PYTHON=	autoplist distutils
31
USE_PYTHON=	autoplist distutils
31
32
33
NO_ARCH=	yes
34
32
CONFLICTS=	py27-iocage-[0-9]*
35
CONFLICTS=	py27-iocage-[0-9]*
33
36
34
.include <bsd.port.mk>
37
.include <bsd.port.mk>
(-)sysutils/iocage/files/patch-iocage_lib-ioc_upgrade.py (+129 lines)
Line 0 Link Here
1
--- iocage_lib/ioc_upgrade.py.orig	2019-01-25 21:32:55 UTC
2
+++ iocage_lib/ioc_upgrade.py
3
@@ -24,6 +24,7 @@
4
 """iocage upgrade module"""
5
 import datetime
6
 import fileinput
7
+import hashlib
8
 import os
9
 import pathlib
10
 import subprocess as su
11
@@ -80,8 +81,11 @@ class IOCUpgrade(iocage_lib.ioc_json.IOC
12
         }
13
 
14
         self.callback = callback
15
-        # Work around for https://github.com/freebsd/freebsd/commit/bffa924f
16
-        os.environ['UNAME_r'] = self.jail_release
17
+
18
+        # symbolic link created on fetch by freebsd-update
19
+        bd_hash = hashlib.sha256((self.path + '\n').encode('utf-8')).hexdigest()
20
+        self.freebsd_install_link = os.path.join(self.path,
21
+            'var/db/freebsd-update', bd_hash + '-install')
22
 
23
     def upgrade_jail(self):
24
         tmp_dataset = self.zfs_get_dataset_name('/tmp')
25
@@ -142,44 +146,40 @@ class IOCUpgrade(iocage_lib.ioc_json.IOC
26
                         callback=self.callback
27
                     )
28
             else:
29
-                try:
30
-                    iocage_lib.ioc_exec.InteractiveExec(
31
-                        fetch_cmd,
32
-                        self.path.replace('/root', ''),
33
-                        uuid=self.uuid,
34
-                        unjailed=True
35
-                    )
36
-                except iocage_lib.ioc_exceptions.CommandFailed:
37
-                    self.__rollback_jail__()
38
-                    msg = f'Upgrade failed! Rolling back jail'
39
-                    iocage_lib.ioc_common.logit(
40
-                        {
41
-                            "level": "EXCEPTION",
42
-                            "message": msg
43
-                        },
44
-                        _callback=self.callback,
45
-                        silent=self.silent
46
-                    )
47
+                iocage_lib.ioc_exec.InteractiveExec(
48
+                    fetch_cmd,
49
+                    self.path.replace('/root', ''),
50
+                    uuid=self.uuid,
51
+                    unjailed=True
52
+                )
53
 
54
-            if not self.interactive:
55
-                while not self.__upgrade_install__(tmp.name):
56
-                    pass
57
-            else:
58
-                # FreeBSD update loops 3 times
59
-                for _ in range(3):
60
-                    try:
61
-                        self.__upgrade_install__(tmp.name)
62
-                    except iocage_lib.ioc_exceptions.CommandFailed:
63
-                        self.__rollback_jail__()
64
-                        msg = f'Upgrade failed! Rolling back jail'
65
-                        iocage_lib.ioc_common.logit(
66
-                            {
67
-                                'level': 'EXCEPTION',
68
-                                'message': msg
69
-                            },
70
-                            _callback=self.callback,
71
-                            silent=self.silent
72
-                        )
73
+            if not os.path.islink(self.freebsd_install_link):
74
+                msg = f'Upgrade failed, nothing to install after fetch!'
75
+                iocage_lib.ioc_common.logit(
76
+                    {
77
+                        'level': 'EXCEPTION',
78
+                        'message': msg
79
+                    },
80
+                    _callback=self.callback,
81
+                    silent=self.silent
82
+                )
83
+
84
+            for _ in range(50): # up to 50 invocations to prevent runaway
85
+                if os.path.islink(self.freebsd_install_link):
86
+                    self.__upgrade_install__(tmp.name)
87
+                else:
88
+                    break
89
+
90
+            if os.path.islink(self.freebsd_install_link):
91
+                msg = f'Upgrade failed, freebsd-update won\'t finish!'
92
+                iocage_lib.ioc_common.logit(
93
+                    {
94
+                        'level': 'EXCEPTION',
95
+                        'message': msg
96
+                    },
97
+                    _callback=self.callback,
98
+                    silent=self.silent
99
+                )
100
 
101
             new_release = iocage_lib.ioc_common.get_jail_freebsd_version(
102
                 self.path,
103
@@ -337,7 +337,7 @@ class IOCUpgrade(iocage_lib.ioc_json.IOC
104
         return new_release
105
 
106
     def __upgrade_install__(self, name):
107
-        """Installs the upgrade and returns the exit code."""
108
+        """Installs the upgrade."""
109
         install_cmd = [
110
             name, "-b", self.path, "-d",
111
             f"{self.path}/var/db/freebsd-update/", "-f",
112
@@ -353,16 +353,10 @@ class IOCUpgrade(iocage_lib.ioc_json.IOC
113
                 unjailed=True,
114
                 callback=self.callback,
115
             ) as _exec:
116
-                update_output = iocage_lib.ioc_common.consume_and_log(
117
+                iocage_lib.ioc_common.consume_and_log(
118
                     _exec,
119
                     callback=self.callback
120
                 )
121
-
122
-            for i in update_output:
123
-                if i == 'No updates are available to install.':
124
-                    return True
125
-
126
-            return False
127
         else:
128
             iocage_lib.ioc_exec.InteractiveExec(
129
                 install_cmd,

Return to bug 240177