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

Recreate /var #143

Merged
merged 5 commits into from
Dec 19, 2023
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
34 changes: 29 additions & 5 deletions run-build
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ log = logging.getLogger(os.path.basename(__file__))
class ImageBuildRoot(object):
"""Build root for performing actual image build

A temporary build root is created with mmdebstrap at builddir. The
A temporary build root is created with ostree at builddir. The
options in the config section buildroot control what gets installed
and mounted in the buildroot.
"""
Expand Down Expand Up @@ -173,6 +173,28 @@ class ImageBuildRoot(object):
for path in to_mount:
self.mount(path)

# Remove the tmpfiles.d snippet that sets up symlinks for changes we have
# just reversed, and for the dpkg database we are about to move back
os.unlink(os.path.join(self.builddir, 'usr/lib/tmpfiles.d/ostree.conf'))

# Create any files that would normally be handled at runtime. This is
# particularly important for /var since it's likely that it was removed
# from the ostree commit. Run this inside the chroot to avoid depending on
# systemd-tmpfiles on the host system.
self._run(['systemd-tmpfiles', '--create', '--remove', '--boot', '-E'])

# Move the dpkg database back to its normal location
os.rename(
os.path.join(self.builddir, 'usr/share/dpkg/database'),
os.path.join(self.builddir, 'var/lib/dpkg'),
)

# update-catalog requires /var/lib/sgml-base to exist
os.makedirs(os.path.join(self.builddir, 'var/lib/sgml-base'))

# update-xmlcatalog requires /var/lib/xml-core to exist
os.makedirs(os.path.join(self.builddir, 'var/lib/xml-core'))
Comment on lines +192 to +196
Copy link
Member Author

@wjt wjt Dec 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment in run-build seems prescient:

        # Pull the ostree. Ideally the eosminbase ostree would be used to
        # minimize the buildroot, but that's not released and would fail with
        # --use-production-ostree.

These packages are not part of eosminbase; so I believe these steps would not be necessary if we used that for the buildroot.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I have a vague memory of seeing errors from sgml-base in my toolboxes.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are the errors fatal? Ideally those would have tmpfiles snippets so we didn't need to do anything like this. Or the scripts would, you know, attempt to create the directories instead of assuming they exist? But meh, this is fine.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, unfortunately they are fatal, and a trigger failing is in turn fatal to the apt-get install invocation.

I agree that ideally they would have tmpfiles snippets – though I think the Way of the Future in OSTree is to put it in /usr/share/factory or whatever it's called?


log.info('Installing buildroot packages')
apt_env = os.environ.copy()
apt_env['DEBIAN_FRONTEND'] = 'noninteractive'
Expand All @@ -195,11 +217,13 @@ class ImageBuildRoot(object):
"--force-confnew";
}};
"""))
apt_cmd = ['chroot', self.builddir, 'apt-get', 'update']
subprocess.check_call(apt_cmd, env=apt_env)
apt_cmd = ['chroot', self.builddir, 'apt-get', 'install', '-y']
self._run(['apt-get', 'update'], env=apt_env)
apt_cmd = ['apt-get', 'install', '-y']
apt_cmd += packages
subprocess.check_call(apt_cmd, env=apt_env)
self._run(apt_cmd, env=apt_env)

def _run(self, cmd, env=None):
subprocess.check_call(['chroot', self.builddir] + cmd, env=env)

def mount(self, path, target=None):
"""Bind mount path in the build directory"""
Expand Down
Loading