Skip to content

Commit

Permalink
Use db_dump
Browse files Browse the repository at this point in the history
  • Loading branch information
peterverraedt committed Dec 5, 2019
1 parent bf5a2be commit 33d0d9e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 41 deletions.
35 changes: 0 additions & 35 deletions lib/yumbootstrap/bdb.py

This file was deleted.

15 changes: 11 additions & 4 deletions lib/yumbootstrap/yum.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import os
import shutil

import yumbootstrap.bdb as bdb
import yumbootstrap.sh as sh
import yumbootstrap.fs as fs

Expand Down Expand Up @@ -146,13 +145,12 @@ def fix_rpmdb(self, expected_rpmdb_dir = None,
db_load = 'db_load', rpm = 'rpm'):
logger.info("fixing RPM database for guest")

# use platform-python if available to read rpm dbpath
if os.path.exists('/usr/libexec/platform-python'):
platform_python = '/usr/libexec/platform-python'
else:
# On debian-based systems, use default python
platform_python = 'python'

# Call platform-python to be sure that rpm module can be loaded
current_rpmdb_dir = sh.run(
[platform_python, '-c', 'import rpm; print(rpm.expandMacro("%{_dbpath}"))'],
pipe = sh.READ,
Expand All @@ -171,16 +169,25 @@ def fix_rpmdb(self, expected_rpmdb_dir = None,
rpmdb_dir = os.path.join(self.chroot, current_rpmdb_dir.lstrip('/'))

logger.info('converting "Packages" file')

in_pkg_db = os.path.join(rpmdb_dir, 'Packages')
tmp_pkg_db = os.path.join(expected_rpmdb_dir, 'Packages.tmp')
out_pkg_db = os.path.join(expected_rpmdb_dir, 'Packages')

in_command = sh.run(
['db_dump', in_pkg_db],
pipe = sh.READ,
env = self.yum_conf.env,
)
out_command = sh.run(
[db_load, tmp_pkg_db],
chroot = self.chroot, pipe = sh.WRITE,
env = self.yum_conf.env,
)
bdb.db_dump(in_pkg_db, out_command)
for line in in_command:
out_command.write(line)
out_command.close()

os.rename(
os.path.join(self.chroot, tmp_pkg_db.lstrip('/')),
os.path.join(self.chroot, out_pkg_db.lstrip('/'))
Expand Down
2 changes: 0 additions & 2 deletions redhat/yumbootstrap.spec
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ Packager: %{_packager}
Prefix: %{_prefix}
BuildRequires: python3-setuptools
Requires: yum >= 3.0
%{?el7:Requires: python36-bsddb3}
%{?el8:Requires: python3-bsddb3}

%description
yumbootstrap is a tool for installing Yum-based distributions (Red Hat,
Expand Down

0 comments on commit 33d0d9e

Please sign in to comment.