Skip to content

Commit

Permalink
During upgrade, use freebsd-update from an already-fetched release (f…
Browse files Browse the repository at this point in the history
…reebsd#38)

This eliminates the dependency on github during upgrade.  It also makes
it possible to upgrade to a release that does not have -RELEASE in the
name.

Fixes freebsd#36
  • Loading branch information
asomers authored and dgeo committed Nov 29, 2024
1 parent bc1c4df commit 6c3423e
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions iocage_lib/ioc_upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,19 +104,25 @@ def upgrade_jail(self):
self.__upgrade_check_conf__()

f_rel = f'{self.new_release.rsplit("-RELEASE")[0]}'
f = 'https://raw.githubusercontent.com/freebsd/freebsd-src' \
f'/releng/{f_rel}/usr.sbin/freebsd-update/freebsd-update.sh'

tmp = None
try:
tmp = tempfile.NamedTemporaryFile(delete=False)
with urllib.request.urlopen(f) as fbsd_update:
tmp.write(fbsd_update.read())
tmp.close()
os.chmod(tmp.name, 0o755)
fetched_update = f"{self.iocroot}/releases/{self.new_release}" \
f"/root/usr/sbin/freebsd-update"
if os.path.isfile(fetched_update):
fbsd_update = fetched_update
else:
f = 'https://raw.githubusercontent.com/freebsd/freebsd-src' \
f'/releng/{f_rel}/usr.sbin/freebsd-update/freebsd-update.sh'
tmp = tempfile.NamedTemporaryFile(delete=False)
with urllib.request.urlopen(f) as http:
tmp.write(http.read())
tmp.close()
os.chmod(tmp.name, 0o755)
fbsd_update = tmp.name

fetch_cmd = [
tmp.name, "-b", self.path, "-d",
fbsd_update, "-b", self.path, "-d",
f"{self.path}/var/db/freebsd-update/", "-f",
f"{self.path}/etc/freebsd-update.conf",
"--not-running-from-cron", "--currently-running",
Expand Down Expand Up @@ -159,7 +165,7 @@ def upgrade_jail(self):

for _ in range(50): # up to 50 invocations to prevent runaway
if os.path.islink(self.freebsd_install_link):
self.__upgrade_install__(tmp.name)
self.__upgrade_install__(fbsd_update)
else:
break

Expand Down

0 comments on commit 6c3423e

Please sign in to comment.