├── mkosi.default ├── README.md ├── .github ├── dependabot.yml └── workflows │ ├── differential-shellcheck.yml │ ├── differential-pylint.yml │ ├── build_test.yml │ └── build-fedora.sh ├── .gitignore ├── TODO ├── kernel-install └── 50-mkosi-initrd.install ├── fedora.mkosi ├── docs └── fedora.md ├── mkosi.finalize └── LICENSE.LGPL2.1 /mkosi.default: -------------------------------------------------------------------------------- 1 | fedora.mkosi -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # mkosi-initrd — Build Initrd Images Using Distro Packages 2 | 3 | This project has been merged into `mkosi` itself and is now OBSOLETE. 4 | 5 | See https://github.com/systemd/mkosi instead. 6 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | version: 2 4 | updates: 5 | - package-ecosystem: github-actions 6 | directory: / 7 | schedule: 8 | interval: monthly 9 | open-pull-requests-limit: 2 10 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.cache 2 | *.plist 3 | *.py[co] 4 | *.swp 5 | *.trs 6 | *~ 7 | .config.args 8 | .gdb_history 9 | .deps/ 10 | .mypy_cache/ 11 | __pycache__/ 12 | /*.gcda 13 | /*.gcno 14 | /*.tar.bz2 15 | /*.tar.gz 16 | /*.tar.xz 17 | /image.raw 18 | /.#image.raw.lck 19 | /image.raw.cache-pre-dev 20 | /image.raw.cache-pre-inst 21 | /install-tree 22 | /.mkosi-* 23 | /mkosi.builddir/ 24 | /mkosi.output/ 25 | /mkosi.default 26 | /mkosi.cache 27 | # Ignore any mkosi config files with "local" in the name 28 | /mkosi.default.d/**/*local*.conf 29 | /tags 30 | -------------------------------------------------------------------------------- /TODO: -------------------------------------------------------------------------------- 1 | emergency.target wants vconsole-setup.service like in dracut? 2 | 3 | shadow-utils dep in systemd.rpm 4 | 5 | Is dbus needed? Note dbus dep in systemd.rpm. 6 | 7 | Failures w/o dbus: 8 | systemd-logind 9 | systemd-homed 10 | 11 | Note: ??? 12 | 13 | selinux: convert to dlopen? Is selinux in the initramfs useful? 14 | 15 | shutdown? 16 | 17 | DNF install mount /proc 18 | 19 | Does emergency target stop sysroot.mount? It shouldn't. If we isolate 20 | on error, that would happen. But it seems we don't, just start the 21 | emergency target. 22 | -------------------------------------------------------------------------------- /.github/workflows/differential-shellcheck.yml: -------------------------------------------------------------------------------- 1 | 2 | --- 3 | # https://github.com/redhat-plumbers-in-action/differential-shellcheck#readme 4 | 5 | name: Differential ShellCheck 6 | on: 7 | pull_request: 8 | branches: [ main ] 9 | 10 | permissions: 11 | contents: read 12 | 13 | jobs: 14 | lint: 15 | runs-on: ubuntu-latest 16 | 17 | permissions: 18 | security-events: write 19 | pull-requests: write 20 | 21 | steps: 22 | - name: Repository checkout 23 | uses: actions/checkout@v4 24 | with: 25 | fetch-depth: 0 26 | 27 | - name: Differential ShellCheck 28 | uses: redhat-plumbers-in-action/differential-shellcheck@v5 29 | with: 30 | token: ${{ secrets.GITHUB_TOKEN }} 31 | -------------------------------------------------------------------------------- /.github/workflows/differential-pylint.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | name: Differential PyLint 4 | 5 | on: 6 | pull_request: 7 | branches: [ main ] 8 | 9 | permissions: 10 | contents: read 11 | 12 | jobs: 13 | lint: 14 | runs-on: ubuntu-latest 15 | 16 | permissions: 17 | security-events: write 18 | 19 | steps: 20 | - name: Repository checkout 21 | uses: actions/checkout@v4 22 | 23 | - id: PyLint 24 | name: Differential PyLint 25 | uses: fedora-copr/vcs-diff-lint-action@v1 26 | 27 | - if: ${{ always() }} 28 | name: Upload artifact with detected PyLint defects in SARIF format 29 | uses: actions/upload-artifact@v3 30 | with: 31 | name: Differential PyLint SARIF 32 | path: ${{ steps.PyLint.outputs.sarif }} 33 | 34 | - if: ${{ always() }} 35 | name: Upload SARIF to GitHub using github/codeql-action/upload-sarif 36 | uses: github/codeql-action/upload-sarif@v3 37 | with: 38 | sarif_file: ${{ steps.PyLint.outputs.sarif }} 39 | -------------------------------------------------------------------------------- /kernel-install/50-mkosi-initrd.install: -------------------------------------------------------------------------------- 1 | #!/usr/bin/bash 2 | # SPDX-License-Identifier: LGPL-2.1-or-later 3 | set -e 4 | export LANG=C 5 | 6 | COMMAND="$1" 7 | KERNEL_VERSION="$2" 8 | BOOT_DIR_ABS="$3" 9 | KERNEL_IMAGE="$4" 10 | INITRD_OPTIONS_SHIFT=4 11 | 12 | # Skip this plugin if we're using a different generator. 13 | [ "${KERNEL_INSTALL_INITRD_GENERATOR:-mkosi-initrd}" != "mkosi-initrd" ] && exit 0 14 | 15 | : "${KERNEL_INSTALL_STAGING_AREA:?}" 16 | 17 | case "$COMMAND" in 18 | add) 19 | # If the initrd was provided on the kernel command line, we shouldn't generate our own. 20 | [ "$#" -gt "$INITRD_OPTIONS_SHIFT" ] && exit 0 21 | 22 | BUILD_DIR=$(mktemp -d -p /var/tmp) 23 | ( 24 | [ "$KERNEL_INSTALL_VERBOSE" -gt 0 ] && set -x 25 | cd "$BUILD_DIR" 26 | 27 | mkosi --default /usr/lib/mkosi-initrd/fedora.mkosi \ 28 | --finalize-script=/usr/lib/mkosi-initrd/mkosi.finalize \ 29 | --image-version="$KERNEL_VERSION" \ 30 | --environment=KERNEL_VERSION="$KERNEL_VERSION" \ 31 | -o "${KERNEL_INSTALL_STAGING_AREA}/initrd" 32 | rm -rf "$BUILD_DIR" 33 | ) 34 | ;; 35 | 36 | remove) 37 | ;; 38 | esac 39 | exit 0 40 | -------------------------------------------------------------------------------- /fedora.mkosi: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: LGPL-2.1-or-later 2 | 3 | [Distribution] 4 | # Distribution=fedora 5 | # Release=34 6 | 7 | [Output] 8 | ImageId=initrd 9 | Format=cpio 10 | ManifestFormat= 11 | Compress=zstd 12 | 13 | # This will create the cache and output directories if they aren't already in place 14 | Cache=mkosi.cache 15 | 16 | [Content] 17 | BasePackages=conditional 18 | Packages= 19 | systemd # sine qua non 20 | systemd-udev 21 | 22 | # File system checkers for supported root file systems 23 | /usr/sbin/fsck.ext4 24 | /usr/sbin/fsck.xfs 25 | 26 | # fsck.btrfs is a dummy, checking is done in the kernel. 27 | 28 | bash # for emergency logins 29 | 30 | less # this makes 'systemctl' much nicer to use ;) 31 | 32 | # Hardware support 33 | lvm2 34 | 35 | # Various libraries that are dlopen'ed by cryptsetup and pcrphase services 36 | libfido2 37 | p11-kit 38 | tpm2-tss 39 | 40 | RemovePackages= 41 | # Various packages pull shadow-utils to create users 42 | shadow-utils 43 | 44 | # Dropping those will require getting rid of deps in systemd and possibly other packages 45 | # setup 46 | # fedora-release 47 | 48 | RemoveFiles= 49 | # we don't need this after the binary catalogs have been built 50 | /usr/lib/systemd/catalog 51 | /etc/udev/hwdb.d 52 | /usr/lib/udev/hwdb.d 53 | -------------------------------------------------------------------------------- /.github/workflows/build_test.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # SPDX-License-Identifier: LGPL-2.1-or-later 3 | # vi: ts=2 sw=2 et: 4 | 5 | name: Build & boot test 6 | on: 7 | push: 8 | branches: 9 | - main 10 | paths-ignore: 11 | - 'docs/**' 12 | - 'README*' 13 | - 'TODO' 14 | pull_request: 15 | branches: 16 | - main 17 | paths-ignore: 18 | - 'docs/**' 19 | - 'README*' 20 | - 'TODO' 21 | 22 | jobs: 23 | build: 24 | runs-on: ubuntu-22.04 25 | concurrency: 26 | group: ${{ github.workflow }}-${{ toJSON(matrix.distro) }}-${{ matrix.phase }}-${{ github.ref }} 27 | cancel-in-progress: true 28 | strategy: 29 | fail-fast: false 30 | matrix: 31 | distro: 32 | - {name: fedora, tag: rawhide } 33 | phase: 34 | - INITRD_BASIC 35 | - INITRD_LVM 36 | - INITRD_LUKS 37 | - INITRD_LUKS_LVM 38 | #- INITRD_ISCSI # iSCSI is missing a generator 39 | - SYSEXT 40 | container: 41 | image: "${{ matrix.distro.name }}:${{ matrix.distro.tag }}" 42 | options: --privileged 43 | # We need to have directories which mkosi uses for its overlayfs on a 44 | # "real" filesystem (not an overlayfs), since we can't nest read/write 45 | # layers. Also, it can't be tmpfs, since generating sysext images uses 46 | # user xattrs. And to correctly propagate loop devices/partitions 47 | # between the container and the host we need to explicitly mount host's 48 | # /dev into the container. 49 | volumes: ["/var/tmp:/var/tmp", "/dev:/dev"] 50 | steps: 51 | - name: Repository checkout 52 | uses: actions/checkout@v4 53 | 54 | - name: Install dependencies 55 | run: ./.github/workflows/build-${{ matrix.distro.name }}.sh DEPS 56 | 57 | - name: ${{ matrix.phase }} on ${{ matrix.distro.name }}:${{ matrix.distro.tag }} 58 | run: ./.github/workflows/build-${{ matrix.distro.name }}.sh ${{ matrix.phase }} 59 | -------------------------------------------------------------------------------- /docs/fedora.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Using mkosi-initrd with Fedora 3 | SPDX-License-Identifier: LGPL-2.1-or-later 4 | --- 5 | 6 | # Building an initramfs image 7 | 8 | Some tools are required: `cpio`, `zstd`, a development version of 9 | `mkosi` from git, and the `mkosi-initrd` repository with configuration 10 | for `mkosi`. 11 | 12 | ```bash 13 | sudo dnf install zstd cpio 14 | git clone https://github.com/systemd/mkosi 15 | git clone https://github.com/systemd/mkosi-initrd 16 | cd mkosi-initrd 17 | ``` 18 | 19 | The initrd is built for a specific kernel version. 20 | `kernel-core.rpm` has the modules that we want, 21 | but also the `vmlinuz` image, which we don't want. 22 | To avoid the installation of the big package, and the additional dependencies, 23 | and the scriptlets that try to call `kernel-install`, 24 | we extract the modules from the package ourselves. 25 | This rpm needs to be downloaded. 26 | We pass `KERNEL_VERSION=…` to tell the scripts what version to install. 27 | 28 | ```bash 29 | KVER=`uname -r` 30 | sudo ../mkosi/bin/mkosi --config fedora.mkosi -f --image-version=$KVER --environment=KERNEL_VERSION=$KVER 31 | ``` 32 | 33 | This should produce an image that is about 60 MB: 34 | 35 | ```console 36 | $ KVER=5.14.9-300.fc35.x86_64 37 | $ sudo mkosi --config fedora.mkosi -f -o initrd-$KVER.cpio.zst --environment=KERNEL_VERSION=$KVER 38 | ‣ Removing output files… 39 | ‣ Detaching namespace 40 | ‣ Setting up temporary workspace. 41 | ‣ Temporary workspace set up in /var/tmp/mkosi-k3j2xmzy 42 | ‣ Running second (final) stage… 43 | ‣ Mounting image… 44 | ‣ Setting up basic OS tree… 45 | ‣ Mounting Package Cache 46 | ‣ Installing Fedora Linux… 47 | ‣ Mounting API VFS 48 | Fedora 35 - base 15 kB/s | 15 kB 00:01 49 | Fedora 35 - base 548 kB/s | 2.7 MB 00:05 50 | Fedora 35 - updates 23 kB/s | 25 kB 00:01 51 | Dependencies resolved. 52 | ======================================================================= 53 | Package Architecture Version Repository Size 54 | ======================================================================= 55 | Installing: 56 | bash x86_64 5.1.8-2.fc35 fedora 1.7 M 57 | e2fsprogs x86_64 1.46.3-1.fc35 fedora 1.0 M 58 | less x86_64 590-1.fc35 fedora 160 k 59 | lvm2 x86_64 2.03.11-6.fc35 fedora 1.4 M 60 | systemd x86_64 249.4-2.fc35 fedora 4.2 M 61 | systemd-udev x86_64 249.4-2.fc35 fedora 1.5 M 62 | xfsprogs x86_64 5.12.0-2.fc35 fedora 1.0 M 63 | Installing dependencies: 64 | ... 65 | Transaction Summary 66 | ======================================================================= 67 | Install 114 Packages 68 | 69 | Total size: 42 M 70 | Installed size: 135 M 71 | Downloading Packages: 72 | ... 73 | Complete! 74 | ‣ Unmounting API VFS 75 | ‣ Unmounting Package Cache 76 | ‣ Removing 7 packages… 77 | ‣ Mounting API VFS 78 | Dependencies resolved. 79 | ======================================================================= 80 | Package Architecture Version Repository Size 81 | ======================================================================= 82 | Removing: 83 | shadow-utils x86_64 2:4.9-3.fc35 @fedora 3.7 M 84 | Removing unused dependencies: 85 | libsemanage x86_64 3.2-4.fc35 @fedora 297 k 86 | 87 | Transaction Summary 88 | ======================================================================= 89 | Remove 2 Packages 90 | 91 | Freed space: 3.9 M 92 | ... 93 | Complete! 94 | ‣ Unmounting API VFS 95 | ‣ Recording packages in manifest… 96 | ‣ Cleaning dnf metadata… 97 | ‣ Cleaning rpm metadata… 98 | ‣ Removing files… 99 | ‣ Resetting machine ID 100 | ‣ Removing random seed 101 | ‣ Running finalize script… 102 | Setting up for kernel 5.14.9-300.fc35.x86_64 103 | ... 104 | Writing /var/tmp/mkosi-k3j2xmzy/root/etc/initrd-release with PRETTY_NAME='Fedora Linux 35 (Thirty Five) (mkosi-initrd)' 105 | Symlinked /var/tmp/mkosi-k3j2xmzy/root/init → usr/lib/systemd/systemd 106 | Created /var/tmp/mkosi-k3j2xmzy/root/sysroot 107 | Symlinked /var/tmp/mkosi-k3j2xmzy/root/etc/systemd/system/emergency.service → debug-shell.service 108 | Created symlink /var/tmp/mkosi-k3j2xmzy/root/etc/systemd/system/initrd-udevadm-cleanup-db.service → /dev/null. 109 | ‣ Unmounting image 110 | ‣ Creating archive… 111 | ‣ Linking image file… 112 | ‣ Changing ownership of output file mkosi.output/initrd_5.14.9-300.fc35.x86_64.cpio.zst to user … (acquired from sudo)… 113 | ‣ Changed ownership of mkosi.output/initrd_5.14.9-300.fc35.x86_64.cpio.zst 114 | ‣ Linked mkosi.output/initrd_5.14.9-300.fc35.x86_64.cpio.zst 115 | ‣ Saving manifest mkosi.output/initrd_5.14.9-300.fc35.x86_64.cpio.zst.manifest 116 | ‣ Changing ownership of output file mkosi.output/initrd_5.14.9-300.fc35.x86_64.cpio.zst.manifest to user … (acquired from sudo)… 117 | ‣ Changed ownership of mkosi.output/initrd_5.14.9-300.fc35.x86_64.cpio.zst.manifest 118 | ‣ Saving report mkosi.output/initrd_5.14.9-300.fc35.x86_64.cpio.zst.changelog 119 | ‣ Changing ownership of output file mkosi.output/initrd_5.14.9-300.fc35.x86_64.cpio.zst.changelog to user … (acquired from sudo)… 120 | ‣ Changed ownership of mkosi.output/initrd_5.14.9-300.fc35.x86_64.cpio.zst.changelog 121 | ‣ Resulting image size is 54.7M, consumes 54.7M. 122 | ``` 123 | 124 | Hint: on repeated runs, it may be useful to add `--with-network=never` if no new packages need to be downloaded. 125 | 126 | # Installing the initramfs image 127 | 128 | ## UEFI 129 | 130 | The output image `mkosi.output/initrd_$KVER.cpio.zst` needs to be installed as 131 | `/boot/efi/$(cat /etc/machine-id)/$KVER/initrd` . 132 | `bootctl list` can be used verify the status. 133 | 134 | ## Non-EFI 135 | 136 | ``` 137 | cp mkosi.output/initrd_$KVER.cpio.zst /boot/ 138 | grubby --copy-default --add-kernel=/boot/vmlinuz-$KVER --initrd=/boot/initrd_$KVER.cpio.zst --title="experimental-$KVER" --make-default 139 | ``` 140 | 141 | # Building system extension images 142 | 143 | First we need to create a version of the initrd image that includes the package metadata: 144 | 145 | ```bash 146 | sudo mkosi --config fedora.mkosi -f \ 147 | --image-version=$KVER \ 148 | --environment=KERNEL_VERSION=$KVER \ 149 | --format=directory --clean-package-metadata=no 150 | ``` 151 | 152 | Once that's done, we can build a sysext: 153 | ```bash 154 | sudo mkosi --config fedora.mkosi -f \ 155 | --image-version=$KVER-ssh \ 156 | --base-image=mkosi.output/initrd_$KVER \ 157 | --format=gpt_squashfs --environment=SYSEXT=initrd-$KVER-ssh \ 158 | --package='!*,openssh-server' 159 | ``` 160 | 161 | This should produce an image that is about 1 MB: 162 | 163 | ```console 164 | $ sudo mkosi --config fedora.mkosi -f \ 165 | --image-version=$KVER \ 166 | --environment=KERNEL_VERSION=$KVER \ 167 | --format=directory --clean-package-metadata=no 168 | ... 169 | ‣ Linked mkosi.output/initrd_5.14.9-300.fc35.x86_64 170 | ‣ Resulting image size is 151.2M. 171 | 172 | $ sudo mkosi --config fedora.mkosi -f --image-version=$KVER-ssh \ 173 | --base-image=mkosi.output/initrd_$KVER \ 174 | --format=gpt_squashfs --environment=SYSEXT=initrd_$KVER-ssh \ 175 | --package='!*,openssh-server' 176 | ... 177 | ‣ Installing Fedora Linux… 178 | ‣ Mounting API VFS 179 | Fedora 35 - base 1.3 kB/s | 15 kB 00:12 180 | Fedora 35 - updates 37 kB/s | 25 kB 00:00 181 | Dependencies resolved. 182 | ====================================================================== 183 | Package Architecture Version Repository Size 184 | ====================================================================== 185 | Installing: 186 | openssh-server x86_64 8.7p1-2.fc35 fedora 451 k 187 | Installing dependencies: 188 | libsemanage x86_64 3.2-4.fc35 fedora 116 k 189 | openssh x86_64 8.7p1-2.fc35 fedora 451 k 190 | shadow-utils x86_64 2:4.9-3.fc35 fedora 1.1 M 191 | 192 | Transaction Summary 193 | ====================================================================== 194 | Install 4 Packages 195 | 196 | Total size: 2.1 M 197 | Installed size: 6.9 M 198 | ... 199 | ‣ Resetting machine ID 200 | ‣ Running finalize script… 201 | Writing /var/tmp/mkosi-g8wqud3n/root/usr/lib/extension-release.d/extension-release.initrd_5.14.9-300.fc35.x86_64-ssh with NAME='initrd_5.14.9-300.fc35.x86_64-ssh' 202 | ‣ Cleaning up overlayfs 203 | ‣ Removing overlay whiteout files… 204 | ‣ Unmounting image 205 | ‣ Creating squashfs file system… 206 | Parallel mksquashfs: Using 4 processors 207 | Creating 4.0 filesystem on /home/zbyszek/src/mkosi-initrd/mkosi.output/.mkosi-squashfsnd45at4h, block size 131072. 208 | ... 209 | ‣ Inserting generated root partition… 210 | ‣ Resizing disk image to 808.0K 211 | ‣ Inserting partition of 768.0K... 212 | ... 213 | ‣ Linked mkosi.output/initrd_5.14.9-300.fc35.x86_64-ssh.raw 214 | ‣ Resulting image size is 808.0K, consumes 776.0K. 215 | ``` 216 | 217 | Note: systemd will refuse to load the sysext image if the name is changed 218 | and doesn't match the string `extension-release.initrd_5.14.9-300.fc35.x86_64-ssh` embedded in the image. 219 | It also doesn't follow symlinks. 220 | 221 | ```console 222 | $ sudo systemd-dissect mkosi.output/initrd_5.14.9-300.fc35.x86_64-ssh.raw 223 | Name: initrd_5.14.9-300.fc35.x86_64-ssh.raw 224 | Size: 808.0K 225 | 226 | Extension Release: NAME=initrd_5.14.9-300.fc35.x86_64-ssh 227 | ID=fedora 228 | VERSION_ID=35 229 | PLATFORM_ID=platform:f35 230 | HOME_URL=https://fedoraproject.org/ 231 | DOCUMENTATION_URL=https://docs.fedoraproject.org/en-US/fedora/f35/system-administrators-guide/ 232 | SUPPORT_URL=https://ask.fedoraproject.org/ 233 | BUG_REPORT_URL=https://bugzilla.redhat.com/ 234 | PRIVACY_POLICY_URL=https://fedoraproject.org/wiki/Legal:PrivacyPolicy 235 | 236 | RW DESIGNATOR PARTITION UUID PARTITION LABEL FSTYPE ARCHITECTURE VERITY GROWFS NODE PARTNO 237 | ro root cc911d05-9aca-8c44-bd81-52c5d1783d8c Root Partition squashfs x86-64 no no /dev/loop2p1 1 238 | ``` 239 | 240 | # Verity and signatures 241 | 242 | TODO: TBD 243 | -------------------------------------------------------------------------------- /mkosi.finalize: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # SPDX-License-Identifier: LGPL-2.1-or-later 3 | 4 | import ast 5 | import fnmatch 6 | import functools 7 | import os 8 | import pathlib 9 | import re 10 | import shutil 11 | import subprocess 12 | import sys 13 | import xattr 14 | 15 | def dictify(f): 16 | def wrapper(*args, **kwargs): 17 | return dict(f(*args, **kwargs)) 18 | return functools.update_wrapper(wrapper, f) 19 | 20 | def buildroot(): 21 | return pathlib.Path(os.getenv('BUILDROOT')) 22 | 23 | def copy_path(oldpath, newpath, should_skip): 24 | newpath.mkdir(exist_ok=True) 25 | 26 | for entry in os.scandir(oldpath): 27 | if should_skip(entry.path): 28 | print(f'Not copying {entry.path}') 29 | 30 | newentry = newpath / entry.name 31 | if entry.is_dir(follow_symlinks=False): 32 | copy_path(entry.path, newentry, should_skip) 33 | elif entry.is_symlink(): 34 | target = os.readlink(entry.path) 35 | newentry.symlink_to(target) 36 | shutil.copystat(entry.path, newentry, follow_symlinks=False) 37 | else: 38 | shutil.copy2(entry.path, newentry, follow_symlinks=False) 39 | 40 | shutil.copystat(oldpath, newpath, follow_symlinks=True) 41 | 42 | def kernel_core_skip_file(path): 43 | patterns = ('*/bls.conf', 44 | '*/vmlinuz', 45 | '*/doc/*', 46 | '/boot/*') 47 | 48 | return any(fnmatch.fnmatch(path, pat) 49 | for pat in patterns) 50 | 51 | def copy_in_modules_from_rpmls(root, kver, modules_rpm): 52 | rpm = f'{modules_rpm}-{kver}' 53 | try: 54 | out = subprocess.check_output(['rpm', '-ql', rpm], text=True) 55 | except (FileNotFoundError, subprocess.CalledProcessError) as e: 56 | print(f'Cannot query file list of {rpm}:', e) 57 | return False 58 | 59 | files = out.splitlines() 60 | installed, skipped = 0, 0 61 | for file in files: 62 | if kernel_core_skip_file(file): 63 | skipped += 1 64 | continue 65 | if pathlib.Path(file).is_dir(): 66 | continue 67 | 68 | dest = root / file[1:] 69 | dest.parent.mkdir(parents=True, exist_ok=True) 70 | shutil.copy2(file, dest, follow_symlinks=False) 71 | installed += 1 72 | 73 | print(f'Installed {installed}/{installed + skipped} files from {rpm}') 74 | return True 75 | 76 | def copy_in_modules_from_fs(root, kver): 77 | source = f'/usr/lib/modules/{kver}' 78 | if not os.path.exists(source + '/kernel'): 79 | return False 80 | 81 | copy_path(pathlib.Path(source), 82 | root / source[1:], 83 | kernel_core_skip_file) 84 | print(f'Copied files from {source}') 85 | return True 86 | 87 | def copy_in_modules_from_cpio(root, kver, modules_rpm): 88 | file_filter = ['--nonmatching', 89 | './lib/modules/*/bls.conf', # a grub abomination with $grub_variables 90 | './lib/modules/*/vmlinuz'] 91 | 92 | path = pathlib.Path(sys.argv[0]).parent 93 | file = path / f'{modules_rpm}-{kver}.rpm' 94 | 95 | if not file.exists(): 96 | print(f'{file} not found, downloading.') 97 | 98 | subprocess.run(['dnf', 'download', f'--downloaddir={file.parent}', 99 | file.with_suffix('').name], 100 | check=True) 101 | 102 | with subprocess.Popen(['rpm2cpio', file], stdout=subprocess.PIPE) as archive: 103 | subprocess.run(['cpio', '-i', '--make-directories', '--quiet', '-D', root, *file_filter], 104 | stdin=archive.stdout, 105 | check=True) 106 | 107 | print(f'Unpacked files from {file}') 108 | return True 109 | 110 | def copy_in_modules_kver(root, kver): 111 | print(f'Installing modules for kernel {kver}') 112 | 113 | res = subprocess.check_output(['rpm', '--eval', f'%[v"{kver}" >= v"6.2.0"]'], 114 | text=True) 115 | good = res.strip() == '1' 116 | modules_rpm = 'kernel-modules-core' if good else 'kernel-core' 117 | 118 | copy_in_modules_from_rpmls(root, kver, modules_rpm) or \ 119 | copy_in_modules_from_fs(root, kver) or \ 120 | copy_in_modules_from_cpio(root, kver, modules_rpm) 121 | 122 | subprocess.run(['depmod', '-a', '-w', '-b', root, kver], check=True) 123 | 124 | def copy_in_modules(root): 125 | # This part is pretty ugly. The kernel package provides the following subpackages: 126 | # kernel — empty metapackage 127 | # kernel-core — /boot/vmlinuz- (%ghost?) and /lib/modules//vmlinuz, 128 | # kernel-modules-core — a bunch of basic modules 129 | # (k-m-c was split out in 6.2.0 out of kernel-core.) 130 | # kernel-modules — more modules (drivers) 131 | # kernel-modules-extra — more modules ("less commonly used drivers") 132 | # kernel-modules-internal — "kernel modules for the kernel package for Red Hat internal usage" 133 | # (netdevsim, rcutorture…) 134 | # 135 | # This script requires kernel-[modules-]core)-.rpm to be present in $CWD. 136 | 137 | try: 138 | kver = os.environ['KERNEL_VERSION'] 139 | except KeyError: 140 | kver = os.uname().release 141 | print(f'$KERNEL_VERSION not defined, using {kver}') 142 | 143 | copy_in_modules_kver(root, kver) 144 | 145 | @dictify 146 | def read_os_release(root): 147 | try: 148 | f = root.joinpath('etc/os-release').open() 149 | except FileNotFoundError: 150 | f = root.joinpath('usr/lib/os-release').open() 151 | 152 | for line_number, line in enumerate(f, start=1): 153 | if not line.strip() or line.startswith('#'): 154 | continue 155 | if m := re.match(r'([A-Z][A-Z_0-9]+)=(.*)', line): 156 | name, val = m.groups() 157 | if val and val[0] in '"\'': 158 | val = ast.literal_eval(val) 159 | yield name, val 160 | else: 161 | print(f'Bad line {line_number}: {line}', file=sys.stderr) 162 | 163 | def update_suffixed(items, name, fallback): 164 | value = items.get(name, fallback) 165 | if 'mkosi-initrd' in value: 166 | return 167 | items[name] = value + ' (mkosi-initrd)' 168 | 169 | def make_initrd_release(root, out): 170 | os_release = read_os_release(root) 171 | 172 | # Replacing fields in the original dictionary should maintain the order 173 | update_suffixed(os_release, 'NAME', 'Linux') 174 | update_suffixed(os_release, 'PRETTY_NAME', 'Linux') 175 | os_release['VARIANT'] = 'mkosi-initrd' 176 | os_release['VARIANT_ID'] = 'mkosi-initrd' 177 | 178 | for name, value in os_release.items(): 179 | if value: 180 | print(f'{name}={value!r}', file=out) 181 | 182 | print(f'Writing {out.name} with PRETTY_NAME={os_release["PRETTY_NAME"]!r}') 183 | 184 | def make_sysext_release(root, sysext_name, out): 185 | os_release = read_os_release(root) 186 | 187 | sysext = { 188 | 'NAME': sysext_name, 189 | 'SYSEXT_SCOPE': 'initrd', 190 | } 191 | for field in ('ID', 192 | 'VERSION_ID', 193 | 'VERSION_CODENAME', 194 | 'PLATFORM_ID', 195 | 'SYSEXT_LEVEL', 196 | 197 | 'HOME_URL', 198 | 'DOCUMENTATION_URL', 199 | 'SUPPORT_URL', 200 | 'BUG_REPORT_URL', 201 | 'PRIVACY_POLICY_URL'): 202 | if value := os_release.get(field): 203 | sysext[field] = value 204 | 205 | for name, value in sysext.items(): 206 | print(f'{name}={value!r}', file=out) 207 | 208 | print(f'Writing {out.name} with NAME={sysext["NAME"]!r}') 209 | 210 | def write_initrd_release(root): 211 | output = root / 'etc/initrd-release' 212 | output.unlink(missing_ok=True) 213 | 214 | with output.open('wt') as out: 215 | make_initrd_release(root, out) 216 | 217 | root.joinpath('etc/os-release').unlink(missing_ok=True) 218 | root.joinpath('usr/lib/os-release').unlink(missing_ok=True) 219 | 220 | root.joinpath('etc/os-release').symlink_to(output.name) 221 | 222 | def write_sysext_release(root, sysext_name): 223 | output = root / f"usr/lib/extension-release.d/extension-release.{sysext_name}" 224 | output.parent.mkdir(exist_ok=True) 225 | 226 | with output.open('wt') as out: 227 | make_sysext_release(root, sysext_name, out) 228 | 229 | print('Setting user.extension-release.strict=0 on the extension-release file') 230 | xattr.set(output, 'user.extension-release.strict', '0') 231 | 232 | def make_init_symlink(root): 233 | init = root / 'init' 234 | init.unlink(missing_ok=True) 235 | init.symlink_to('usr/lib/systemd/systemd') 236 | print(f'Symlinked {init} → usr/lib/systemd/systemd') 237 | 238 | def make_sysroot_dir(root): 239 | sysroot = root / 'sysroot' 240 | sysroot.mkdir(mode=0o755, exist_ok=True) 241 | print(f'Created {sysroot}') 242 | 243 | def make_debug_shell_emergency(root): 244 | unit = root / 'etc/systemd/system/emergency.service' 245 | unit.unlink(missing_ok=True) 246 | unit.symlink_to('debug-shell.service') 247 | print(f'Symlinked {unit} → debug-shell.service') 248 | 249 | def mask_units(root): 250 | units = [ 251 | # Dracut installs a rule which sets OPTIONS+="db_persist" on all dm devices [1] 252 | # (According to codesearch.debian.net, it is the only user of db_persist.) 253 | # Without this, all dm units end up with SYSTEMD_READY=0 and systemd thinks the 254 | # device units are missing. The system boots fine, but an attempt to call 255 | # daemon-reexec or daemon-reload ends with anything that can be stopped or unmounted 256 | # being purged. 257 | # 258 | # In systemd, we always have cleaned the database on switch-root, since the initial 259 | # addition of the initrd-* units in cf843477946451fabf9b5d17eec8ec81515057b6. But 260 | # that seems pointless, since initrds need to match the kernel version and are 261 | # generally used with the main system in the same version or slightly newer. And 262 | # for important devices, db_persist is set. So we end up destroying some of the 263 | # state, but not all. Let's just skip the cleanup altogether, and rely on the rules 264 | # being idempotent so that we end up in the correct state. 265 | # 266 | # [1] https://raw.githubusercontent.com/dracutdevs/dracut/2d83bce21bfc874b29c1fb99e8fabb843f038725/modules.d/90dm/11-dm.rules 267 | 'initrd-udevadm-cleanup-db.service', 268 | ] 269 | 270 | subprocess.run(['systemctl', f'--root={root}', 'mask', *units], check=True) 271 | 272 | def remove_non_sysext_files(root): 273 | var = root / "var" 274 | if var.exists(): 275 | shutil.rmtree(var) 276 | 277 | etc = root / "etc" 278 | if etc.exists(): 279 | # from mkosi import find_files 280 | # for path in find_files(etc): 281 | # print(f'WARNING: configuration file: {path}') 282 | # … This doesn't work because we also see files from the lower layer 283 | 284 | shutil.rmtree(etc) 285 | 286 | 287 | def do_initrd(root): 288 | copy_in_modules(root) 289 | 290 | write_initrd_release(root) 291 | 292 | make_init_symlink(root) 293 | make_sysroot_dir(root) 294 | 295 | make_debug_shell_emergency(root) 296 | 297 | mask_units(root) 298 | 299 | def do_sysext(root, sysext_name): 300 | write_sysext_release(root, sysext_name) 301 | remove_non_sysext_files(root) 302 | 303 | def main(argv): 304 | if argv[1] != 'final': 305 | sys.exit(0) 306 | 307 | root = buildroot() 308 | 309 | sysext = os.getenv('SYSEXT') 310 | if sysext: 311 | do_sysext(root, sysext) 312 | else: 313 | do_initrd(root) 314 | 315 | if __name__ == '__main__': 316 | main(sys.argv) 317 | -------------------------------------------------------------------------------- /.github/workflows/build-fedora.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -eux 4 | set -o pipefail 5 | 6 | # shellcheck disable=SC2206 7 | PHASES=(${@:-DEPS INITRD_BASIC}) 8 | SYSTEMD_LOG_OPTS="systemd.log_target=console udev.log_level=info systemd.default_standard_output=journal+console systemd.status_unit_format=name" 9 | MKOSI_CACHE="/var/tmp/mkosiinitrd$(/dev/null; then 28 | # Can't use 'uname -r', since we're in a container 29 | KVER="$(sed 1q <(rpm -q kernel-core --qf "%{version}-%{release}.%{arch}\n" | sort -Vr))" 30 | fi 31 | 32 | for phase in "${PHASES[@]}"; do 33 | case "$phase" in 34 | DEPS) 35 | echo "Installing necessary dependencies" 36 | dnf -y install \ 37 | cryptsetup \ 38 | dnf-plugins-core \ 39 | dnsmasq \ 40 | e2fsprogs \ 41 | iproute \ 42 | jq \ 43 | kernel-core \ 44 | lvm2 \ 45 | mkosi \ 46 | python3-pyxattr \ 47 | qemu-kvm \ 48 | scsi-target-utils \ 49 | systemd \ 50 | util-linux \ 51 | zstd 52 | ;; 53 | INITRD_BASIC) 54 | INITRD="initrd_$KVER.cpio.zstd" 55 | # Build a basic initrd 56 | mkosi --cache "$MKOSI_CACHE" \ 57 | --default fedora.mkosi \ 58 | --image-version="$KVER" \ 59 | --environment=KERNEL_VERSION="$KVER" \ 60 | --output="$INITRD" \ 61 | -f build 62 | # Check if the image was indeed generated 63 | stat "$INITRD" 64 | 65 | # Build a basic OS image to test the initrd with 66 | rm -fr _rootfs 67 | mkdir _rootfs 68 | pushd _rootfs 69 | # shellcheck source=/dev/null 70 | source <(grep -E "(ID|VERSION_ID)" /etc/os-release) 71 | mkosi --cache "$MKOSI_CACHE" \ 72 | --distribution="$ID" \ 73 | --release="$VERSION_ID" \ 74 | --format=gpt_btrfs \ 75 | --output=rootfs.img 76 | popd 77 | 78 | # Sanity check if the initrd is bootable 79 | timeout --foreground -k 10 5m \ 80 | qemu-kvm -m 512 -smp "$(nproc)" -nographic \ 81 | -initrd "$INITRD" \ 82 | -kernel "/usr/lib/modules/$KVER/vmlinuz" \ 83 | -append "rd.systemd.unit=systemd-poweroff.service rd.debug $SYSTEMD_LOG_OPTS console=ttyS0" 84 | 85 | # Boot the initrd with an OS image 86 | timeout --foreground -k 10 5m \ 87 | qemu-kvm -m 1024 -smp "$(nproc)" -nographic \ 88 | -initrd "$INITRD" \ 89 | -kernel "/usr/lib/modules/$KVER/vmlinuz" \ 90 | -drive "format=raw,cache=unsafe,file=_rootfs/rootfs.img" \ 91 | -append "root=LABEL=root rd.debug $SYSTEMD_LOG_OPTS console=ttyS0 systemd.unit=systemd-poweroff.service systemd.default_timeout_start_sec=240" 92 | 93 | # Cleanup 94 | rm -fr _rootfs "$INITRD" 95 | ;; 96 | INITRD_LVM) 97 | # Build the initrd with LVM support 98 | INITRD="initrd_$KVER.cpio.zstd" 99 | mkosi --cache "$MKOSI_CACHE" \ 100 | --default fedora.mkosi \ 101 | --package="lvm2" \ 102 | --image-version="$KVER" \ 103 | --environment=KERNEL_VERSION="$KVER" \ 104 | --output="$INITRD" \ 105 | -f build 106 | ## Check if the image was indeed generated 107 | stat "$INITRD" 108 | 109 | # Build a basic LVM image to test the initrd with 110 | rm -fr _rootfs 111 | mkdir _rootfs 112 | pushd _rootfs 113 | 114 | # Create the base LVM layout with an ext4 rootfs 115 | dd if=/dev/zero of=rootfs.img bs=1M count=3000 116 | lodev="$(losetup --show -f -P rootfs.img)" 117 | echo "type=E6D6D379-F507-44C2-A23C-238F2A3DF928 bootable" | sfdisk -X gpt "$lodev" 118 | lvm pvcreate "${lodev}p1" 119 | lvm pvs 120 | lvm vgcreate "vg_root" "${lodev}p1" 121 | lvm vgchange -ay "vg_root" 122 | lvm vgs 123 | # Note: we need to create the LV as "deactivated" (-an) and activate it 124 | # separately later as a workaround since we're running in a container 125 | lvm lvcreate -an -l 100%FREE -n lv0 "vg_root" 126 | lvm lvchange -ay "vg_root" 127 | lvm lvs 128 | wait_for_dev /dev/vg_root/lv0 129 | mkfs.ext4 -L "root" /dev/vg_root/lv0 130 | 131 | # Populate the rootfs with a basic OS image 132 | mkdir mnt 133 | mount /dev/vg_root/lv0 mnt 134 | # shellcheck source=/dev/null 135 | source <(grep -E "(ID|VERSION_ID)" /etc/os-release) 136 | mkosi --cache "$MKOSI_CACHE" \ 137 | --distribution="$ID" \ 138 | --release="$VERSION_ID" \ 139 | --format=directory \ 140 | --output=out 141 | # Note: this is necessary, since mkosi requires the target directory 142 | # to not exist and we don't want it to remove the mnt mountpoint 143 | (shopt -s dotglob && mv out/* mnt/) 144 | # Wrap up the LVM image 145 | umount mnt 146 | vgchange -an "vg_root" 147 | losetup -d "$lodev" 148 | popd 149 | 150 | # Boot the initrd with an OS image 151 | timeout --foreground -k 10 5m \ 152 | qemu-kvm -m 1024 -smp "$(nproc)" -nographic \ 153 | -initrd "$INITRD" \ 154 | -kernel "/usr/lib/modules/$KVER/vmlinuz" \ 155 | -drive "format=raw,cache=unsafe,file=_rootfs/rootfs.img" \ 156 | -append "root=LABEL=root rd.debug $SYSTEMD_LOG_OPTS console=ttyS0 systemd.unit=systemd-poweroff.service systemd.default_timeout_start_sec=240" 157 | 158 | # Cleanup 159 | rm -fr _rootfs "$INITRD" 160 | ;; 161 | INITRD_LUKS) 162 | rm -fr mkosi.extra 163 | mkdir mkosi.extra 164 | 165 | luks_passphrase="H3lloW0rld!" 166 | # Instruct mkosi to copy the password file into the initrd image 167 | # so we can use it to unlock the rootfs 168 | echo -ne "$luks_passphrase" >mkosi.extra/luks.passphrase 169 | INITRD="initrd_$KVER.cpio.zstd" 170 | # Build the initrd with dm-crypt support 171 | mkosi --cache "$MKOSI_CACHE" \ 172 | --default fedora.mkosi \ 173 | --package="cryptsetup" \ 174 | --image-version="$KVER" \ 175 | --environment=KERNEL_VERSION="$KVER" \ 176 | --output="$INITRD" \ 177 | -f build 178 | # Check if the image was indeed generated 179 | stat "$INITRD" 180 | 181 | # Build a basic LUKS encrypted OS image to test the initrd with 182 | # Passphrase is provided by the mkosi.passphrase file created above 183 | rm -fr _rootfs mkosi.extra 184 | mkdir _rootfs 185 | pushd _rootfs 186 | # Create a LUKS password file for mkosi 187 | echo -ne "$luks_passphrase" >mkosi.passphrase 188 | # shellcheck source=/dev/null 189 | source <(grep -E "(ID|VERSION_ID)" /etc/os-release) 190 | mkosi --cache "$MKOSI_CACHE" \ 191 | --distribution="$ID" \ 192 | --release="$VERSION_ID" \ 193 | --encrypt=all \ 194 | --format=gpt_btrfs \ 195 | --output=rootfs.img 196 | popd 197 | 198 | # Boot the initrd with an OS image 199 | lodev="$(losetup --show -f -P _rootfs/rootfs.img)" 200 | luks_uuid="$(cryptsetup luksUUID "${lodev}p1")" 201 | echo "LUKS rootfs UUID: $luks_uuid" 202 | losetup -d "$lodev" 203 | luks_cmdline="rd.luks.key=/luks.passphrase rd.luks.uuid=$luks_uuid" 204 | timeout --foreground -k 10 5m \ 205 | qemu-kvm -m 1024 -smp "$(nproc)" -nographic \ 206 | -initrd "$INITRD" \ 207 | -kernel "/usr/lib/modules/$KVER/vmlinuz" \ 208 | -drive "format=raw,cache=unsafe,file=_rootfs/rootfs.img" \ 209 | -append "$luks_cmdline root=LABEL=root rd.debug $SYSTEMD_LOG_OPTS console=ttyS0 systemd.unit=systemd-poweroff.service systemd.default_timeout_start_sec=240" 210 | 211 | # Cleanup 212 | rm -fr mkosi.extra mkosi.passphrase "$INITRD" 213 | ;; 214 | INITRD_LUKS_LVM) 215 | rm -fr mkosi.extra 216 | mkdir mkosi.extra 217 | 218 | luks_passphrase="H3lloW0rld!" 219 | # Instruct mkosi to copy the password file into the initrd image 220 | # so we can use it to unlock the rootfs 221 | echo -ne "$luks_passphrase" >mkosi.extra/luks.passphrase 222 | # Build the initrd with LVM support 223 | INITRD="initrd_$KVER.cpio.zstd" 224 | mkosi --cache "$MKOSI_CACHE" \ 225 | --default fedora.mkosi \ 226 | --package="cryptsetup,lvm2" \ 227 | --image-version="$KVER" \ 228 | --environment=KERNEL_VERSION="$KVER" \ 229 | --output="$INITRD" \ 230 | -f build 231 | ## Check if the image was indeed generated 232 | stat "$INITRD" 233 | 234 | # Build a basic LVM image to test the initrd with 235 | rm -fr _rootfs 236 | mkdir _rootfs 237 | pushd _rootfs 238 | 239 | # Create the base LVM layout with an ext4 rootfs 240 | dd if=/dev/zero of=rootfs.img bs=1M count=3000 241 | lodev="$(losetup --show -f -P rootfs.img)" 242 | echo "type=0FC63DAF-8483-4772-8E79-3D69D8477DE4 bootable" | sfdisk -X gpt "$lodev" 243 | cryptsetup --key-file ../mkosi.extra/luks.passphrase -q --use-urandom --pbkdf pbkdf2 --pbkdf-force-iterations 1000 luksFormat "${lodev}p1" 244 | cryptsetup --key-file ../mkosi.extra/luks.passphrase luksOpen "${lodev}p1" lvm_root 245 | luks_uuid="$(cryptsetup luksUUID "${lodev}p1")" 246 | lvm pvcreate /dev/mapper/lvm_root 247 | lvm pvs 248 | lvm vgcreate "vg_root" /dev/mapper/lvm_root 249 | lvm vgchange -ay "vg_root" 250 | lvm vgs 251 | # Note: we need to create the LV as "deactivated" (-an) and activate it 252 | # separately later as a workaround since we're running in a container 253 | lvm lvcreate -an -l 100%FREE -n lv0 "vg_root" 254 | lvm lvchange -ay "vg_root" 255 | lvm lvs 256 | wait_for_dev /dev/vg_root/lv0 257 | mkfs.ext4 -L "root" /dev/vg_root/lv0 258 | rm -fr mkosi.extra 259 | 260 | # Populate the rootfs with a basic OS image 261 | mkdir mnt 262 | mount /dev/vg_root/lv0 mnt 263 | # shellcheck source=/dev/null 264 | source <(grep -E "(ID|VERSION_ID)" /etc/os-release) 265 | mkosi --cache "$MKOSI_CACHE" \ 266 | --distribution="$ID" \ 267 | --release="$VERSION_ID" \ 268 | --format=directory \ 269 | --output=out 270 | # Note: this is necessary, since mkosi requires the target directory 271 | # to not exist and we don't want it to remove the mnt mountpoint 272 | (shopt -s dotglob && mv out/* mnt/) 273 | # Wrap up the LUKS+LVM image 274 | umount mnt 275 | vgchange -an "vg_root" 276 | cryptsetup close lvm_root 277 | losetup -d "$lodev" 278 | popd 279 | 280 | # Boot the initrd with an OS image 281 | luks_cmdline="rd.luks.key=/luks.passphrase rd.luks.uuid=$luks_uuid" 282 | timeout --foreground -k 10 5m \ 283 | qemu-kvm -m 1024 -smp "$(nproc)" -nographic \ 284 | -initrd "$INITRD" \ 285 | -kernel "/usr/lib/modules/$KVER/vmlinuz" \ 286 | -drive "format=raw,cache=unsafe,file=_rootfs/rootfs.img" \ 287 | -append "$luks_cmdline root=LABEL=root rd.debug $SYSTEMD_LOG_OPTS console=ttyS0 systemd.unit=systemd-poweroff.service systemd.default_timeout_start_sec=240" 288 | 289 | # Cleanup 290 | rm -fr _rootfs "$INITRD" 291 | ;; 292 | INITRD_ISCSI) 293 | # Build the initrd with iSCSI support 294 | INITRD="initrd_$KVER.cpio.zstd" 295 | mkosi --cache "$MKOSI_CACHE" \ 296 | --default fedora.mkosi \ 297 | --package="NetworkManager,iscsi-initiator-utils" \ 298 | --image-version="$KVER" \ 299 | --environment=KERNEL_VERSION="$KVER" \ 300 | --output="$INITRD" \ 301 | -f build 302 | ## Check if the image was indeed generated 303 | stat "$INITRD" 304 | 305 | # Build a basic image to test the initrd with 306 | rm -fr _rootfs 307 | mkdir _rootfs 308 | pushd _rootfs 309 | # shellcheck source=/dev/null 310 | source <(grep -E "(ID|VERSION_ID)" /etc/os-release) 311 | mkosi --cache "$MKOSI_CACHE" \ 312 | --distribution="$ID" \ 313 | --release="$VERSION_ID" \ 314 | --format=gpt_btrfs \ 315 | --output=rootfs.img 316 | popd 317 | 318 | # Setup a local iSCSI target 319 | target_name="iqn.2022-01.com.example:iscsi.initrd.test" 320 | pgrep tgtd || /usr/sbin/tgtd 321 | # Workaround for a race 322 | # See: https://src.fedoraproject.org/rpms/scsi-target-utils/c/3a25fe7a57200b61ecebcec0d867671597080196 323 | sleep 5 324 | tgtadm --lld iscsi --op new --mode target --tid=1 --targetname "$target_name" 325 | tgtadm --lld iscsi --op new --mode logicalunit --tid 1 --lun 1 -b "$PWD/_rootfs/rootfs.img" 326 | tgtadm --lld iscsi --op update --mode logicalunit --tid 1 --lun 1 327 | tgtadm --lld iscsi --op bind --mode target --tid 1 -I ALL 328 | tgtadm --lld iscsi --op show --mode target 329 | 330 | ip link add name initrd0 type bridge 331 | ip addr add 10.10.10.1/24 dev initrd0 332 | ip link set initrd0 up 333 | dnsmasq --interface=initrd0 --bind-interfaces --dhcp-range=10.10.10.10,10.10.10.100 334 | grep -q initrd0 /etc/qemu/bridge.conf || echo "allow initrd0" >>/etc/qemu/bridge.conf 335 | 336 | iscsi_cmdline="ip=dhcp netroot=iscsi:10.10.10.1::::$target_name" 337 | timeout --foreground -k 10 5m \ 338 | qemu-kvm -m 1024 -smp "$(nproc)" -nographic -nic bridge,br=initrd0 \ 339 | -initrd "$INITRD" \ 340 | -kernel "/usr/lib/modules/$KVER/vmlinuz" \ 341 | -append "$iscsi_cmdline root=LABEL=root rd.debug $SYSTEMD_LOG_OPTS console=ttyS0 systemd.unit=systemd-poweroff.service systemd.default_timeout_start_sec=240" 342 | 343 | # Cleanup 344 | tgtadm --lld iscsi --op delete --mode target --tid=1 345 | pkill -INT tgtd 346 | pkill dnsmasq 347 | ip link del dev initrd0 348 | rm -fr _rootfs "$INITRD" 349 | ;; 350 | SYSEXT) 351 | # Build the base initrd 352 | INITRD_BASE="initrd_$KVER" 353 | mkosi --default fedora.mkosi \ 354 | --image-version="$KVER" \ 355 | --environment=KERNEL_VERSION="$KVER" \ 356 | --format=directory \ 357 | --output="$INITRD_BASE" \ 358 | --clean-package-metadata=no \ 359 | -f build 360 | # Build the sysext image 361 | INITRD_SYSEXT="initrd_$KVER-ssh.raw" 362 | mkosi --default fedora.mkosi \ 363 | --image-version="$KVER-ssh" \ 364 | --base-image="$INITRD_BASE" \ 365 | --format=gpt_squashfs \ 366 | --environment=SYSEXT="initrd-$KVER-ssh" \ 367 | --output="$INITRD_SYSEXT" \ 368 | --package='!*,openssh-server' 369 | # Check if the image was indeed generated 370 | stat "$INITRD_SYSEXT" 371 | 372 | # Cleanup 373 | rm -fr "$INITRD_BASE" "$INITRD_SYSEXT" 374 | ;; 375 | *) 376 | echo >&2 "Unknown phase '$phase'" 377 | exit 1 378 | esac 379 | done 380 | -------------------------------------------------------------------------------- /LICENSE.LGPL2.1: -------------------------------------------------------------------------------- 1 | GNU LESSER GENERAL PUBLIC LICENSE 2 | Version 2.1, February 1999 3 | 4 | Copyright (C) 1991, 1999 Free Software Foundation, Inc. 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | [This is the first released version of the Lesser GPL. It also counts 10 | as the successor of the GNU Library Public License, version 2, hence 11 | the version number 2.1.] 12 | 13 | Preamble 14 | 15 | The licenses for most software are designed to take away your 16 | freedom to share and change it. By contrast, the GNU General Public 17 | Licenses are intended to guarantee your freedom to share and change 18 | free software--to make sure the software is free for all its users. 19 | 20 | This license, the Lesser General Public License, applies to some 21 | specially designated software packages--typically libraries--of the 22 | Free Software Foundation and other authors who decide to use it. You 23 | can use it too, but we suggest you first think carefully about whether 24 | this license or the ordinary General Public License is the better 25 | strategy to use in any particular case, based on the explanations below. 26 | 27 | When we speak of free software, we are referring to freedom of use, 28 | not price. Our General Public Licenses are designed to make sure that 29 | you have the freedom to distribute copies of free software (and charge 30 | for this service if you wish); that you receive source code or can get 31 | it if you want it; that you can change the software and use pieces of 32 | it in new free programs; and that you are informed that you can do 33 | these things. 34 | 35 | To protect your rights, we need to make restrictions that forbid 36 | distributors to deny you these rights or to ask you to surrender these 37 | rights. These restrictions translate to certain responsibilities for 38 | you if you distribute copies of the library or if you modify it. 39 | 40 | For example, if you distribute copies of the library, whether gratis 41 | or for a fee, you must give the recipients all the rights that we gave 42 | you. You must make sure that they, too, receive or can get the source 43 | code. If you link other code with the library, you must provide 44 | complete object files to the recipients, so that they can relink them 45 | with the library after making changes to the library and recompiling 46 | it. And you must show them these terms so they know their rights. 47 | 48 | We protect your rights with a two-step method: (1) we copyright the 49 | library, and (2) we offer you this license, which gives you legal 50 | permission to copy, distribute and/or modify the library. 51 | 52 | To protect each distributor, we want to make it very clear that 53 | there is no warranty for the free library. Also, if the library is 54 | modified by someone else and passed on, the recipients should know 55 | that what they have is not the original version, so that the original 56 | author's reputation will not be affected by problems that might be 57 | introduced by others. 58 | 59 | Finally, software patents pose a constant threat to the existence of 60 | any free program. We wish to make sure that a company cannot 61 | effectively restrict the users of a free program by obtaining a 62 | restrictive license from a patent holder. Therefore, we insist that 63 | any patent license obtained for a version of the library must be 64 | consistent with the full freedom of use specified in this license. 65 | 66 | Most GNU software, including some libraries, is covered by the 67 | ordinary GNU General Public License. This license, the GNU Lesser 68 | General Public License, applies to certain designated libraries, and 69 | is quite different from the ordinary General Public License. We use 70 | this license for certain libraries in order to permit linking those 71 | libraries into non-free programs. 72 | 73 | When a program is linked with a library, whether statically or using 74 | a shared library, the combination of the two is legally speaking a 75 | combined work, a derivative of the original library. The ordinary 76 | General Public License therefore permits such linking only if the 77 | entire combination fits its criteria of freedom. The Lesser General 78 | Public License permits more lax criteria for linking other code with 79 | the library. 80 | 81 | We call this license the "Lesser" General Public License because it 82 | does Less to protect the user's freedom than the ordinary General 83 | Public License. It also provides other free software developers Less 84 | of an advantage over competing non-free programs. These disadvantages 85 | are the reason we use the ordinary General Public License for many 86 | libraries. However, the Lesser license provides advantages in certain 87 | special circumstances. 88 | 89 | For example, on rare occasions, there may be a special need to 90 | encourage the widest possible use of a certain library, so that it becomes 91 | a de-facto standard. To achieve this, non-free programs must be 92 | allowed to use the library. A more frequent case is that a free 93 | library does the same job as widely used non-free libraries. In this 94 | case, there is little to gain by limiting the free library to free 95 | software only, so we use the Lesser General Public License. 96 | 97 | In other cases, permission to use a particular library in non-free 98 | programs enables a greater number of people to use a large body of 99 | free software. For example, permission to use the GNU C Library in 100 | non-free programs enables many more people to use the whole GNU 101 | operating system, as well as its variant, the GNU/Linux operating 102 | system. 103 | 104 | Although the Lesser General Public License is Less protective of the 105 | users' freedom, it does ensure that the user of a program that is 106 | linked with the Library has the freedom and the wherewithal to run 107 | that program using a modified version of the Library. 108 | 109 | The precise terms and conditions for copying, distribution and 110 | modification follow. Pay close attention to the difference between a 111 | "work based on the library" and a "work that uses the library". The 112 | former contains code derived from the library, whereas the latter must 113 | be combined with the library in order to run. 114 | 115 | GNU LESSER GENERAL PUBLIC LICENSE 116 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 117 | 118 | 0. This License Agreement applies to any software library or other 119 | program which contains a notice placed by the copyright holder or 120 | other authorized party saying it may be distributed under the terms of 121 | this Lesser General Public License (also called "this License"). 122 | Each licensee is addressed as "you". 123 | 124 | A "library" means a collection of software functions and/or data 125 | prepared so as to be conveniently linked with application programs 126 | (which use some of those functions and data) to form executables. 127 | 128 | The "Library", below, refers to any such software library or work 129 | which has been distributed under these terms. A "work based on the 130 | Library" means either the Library or any derivative work under 131 | copyright law: that is to say, a work containing the Library or a 132 | portion of it, either verbatim or with modifications and/or translated 133 | straightforwardly into another language. (Hereinafter, translation is 134 | included without limitation in the term "modification".) 135 | 136 | "Source code" for a work means the preferred form of the work for 137 | making modifications to it. For a library, complete source code means 138 | all the source code for all modules it contains, plus any associated 139 | interface definition files, plus the scripts used to control compilation 140 | and installation of the library. 141 | 142 | Activities other than copying, distribution and modification are not 143 | covered by this License; they are outside its scope. The act of 144 | running a program using the Library is not restricted, and output from 145 | such a program is covered only if its contents constitute a work based 146 | on the Library (independent of the use of the Library in a tool for 147 | writing it). Whether that is true depends on what the Library does 148 | and what the program that uses the Library does. 149 | 150 | 1. You may copy and distribute verbatim copies of the Library's 151 | complete source code as you receive it, in any medium, provided that 152 | you conspicuously and appropriately publish on each copy an 153 | appropriate copyright notice and disclaimer of warranty; keep intact 154 | all the notices that refer to this License and to the absence of any 155 | warranty; and distribute a copy of this License along with the 156 | Library. 157 | 158 | You may charge a fee for the physical act of transferring a copy, 159 | and you may at your option offer warranty protection in exchange for a 160 | fee. 161 | 162 | 2. You may modify your copy or copies of the Library or any portion 163 | of it, thus forming a work based on the Library, and copy and 164 | distribute such modifications or work under the terms of Section 1 165 | above, provided that you also meet all of these conditions: 166 | 167 | a) The modified work must itself be a software library. 168 | 169 | b) You must cause the files modified to carry prominent notices 170 | stating that you changed the files and the date of any change. 171 | 172 | c) You must cause the whole of the work to be licensed at no 173 | charge to all third parties under the terms of this License. 174 | 175 | d) If a facility in the modified Library refers to a function or a 176 | table of data to be supplied by an application program that uses 177 | the facility, other than as an argument passed when the facility 178 | is invoked, then you must make a good faith effort to ensure that, 179 | in the event an application does not supply such function or 180 | table, the facility still operates, and performs whatever part of 181 | its purpose remains meaningful. 182 | 183 | (For example, a function in a library to compute square roots has 184 | a purpose that is entirely well-defined independent of the 185 | application. Therefore, Subsection 2d requires that any 186 | application-supplied function or table used by this function must 187 | be optional: if the application does not supply it, the square 188 | root function must still compute square roots.) 189 | 190 | These requirements apply to the modified work as a whole. If 191 | identifiable sections of that work are not derived from the Library, 192 | and can be reasonably considered independent and separate works in 193 | themselves, then this License, and its terms, do not apply to those 194 | sections when you distribute them as separate works. But when you 195 | distribute the same sections as part of a whole which is a work based 196 | on the Library, the distribution of the whole must be on the terms of 197 | this License, whose permissions for other licensees extend to the 198 | entire whole, and thus to each and every part regardless of who wrote 199 | it. 200 | 201 | Thus, it is not the intent of this section to claim rights or contest 202 | your rights to work written entirely by you; rather, the intent is to 203 | exercise the right to control the distribution of derivative or 204 | collective works based on the Library. 205 | 206 | In addition, mere aggregation of another work not based on the Library 207 | with the Library (or with a work based on the Library) on a volume of 208 | a storage or distribution medium does not bring the other work under 209 | the scope of this License. 210 | 211 | 3. You may opt to apply the terms of the ordinary GNU General Public 212 | License instead of this License to a given copy of the Library. To do 213 | this, you must alter all the notices that refer to this License, so 214 | that they refer to the ordinary GNU General Public License, version 2, 215 | instead of to this License. (If a newer version than version 2 of the 216 | ordinary GNU General Public License has appeared, then you can specify 217 | that version instead if you wish.) Do not make any other change in 218 | these notices. 219 | 220 | Once this change is made in a given copy, it is irreversible for 221 | that copy, so the ordinary GNU General Public License applies to all 222 | subsequent copies and derivative works made from that copy. 223 | 224 | This option is useful when you wish to copy part of the code of 225 | the Library into a program that is not a library. 226 | 227 | 4. You may copy and distribute the Library (or a portion or 228 | derivative of it, under Section 2) in object code or executable form 229 | under the terms of Sections 1 and 2 above provided that you accompany 230 | it with the complete corresponding machine-readable source code, which 231 | must be distributed under the terms of Sections 1 and 2 above on a 232 | medium customarily used for software interchange. 233 | 234 | If distribution of object code is made by offering access to copy 235 | from a designated place, then offering equivalent access to copy the 236 | source code from the same place satisfies the requirement to 237 | distribute the source code, even though third parties are not 238 | compelled to copy the source along with the object code. 239 | 240 | 5. A program that contains no derivative of any portion of the 241 | Library, but is designed to work with the Library by being compiled or 242 | linked with it, is called a "work that uses the Library". Such a 243 | work, in isolation, is not a derivative work of the Library, and 244 | therefore falls outside the scope of this License. 245 | 246 | However, linking a "work that uses the Library" with the Library 247 | creates an executable that is a derivative of the Library (because it 248 | contains portions of the Library), rather than a "work that uses the 249 | library". The executable is therefore covered by this License. 250 | Section 6 states terms for distribution of such executables. 251 | 252 | When a "work that uses the Library" uses material from a header file 253 | that is part of the Library, the object code for the work may be a 254 | derivative work of the Library even though the source code is not. 255 | Whether this is true is especially significant if the work can be 256 | linked without the Library, or if the work is itself a library. The 257 | threshold for this to be true is not precisely defined by law. 258 | 259 | If such an object file uses only numerical parameters, data 260 | structure layouts and accessors, and small macros and small inline 261 | functions (ten lines or less in length), then the use of the object 262 | file is unrestricted, regardless of whether it is legally a derivative 263 | work. (Executables containing this object code plus portions of the 264 | Library will still fall under Section 6.) 265 | 266 | Otherwise, if the work is a derivative of the Library, you may 267 | distribute the object code for the work under the terms of Section 6. 268 | Any executables containing that work also fall under Section 6, 269 | whether or not they are linked directly with the Library itself. 270 | 271 | 6. As an exception to the Sections above, you may also combine or 272 | link a "work that uses the Library" with the Library to produce a 273 | work containing portions of the Library, and distribute that work 274 | under terms of your choice, provided that the terms permit 275 | modification of the work for the customer's own use and reverse 276 | engineering for debugging such modifications. 277 | 278 | You must give prominent notice with each copy of the work that the 279 | Library is used in it and that the Library and its use are covered by 280 | this License. You must supply a copy of this License. If the work 281 | during execution displays copyright notices, you must include the 282 | copyright notice for the Library among them, as well as a reference 283 | directing the user to the copy of this License. Also, you must do one 284 | of these things: 285 | 286 | a) Accompany the work with the complete corresponding 287 | machine-readable source code for the Library including whatever 288 | changes were used in the work (which must be distributed under 289 | Sections 1 and 2 above); and, if the work is an executable linked 290 | with the Library, with the complete machine-readable "work that 291 | uses the Library", as object code and/or source code, so that the 292 | user can modify the Library and then relink to produce a modified 293 | executable containing the modified Library. (It is understood 294 | that the user who changes the contents of definitions files in the 295 | Library will not necessarily be able to recompile the application 296 | to use the modified definitions.) 297 | 298 | b) Use a suitable shared library mechanism for linking with the 299 | Library. A suitable mechanism is one that (1) uses at run time a 300 | copy of the library already present on the user's computer system, 301 | rather than copying library functions into the executable, and (2) 302 | will operate properly with a modified version of the library, if 303 | the user installs one, as long as the modified version is 304 | interface-compatible with the version that the work was made with. 305 | 306 | c) Accompany the work with a written offer, valid for at 307 | least three years, to give the same user the materials 308 | specified in Subsection 6a, above, for a charge no more 309 | than the cost of performing this distribution. 310 | 311 | d) If distribution of the work is made by offering access to copy 312 | from a designated place, offer equivalent access to copy the above 313 | specified materials from the same place. 314 | 315 | e) Verify that the user has already received a copy of these 316 | materials or that you have already sent this user a copy. 317 | 318 | For an executable, the required form of the "work that uses the 319 | Library" must include any data and utility programs needed for 320 | reproducing the executable from it. However, as a special exception, 321 | the materials to be distributed need not include anything that is 322 | normally distributed (in either source or binary form) with the major 323 | components (compiler, kernel, and so on) of the operating system on 324 | which the executable runs, unless that component itself accompanies 325 | the executable. 326 | 327 | It may happen that this requirement contradicts the license 328 | restrictions of other proprietary libraries that do not normally 329 | accompany the operating system. Such a contradiction means you cannot 330 | use both them and the Library together in an executable that you 331 | distribute. 332 | 333 | 7. You may place library facilities that are a work based on the 334 | Library side-by-side in a single library together with other library 335 | facilities not covered by this License, and distribute such a combined 336 | library, provided that the separate distribution of the work based on 337 | the Library and of the other library facilities is otherwise 338 | permitted, and provided that you do these two things: 339 | 340 | a) Accompany the combined library with a copy of the same work 341 | based on the Library, uncombined with any other library 342 | facilities. This must be distributed under the terms of the 343 | Sections above. 344 | 345 | b) Give prominent notice with the combined library of the fact 346 | that part of it is a work based on the Library, and explaining 347 | where to find the accompanying uncombined form of the same work. 348 | 349 | 8. You may not copy, modify, sublicense, link with, or distribute 350 | the Library except as expressly provided under this License. Any 351 | attempt otherwise to copy, modify, sublicense, link with, or 352 | distribute the Library is void, and will automatically terminate your 353 | rights under this License. However, parties who have received copies, 354 | or rights, from you under this License will not have their licenses 355 | terminated so long as such parties remain in full compliance. 356 | 357 | 9. You are not required to accept this License, since you have not 358 | signed it. However, nothing else grants you permission to modify or 359 | distribute the Library or its derivative works. These actions are 360 | prohibited by law if you do not accept this License. Therefore, by 361 | modifying or distributing the Library (or any work based on the 362 | Library), you indicate your acceptance of this License to do so, and 363 | all its terms and conditions for copying, distributing or modifying 364 | the Library or works based on it. 365 | 366 | 10. Each time you redistribute the Library (or any work based on the 367 | Library), the recipient automatically receives a license from the 368 | original licensor to copy, distribute, link with or modify the Library 369 | subject to these terms and conditions. You may not impose any further 370 | restrictions on the recipients' exercise of the rights granted herein. 371 | You are not responsible for enforcing compliance by third parties with 372 | this License. 373 | 374 | 11. If, as a consequence of a court judgment or allegation of patent 375 | infringement or for any other reason (not limited to patent issues), 376 | conditions are imposed on you (whether by court order, agreement or 377 | otherwise) that contradict the conditions of this License, they do not 378 | excuse you from the conditions of this License. If you cannot 379 | distribute so as to satisfy simultaneously your obligations under this 380 | License and any other pertinent obligations, then as a consequence you 381 | may not distribute the Library at all. For example, if a patent 382 | license would not permit royalty-free redistribution of the Library by 383 | all those who receive copies directly or indirectly through you, then 384 | the only way you could satisfy both it and this License would be to 385 | refrain entirely from distribution of the Library. 386 | 387 | If any portion of this section is held invalid or unenforceable under any 388 | particular circumstance, the balance of the section is intended to apply, 389 | and the section as a whole is intended to apply in other circumstances. 390 | 391 | It is not the purpose of this section to induce you to infringe any 392 | patents or other property right claims or to contest validity of any 393 | such claims; this section has the sole purpose of protecting the 394 | integrity of the free software distribution system which is 395 | implemented by public license practices. Many people have made 396 | generous contributions to the wide range of software distributed 397 | through that system in reliance on consistent application of that 398 | system; it is up to the author/donor to decide if he or she is willing 399 | to distribute software through any other system and a licensee cannot 400 | impose that choice. 401 | 402 | This section is intended to make thoroughly clear what is believed to 403 | be a consequence of the rest of this License. 404 | 405 | 12. If the distribution and/or use of the Library is restricted in 406 | certain countries either by patents or by copyrighted interfaces, the 407 | original copyright holder who places the Library under this License may add 408 | an explicit geographical distribution limitation excluding those countries, 409 | so that distribution is permitted only in or among countries not thus 410 | excluded. In such case, this License incorporates the limitation as if 411 | written in the body of this License. 412 | 413 | 13. The Free Software Foundation may publish revised and/or new 414 | versions of the Lesser General Public License from time to time. 415 | Such new versions will be similar in spirit to the present version, 416 | but may differ in detail to address new problems or concerns. 417 | 418 | Each version is given a distinguishing version number. If the Library 419 | specifies a version number of this License which applies to it and 420 | "any later version", you have the option of following the terms and 421 | conditions either of that version or of any later version published by 422 | the Free Software Foundation. If the Library does not specify a 423 | license version number, you may choose any version ever published by 424 | the Free Software Foundation. 425 | 426 | 14. If you wish to incorporate parts of the Library into other free 427 | programs whose distribution conditions are incompatible with these, 428 | write to the author to ask for permission. For software which is 429 | copyrighted by the Free Software Foundation, write to the Free 430 | Software Foundation; we sometimes make exceptions for this. Our 431 | decision will be guided by the two goals of preserving the free status 432 | of all derivatives of our free software and of promoting the sharing 433 | and reuse of software generally. 434 | 435 | NO WARRANTY 436 | 437 | 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO 438 | WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. 439 | EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR 440 | OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY 441 | KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE 442 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 443 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE 444 | LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME 445 | THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 446 | 447 | 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN 448 | WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY 449 | AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU 450 | FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR 451 | CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE 452 | LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING 453 | RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A 454 | FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF 455 | SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH 456 | DAMAGES. 457 | 458 | END OF TERMS AND CONDITIONS 459 | 460 | How to Apply These Terms to Your New Libraries 461 | 462 | If you develop a new library, and you want it to be of the greatest 463 | possible use to the public, we recommend making it free software that 464 | everyone can redistribute and change. You can do so by permitting 465 | redistribution under these terms (or, alternatively, under the terms of the 466 | ordinary General Public License). 467 | 468 | To apply these terms, attach the following notices to the library. It is 469 | safest to attach them to the start of each source file to most effectively 470 | convey the exclusion of warranty; and each file should have at least the 471 | "copyright" line and a pointer to where the full notice is found. 472 | 473 | 474 | Copyright (C) 475 | 476 | This library is free software; you can redistribute it and/or 477 | modify it under the terms of the GNU Lesser General Public 478 | License as published by the Free Software Foundation; either 479 | version 2.1 of the License, or (at your option) any later version. 480 | 481 | This library is distributed in the hope that it will be useful, 482 | but WITHOUT ANY WARRANTY; without even the implied warranty of 483 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 484 | Lesser General Public License for more details. 485 | 486 | You should have received a copy of the GNU Lesser General Public 487 | License along with this library; if not, write to the Free Software 488 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 489 | 490 | Also add information on how to contact you by electronic and paper mail. 491 | 492 | You should also get your employer (if you work as a programmer) or your 493 | school, if any, to sign a "copyright disclaimer" for the library, if 494 | necessary. Here is a sample; alter the names: 495 | 496 | Yoyodyne, Inc., hereby disclaims all copyright interest in the 497 | library `Frob' (a library for tweaking knobs) written by James Random Hacker. 498 | 499 | , 1 April 1990 500 | Ty Coon, President of Vice 501 | 502 | That's all there is to it! 503 | --------------------------------------------------------------------------------