Skip to content

Commit

Permalink
Added e2fsprogs bundle, Log to virt disk test
Browse files Browse the repository at this point in the history
  • Loading branch information
kincsescsaba committed Mar 2, 2024
1 parent 6c93d18 commit 84b5f4e
Show file tree
Hide file tree
Showing 7 changed files with 141 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/minimal_overlay/bundles/e2fsprogs/.config
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
E2FSPROGS_SOURCE_URL=https://git.kernel.org/pub/scm/fs/ext2/e2fsprogs.git/snapshot/e2fsprogs-$E2FSPROGS_VERSION.tar.gz
39 changes: 39 additions & 0 deletions src/minimal_overlay/bundles/e2fsprogs/01_get.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/sh

set -e

. ../../common.sh
. ../../../settings

# Read the common configuration properties.
DOWNLOAD_URL=`read_property E2FSPROGS_SOURCE_URL`
USE_LOCAL_SOURCE=`read_property USE_LOCAL_SOURCE`

# Grab everything after the last '/' character.
ARCHIVE_FILE=${DOWNLOAD_URL##*/}

if [ "$USE_LOCAL_SOURCE" = "true" -a ! -f $MAIN_SRC_DIR/source/overlay/$ARCHIVE_FILE ] ; then
echo "Source bundle $MAIN_SRC_DIR/source/overlay/$ARCHIVE_FILE is missing and will be downloaded."
USE_LOCAL_SOURCE="false"
fi

cd $MAIN_SRC_DIR/source/overlay

if [ ! "$USE_LOCAL_SOURCE" = "true" ] ; then
# Downloading util-linux source bundle file. The '-c' option allows the download to resume.
echo "Downloading jq source bundle from $DOWNLOAD_URL"
wget -c $DOWNLOAD_URL
else
echo "Using local jq source bundle $MAIN_SRC_DIR/source/overlay/$ARCHIVE_FILE"
fi

# Delete folder with previously extracted jq.
echo "Removing util-linux work area. This may take a while."
rm -rf $WORK_DIR/overlay/$BUNDLE_NAME
mkdir $WORK_DIR/overlay/$BUNDLE_NAME

# Extract util-linux to folder 'work/overlay/util_linux'.
# Full path will be something like 'work/overlay/util_linux/util-linux-2.31'.
tar -xvf $ARCHIVE_FILE -C $WORK_DIR/overlay/$BUNDLE_NAME

cd $SRC_DIR
67 changes: 67 additions & 0 deletions src/minimal_overlay/bundles/e2fsprogs/02_build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#!/bin/sh

set -e

. ../../common.sh
. ../../../settings

cd $WORK_DIR/overlay/$BUNDLE_NAME

# Change to the util-linux source directory which ls finds, e.g. 'util-linux-2.34'.
cd $(ls -d e2fsprogs-$E2FSPROGS_VERSION)

if [ -f Makefile ] ; then
echo "Preparing '$BUNDLE_NAME' work area. This may take a while."
make -j $NUM_JOBS clean
else
echo "The clean phase for '$BUNDLE_NAME' has been skipped."
fi

rm -rf $DEST_DIR
mkdir -p $DEST_DIR/bin
mkdir -p $DEST_DIR/lib

echo "Configuring '$BUNDLE_NAME'."

CFLAGS="$CFLAGS" ./configure --prefix=/usr \
--bindir=/bin \
--sysconfdir=/etc \
--enable-elf-shlibs \
#--disable-libblkid \
#--disable-libuuid \
#--disable-uuidd \
#--disable-fsck

echo "Building '$BUNDLE_NAME'."
make -j $NUM_JOBS

echo "Installing '$BUNDLE_NAME'."
make check
#make -j $NUM_JOBS install

cp -r misc/mke2fs $DEST_DIR/bin/mke2fs
cp -r lib/libext2fs.so.2.4 $DEST_DIR/lib/libext2fs.so.2.4
cp -r lib/libext2fs.so.2 $DEST_DIR/lib/libext2fs.so.2
cp -r lib/libext2fs.so $DEST_DIR/lib/libext2fs.so
cp -r lib/libcom_err.so.2.1 $DEST_DIR/lib/libcom_err.so.2.1
cp -r lib/libcom_err.so.2 $DEST_DIR/lib/libcom_err.so.2
cp -r lib/libcom_err.so $DEST_DIR/lib/libcom_err.so
cp -r lib/libe2p.so.2.3 $DEST_DIR/lib/libe2p.so.2.3
cp -r lib/libe2p.so.2 $DEST_DIR/lib/libe2p.so.2
cp -r lib/libe2p.so $DEST_DIR/lib/libe2p.so
cd $DEST_DIR/bin
ln mke2fs mkfs.ext2
ln mke2fs mkfs.ext3
ln mke2fs mkfs.ext4
cd $(ls -d e2fsprogs-$E2FSPROGS_VERSION)

echo "Reducing '$BUNDLE_NAME' size."
reduce_size $DEST_DIR

install_to_overlay bin
install_to_overlay lib

echo "Bundle '$BUNDLE_NAME' has been installed."

cd $SRC_DIR

10 changes: 10 additions & 0 deletions src/minimal_overlay/bundles/e2fsprogs/bundle.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/sh

set -e

. ../../common.sh

./01_get.sh
./02_build.sh

cd $SRC_DIR
9 changes: 9 additions & 0 deletions src/minimal_overlay/bundles/util_linux/02_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ CFLAGS="$CFLAGS" ./configure \
--disable-pylibmount \
--disable-static \
--disable-makeinstall-chown \
--enable-sfdisk \
--enable-mkfs
#--enable-libblkid \
#--enable-libuuid \
#--enable-libsmartcols \
Expand All @@ -49,12 +51,19 @@ make -j $NUM_JOBS
echo "Installing '$BUNDLE_NAME'."
make -j $NUM_JOBS install

cp -r /lib/x86_64-linux-gnu/libtinfo.so.6.3 $DEST_DIR/lib
cd $DEST_DIR/lib
ln -s libtinfo.so.6.3 libtinfo.so.6
cd $(ls -d util-linux-$UTIL_LINUX_VERSION)


echo "Reducing '$BUNDLE_NAME' size."
reduce_size $DEST_DIR/bin
reduce_size $DEST_DIR/sbin
reduce_size $DEST_DIR/lib

install_to_overlay bin
install_to_overlay sbin
install_to_overlay lib

echo "Bundle '$BUNDLE_NAME' has been installed."
Expand Down
13 changes: 13 additions & 0 deletions src/minimal_rootfs/etc/autorun/50_log_something_on_disk.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/sh

UNFORMATTED=$(lsblk --fs --json | jq -r '.blockdevices[] | select(.children == null and .fstype == null) | .name'| grep -i "vd")
if [ -n "$UNFORMATTED" ]; then
sfdisk /dev/$UNFORMATTED <<EOF
label: gpt
,$(( $(blockdev --getsize64 /dev/$UNFORMATTED) / 1024 ))KiB,,
EOF
mkfs.ext4 /dev/${UNFORMATTED}1
fi
mkdir -p /mnt/virtdrive
mount /dev/${UNFORMATTED}1 /mnt/virtdrive
echo "$(date) hello" >> /mnt/virtdrive/log
3 changes: 2 additions & 1 deletion src/settings
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
KERNEL_VERSION=6.7.5
GLIBC_VERSION=2.39
BUSYBOX_VERSION=1.36.1
ADD_BUNDLES=dhcp,util_linux,passwd,jq
ADD_BUNDLES=dhcp,util_linux,passwd,jq,e2fsprogs
UTIL_LINUX_VERSION=2.39.3
NCURSES_VERSION=6.3
PKG_CONFIG_VERSION=0.29.2
JQ_VERSION=1.7.1
E2FSPROGS_VERSION=1.47.0

0 comments on commit 84b5f4e

Please sign in to comment.