diff --git a/docs/livemedia-creator.rst b/docs/livemedia-creator.rst index c3d76b2a0..5e9587131 100644 --- a/docs/livemedia-creator.rst +++ b/docs/livemedia-creator.rst @@ -67,7 +67,7 @@ Run this to create a bootable live iso:: You can run it directly from the lorax git repo like this:: - sudo PATH=./src/sbin/:$PATH PYTHONPATH=./src/ ./src/sbin/livemedia-creator \ + sudo PATH=./src/bin/:$PATH PYTHONPATH=./src/ ./src/bin/livemedia-creator \ --make-iso --iso=/extra/iso/boot.iso \ --ks=./docs/fedora-livemedia.ks --lorax-templates=./share/ diff --git a/lorax.spec b/lorax.spec index 0c112f1d1..4e26f7b8a 100644 --- a/lorax.spec +++ b/lorax.spec @@ -145,9 +145,9 @@ make DESTDIR=$RPM_BUILD_ROOT mandir=%{_mandir} install %doc docs/*ks %{python3_sitelib}/pylorax %{python3_sitelib}/*.egg-info -%{_sbindir}/lorax -%{_sbindir}/mkefiboot -%{_sbindir}/livemedia-creator +%{_bindir}/lorax +%{_bindir}/mkefiboot +%{_bindir}/livemedia-creator %{_bindir}/mkksiso %{_bindir}/image-minimizer %dir %{_sysconfdir}/lorax diff --git a/setup.py b/setup.py index 277a62c4e..ddc780764 100644 --- a/setup.py +++ b/setup.py @@ -12,9 +12,9 @@ [os.path.join(root, fname)])) # executable -data_files.append(("/usr/sbin", ["src/sbin/lorax", "src/sbin/mkefiboot", - "src/sbin/livemedia-creator"])) -data_files.append(("/usr/bin", ["src/bin/image-minimizer", "src/bin/mkksiso"])) +data_files.append(("/usr/bin", ["src/bin/lorax", "src/bin/mkefiboot", + "src/bin/livemedia-creator", + "src/bin/image-minimizer", "src/bin/mkksiso"])) setup(name="lorax", version="42.4", diff --git a/share/templates.d/99-generic/config_files/common/inst.rngd.service b/share/templates.d/99-generic/config_files/common/inst.rngd.service index 7b5103372..aa2e3c50d 100644 --- a/share/templates.d/99-generic/config_files/common/inst.rngd.service +++ b/share/templates.d/99-generic/config_files/common/inst.rngd.service @@ -8,4 +8,4 @@ ConditionKernelCommandLine=!inst.rngd=0 [Service] Type=simple EnvironmentFile=/etc/sysconfig/rngd -ExecStart=/usr/sbin/rngd -f $RNGD_ARGS +ExecStart=/usr/bin/rngd -f $RNGD_ARGS diff --git a/share/templates.d/99-generic/config_files/common/profile b/share/templates.d/99-generic/config_files/common/profile index 00a475e9c..8990a7620 100644 --- a/share/templates.d/99-generic/config_files/common/profile +++ b/share/templates.d/99-generic/config_files/common/profile @@ -1,3 +1,3 @@ PS1="[anaconda \u@\h \W]\\$ " -PATH=/bin:/sbin:/usr/bin:/usr/sbin:/mnt/sysimage/sbin:/mnt/sysimage/usr/sbin:/mnt/sysimage/bin:/mnt/sysimage/usr/bin +PATH=/usr/bin:/mnt/sysimage/usr/bin export PATH PS1 diff --git a/share/templates.d/99-generic/runtime-cleanup.tmpl b/share/templates.d/99-generic/runtime-cleanup.tmpl index 9199f53b2..0c2a7a095 100644 --- a/share/templates.d/99-generic/runtime-cleanup.tmpl +++ b/share/templates.d/99-generic/runtime-cleanup.tmpl @@ -30,7 +30,7 @@ removefrom shadow-utils --allbut /usr/bin/chage /usr/*bin/chpasswd \ /usr/*bin/groupadd /usr/*bin/useradd ## no services to turn on/off (keep the /etc/init.d link though) -removefrom initscripts /usr/sbin/* /usr/share/locale/* /usr/share/doc/* /usr/share/man/* +removefrom initscripts /usr/bin/* /usr/share/locale/* /usr/share/doc/* /usr/share/man/* ## no storage device monitoring removepkg device-mapper-event diff --git a/src/sbin/livemedia-creator b/src/bin/livemedia-creator similarity index 98% rename from src/sbin/livemedia-creator rename to src/bin/livemedia-creator index 91c94df83..747ff6e32 100755 --- a/src/sbin/livemedia-creator +++ b/src/bin/livemedia-creator @@ -22,6 +22,7 @@ log = logging.getLogger("livemedia-creator") import glob import os +import shutil import sys import tempfile @@ -91,7 +92,7 @@ def main(): errors.append("qemu needs to be installed.") if is_install and opts.no_virt \ - and not os.path.exists("/usr/sbin/anaconda"): + and not shutil.which("anaconda"): errors.append("no-virt requires anaconda to be installed.") if opts.make_appliance and not opts.app_template: @@ -144,7 +145,7 @@ def main(): if opts.virt_uefi and not os.path.isdir(opts.fw_path): errors.append("The UEFI firmware directory is missing: %s" % opts.fw_path) - if opts.domacboot and not os.path.exists("/usr/sbin/mkfs.hfsplus"): + if opts.domacboot and not shutil.which("mkfs.hfsplus"): errors.append("mkfs.hfsplus is missing. Install hfsplus-tools, or pass --nomacboot") if os.getuid() != 0: diff --git a/src/sbin/lorax b/src/bin/lorax similarity index 100% rename from src/sbin/lorax rename to src/bin/lorax diff --git a/src/sbin/mkefiboot b/src/bin/mkefiboot similarity index 100% rename from src/sbin/mkefiboot rename to src/bin/mkefiboot diff --git a/src/pylorax/__init__.py b/src/pylorax/__init__.py index fe004c711..aaf4eb358 100644 --- a/src/pylorax/__init__.py +++ b/src/pylorax/__init__.py @@ -182,10 +182,6 @@ def configure(self, conf_file="/etc/lorax/lorax.conf"): if line and not line.startswith("#"): self.output.ignore(line) - # cron does not have sbin in PATH, - # so we have to add it ourselves - os.environ["PATH"] = "{0}:/sbin:/usr/sbin".format(os.environ["PATH"]) - # remove some environmental variables that can cause problems with package scripts env_remove = ('DISPLAY', 'DBUS_SESSION_BUS_ADDRESS') list(os.environ.pop(k) for k in env_remove if k in os.environ) diff --git a/src/pylorax/creator.py b/src/pylorax/creator.py index 3829c73ec..20cd0593e 100644 --- a/src/pylorax/creator.py +++ b/src/pylorax/creator.py @@ -570,7 +570,10 @@ def make_live_images(opts, work_dir, disk_img): log.debug("sys_root = %s", sys_root) # Make sure free blocks are actually zeroed so it will compress - rc = execWithRedirect("/usr/sbin/fsck.ext4", ["-y", "-f", "-E", "discard", rootfs_img]) + ext4path = shutil.which("fsck.ext4") + if not ext4path: + raise RuntimeError("Cannot find fsck.ext4 executable in PATH") + rc = execWithRedirect(ext4path, ["-y", "-f", "-E", "discard", rootfs_img]) if rc != 0: log.error("Problem zeroing free blocks of %s", disk_img) return None diff --git a/src/pylorax/ltmpl.py b/src/pylorax/ltmpl.py index 4d0bb14aa..6d3d715b2 100644 --- a/src/pylorax/ltmpl.py +++ b/src/pylorax/ltmpl.py @@ -845,7 +845,7 @@ def removefrom(self, pkg, *globs): Examples: removefrom usbutils /usr/bin/* - removefrom xfsprogs --allbut /sbin/* + removefrom xfsprogs --allbut /bin/* ''' cmd = "%s %s" % (pkg, " ".join(globs)) # save for later logging keepmatches = False diff --git a/src/pylorax/treebuilder.py b/src/pylorax/treebuilder.py index 511383dd7..505321512 100644 --- a/src/pylorax/treebuilder.py +++ b/src/pylorax/treebuilder.py @@ -25,7 +25,6 @@ from shutil import copytree, copy2 from subprocess import CalledProcessError from pathlib import Path -import itertools import libdnf5 as dnf5 from libdnf5.common import QueryCmp_EQ as EQ @@ -183,13 +182,12 @@ def verify(self): ELF_MAGIC = b'\x7fELF' - # Iterate over all files in /usr/bin and /usr/sbin + # Iterate over all files in /usr/bin + # NOTE: Fedora 42 has merged these into the same directory # For ELF files, gather them into a list and we'll check them all at # the end. For files with a #!, check them as we go elf_files = [] - usr_bin = Path(self.vars.root + '/usr/bin') - usr_sbin = Path(self.vars.root + '/usr/sbin') - for path in (str(x) for x in itertools.chain(usr_bin.iterdir(), usr_sbin.iterdir()) \ + for path in (str(x) for x in Path(self.vars.root + '/usr/bin').iterdir() \ if x.is_file()): with open(path, "rb") as f: magic = f.read(4) diff --git a/tests/lorax/test_build_bootiso.sh b/tests/lorax/test_build_bootiso.sh index 074657185..dc1e008d9 100755 --- a/tests/lorax/test_build_bootiso.sh +++ b/tests/lorax/test_build_bootiso.sh @@ -12,7 +12,7 @@ set -e . /usr/share/beakerlib/beakerlib.sh . "$(dirname $0)/lib/lib.sh" -CLI="${CLI:-./src/sbin/lorax}" +CLI="${CLI:-./src/bin/lorax}" # Make up a name (slightly unsafe), should not exist before running lorax so use -u rlJournalStart diff --git a/tests/mkksiso/test_boot_repo.sh b/tests/mkksiso/test_boot_repo.sh index b9e961730..03f970ddd 100755 --- a/tests/mkksiso/test_boot_repo.sh +++ b/tests/mkksiso/test_boot_repo.sh @@ -7,7 +7,7 @@ set -e [ "$(id -u)" -eq 0 ] || (echo "$0 must be run as root"; exit 1) . /usr/share/beakerlib/beakerlib.sh -CLI="${CLI:-./src/sbin/mkksiso}" +CLI="${CLI:-./src/bin/mkksiso}" rlJournalStart rlPhaseStartSetup "Setup repo with fake rpm" diff --git a/tests/mkksiso/test_liveimg.sh b/tests/mkksiso/test_liveimg.sh index 8fb1d0622..3e33489bc 100755 --- a/tests/mkksiso/test_liveimg.sh +++ b/tests/mkksiso/test_liveimg.sh @@ -7,7 +7,7 @@ set -e [ "$(id -u)" -eq 0 ] || (echo "$0 must be run as root"; exit 1) . /usr/share/beakerlib/beakerlib.sh -CLI="${CLI:-./src/sbin/mkksiso}" +CLI="${CLI:-./src/bin/mkksiso}" rlJournalStart rlPhaseStartSetup "Setup a fake root image" diff --git a/tests/pylorax/test_imgutils.py b/tests/pylorax/test_imgutils.py index 2d76e8025..2c4f8dfae 100644 --- a/tests/pylorax/test_imgutils.py +++ b/tests/pylorax/test_imgutils.py @@ -40,7 +40,7 @@ def mkfakerootdir(rootdir): Use this for testing the mk* functions that compress a directory tree """ - dirs = ["/root", "/usr/sbin/", "/usr/local/", "/home/bart", "/etc/"] + dirs = ["/root", "/usr/bin/", "/usr/local/", "/home/bart", "/etc/"] files = ["/etc/passwd", "/home/bart/.bashrc", "/root/.bashrc"] for d in dirs: os.makedirs(joinpaths(rootdir, d))