Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

During upgrade, use freebsd-update from an already-fetched release #38

Merged
merged 1 commit into from
Oct 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading