Skip to content

Commit

Permalink
Added jq bundle
Browse files Browse the repository at this point in the history
  • Loading branch information
kincsescsaba committed Mar 1, 2024
1 parent 45cbcd5 commit 6c93d18
Show file tree
Hide file tree
Showing 5 changed files with 105 additions and 1 deletion.
9 changes: 9 additions & 0 deletions src/minimal_overlay/bundles/jq/.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Some of the functionality depends on third party
# libraries, e.g. 'ncurses' and 'termcap'. Also note
# that the build process requires root permissions.
#
# You can find the latest util_linux archives here:
#
# https://www.kernel.org/pub/linux/utils/util-linux/
#
JQ_SOURCE_URL=https://github.com/jqlang/jq/releases/download/jq-$JQ_VERSION/jq-$JQ_VERSION.tar.gz
39 changes: 39 additions & 0 deletions src/minimal_overlay/bundles/jq/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 JQ_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
45 changes: 45 additions & 0 deletions src/minimal_overlay/bundles/jq/02_build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/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 jq-$JQ_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

echo "Configuring '$BUNDLE_NAME'."

CFLAGS="$CFLAGS" ./configure \
--with-oniguruma=builtin

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

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

cp -r jq $DEST_DIR/bin/jq

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

install_to_overlay

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

cd $SRC_DIR

10 changes: 10 additions & 0 deletions src/minimal_overlay/bundles/jq/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
3 changes: 2 additions & 1 deletion src/settings
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
KERNEL_VERSION=6.7.5
GLIBC_VERSION=2.39
BUSYBOX_VERSION=1.36.1
ADD_BUNDLES=dhcp,util_linux,passwd
ADD_BUNDLES=dhcp,util_linux,passwd,jq
UTIL_LINUX_VERSION=2.39.3
NCURSES_VERSION=6.3
PKG_CONFIG_VERSION=0.29.2
JQ_VERSION=1.7.1

0 comments on commit 6c93d18

Please sign in to comment.