Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:coolo:fakedevel
base-image
base-image.spec
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File base-image.spec of Package base-image
# # spec file for package base-image # # Copyright (c) 2020 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed # upon. The license for this file, and modifications and additions to the # file, is the same license as for the pristine package itself (unless the # license for the pristine package is not an Open Source License, in which # case the license is the MIT License). An "Open Source License" is a # license that conforms to the Open Source Definition (Version 1.9) # published by the Open Source Initiative. # Please submit bugfixes or comments via https://bugs.opensuse.org/ # # needsrootforbuild # needsbinariesforbuild %global packages_base systemd dash carwos-release smack kernel-rt libproj19 iproute2 iptables bridge-utils kexec-tools ebtables kmod strongswan-ipsec busybox cryptsetup %global packages_dev zypper psmisc openssh strace socat gdbserver curl iperf jq tcpdump valgrind ltrace iputils xz audit gdb %global packages_sdk binutils binutils-devel bison e2fsprogs-devel gcc gcc-c++ gdbm-devel glibc-devel glibc-devel-static gmp-devel libaio-devel libcom_err-devel libopenssl-1_1-devel libstdc++-devel libuuid-devel libxml2-tools linux-glibc-devel pkg-config proj-devel systemd-devel Name: base-image Version: 1.0 Release: 0 Summary: This is not sleshammer, but something similiar (abusing needsrootforbuild exception) License: MIT Source1: unhardlink.sh Source2: config.sh Source3: config.dev.sh Source4: config.sdk.sh Source5: cmdline.txt Source6: pre-init.sh Source7: 55-udev-smack-default.rules %if "@BUILD_FLAVOR@" == "sdk" BuildRequires: %packages_sdk %else BuildRequires: %packages_base BuildRequires: %packages_dev %endif # To make it behave like a kiwi build #!BuildRequires: --ignoreignore-- # Substitute like python3-kiwi, to conflict -mini packages #!BuildRequires: dont_want_mini BuildRequires: suse-build-key BuildRequires: e2fsprogs BuildRequires: zypper BuildRequires: iasimage %description %prep %build install_repo() { root=$(realpath $1) pkglist=$2 for key in /usr/lib/rpm/gnupg/keys/gpg-pubkey-*.asc; do rpm -r $root --import $key done export ZYPP_CONF=$root/etc/zypp/zypp.conf ZYPPER="zypper --root $root --non-interactive --no-gpg-checks" $ZYPPER addrepo /.build.binaries InstallationImage $ZYPPER in --auto-agree-with-licenses $pkglist $ZYPPER rr InstallationImage rm -rf $root/var/cache/zypp } setup_chroot() { root=$1 trap "cleanup_chroot $root" EXIT for i in proc sys dev; do mkdir -p $root/$i mount --rbind /$i $root/$i done } cleanup_chroot() { umount -R $1/{proc,sys,dev} trap "" EXIT } run_in_chroot() { root=$1 script=$2 install -m755 $2 $1/script chroot $1 /script ret=$? rm $1/script return $ret } mkdir -p %{_topdir}/OTHER %if "@BUILD_FLAVOR@" == "sdk" mkdir -p sdk setup_chroot sdk install_repo sdk "%packages_sdk" run_in_chroot sdk %{S:1} run_in_chroot sdk %{S:4} cleanup_chroot sdk sed -e 's,/usr/lib64/,,g; s,/lib64/,../../lib64/,g' -i sdk/usr/lib64/libndbm.so sdk/usr/lib64/libc.so sdk/usr/lib64/libm.so sdk/usr/lib64/libpthread.so find sdk -name *.so 2>/dev/null | xargs file | grep 'ASCII text' | sed -e 's,\.so:.*,.so,' | xargs cat %else # Create root file system dd if=/dev/zero seek=500 of=base.raw bs=1M count=0 /usr/sbin/mkfs.ext4 -m 0 base.raw mkdir -p base mount -t ext4 -o seclabel base.raw base # Create zypp config mkdir -p base/etc/zypp cat > base/etc/zypp/zypp.conf <<EOF [main] rpm.install.excludedocs = yes solver.onlyRequires = true EOF # Install the base layer setup_chroot base install_repo base "%packages_base" run_in_chroot base %{S:2} run_in_chroot base %{S:1} # Hack to get zypper removing rpm work. zypper only knows the old database location (boo#1122471) rm -f base/var/lib/rpm mv base/usr/lib/sysimage/rpm base/var/lib zypper --root $PWD/base --non-interactive rm -u dracut xz gawk pigz fillup suse-module-tools diffutils perl-Bootloader systemd-presets-common-SUSE mkdir -p base/usr/lib/sysimage/ mv base/var/lib/rpm base/usr/lib/sysimage/ # Drop bash zypper --non-interactive --root $PWD/base rm -u bash sed -i -e 's,/bin/bash,/bin/sh,' $PWD/base/etc/passwd # drop dependencies by brute force (and replace some of them with busybox) rpm -ql coreutils | grep usr/bin | while read p; do base=`basename $p`; egrep "/$base$" /usr/share/busybox/busybox.links || true; done > links rpm -r $PWD/base -e --nodeps update-alternatives pkg-config sed info grep findutils coreutils libreadline7 # require libreadline but not needed to execute rm $PWD/base/usr/sbin/*fdisk* $PWD/base/sbin/*fdisk* for binary in sed grep egrep fgrep find xargs; do ln -s busybox $PWD/base/usr/bin/$binary done grep usr/bin links | while read binary; do ln -s busybox $PWD/base/$binary done grep ^/bin links | while read binary; do ln -s ../usr/bin/busybox $PWD/base/$binary ln -s busybox $PWD/base/usr/$binary done # enable busybox's udhcpc ln -s busybox $PWD/base/usr/bin/udhcpd ln -s busybox $PWD/base/usr/bin/udhcpc ln -s busybox $PWD/base/usr/bin/vi ln -s busybox $PWD/base/usr/bin/netstat ln -s busybox $PWD/base/usr/bin/tar rpm -r $PWD/base -qa --queryformat '%%{NAME}-%%{VERSION}-%%{RELEASE} %%{DISTURL} "%%{LICENSE}"\n' | sort > $PWD/base/.installed.rpms cat $PWD/base/.installed.rpms install -m 755 %{S:6} base/sbin/init install -m 644 %{S:7} base/usr/lib/udev/rules.d cleanup_chroot base # install convenience links for i in poweroff reboot halt; do ln -s ../usr/bin/systemctl base/sbin/$i done # Install the dev layer mkdir layer{,-work} mount -t overlay -o upperdir=layer,lowerdir=base,workdir=layer-work overlay base setup_chroot base install_repo base "%packages_dev" run_in_chroot base %{S:3} run_in_chroot base %{S:1} cleanup_chroot base umount base cp -R --preserve=all layer base/dev-overlay rm -rf layer{,-work} # Only keep the RPM database in the dev layer. cp --update base/usr/lib/sysimage/rpm/* base/dev-overlay/usr/lib/sysimage/rpm/ rm base/usr/lib/sysimage/rpm/* # Must not be in the overlay rm -rf base/dev-overlay/{proc,sys,dev,run,var,tmp} mv base/boot/vmlinu* . umount base # Not sure why this makes a difference, but it makes the first boot quicker fsck.ext4 -vy base.raw rm vmlinux* vmlinuz mv vmlinuz* vmlinuz iasimage create -o boot.kpi -i 0x30000 %{S:5} vmlinuz %endif %install %if "@BUILD_FLAVOR@" == "sdk" tar cvJf %{_topdir}/OTHER/image.sdk-%{version}-%{release}.tar.xz sdk %else #for local debugging #cp vmlinuz base.raw %{_topdir}/OTHER/ #exit 0 tar -cSvaf %{_topdir}/OTHER/image.base-%{version}-%{release}.tar.xz base.raw vmlinuz boot.kpi %endif %changelog
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor