Skip to content

Add %{script} format to `buildstream show`

Tristan Maat requested to merge non-sandbox-builds into master

This adds the %{script} format specifier which prints an element's script.

Can be used for debugging purposes, to check variable expansions or even to manually execute a failed build in a bst shell.

Perhaps the documentation should note somewhere that $SRCDIR should be set to a directory containing the correct sources to execute these scripts.

Example output:

#!/bin/sh
#
# DO NOT EDIT THIS FILE
#
# This is a build script generated by
# [BuildStream](https://wiki.gnome.org/Projects/BuildStream/).
#
# Builds the module base-base-system.

set -e

# Prepare the build environment
echo 'Building base-base-system'

if [ -d '/buildstream/build' ]; then
    rm -rf '/buildstream/build'
fi

if [ -d '/buildstream/install' ]; then
    rm -rf '/buildstream/install'
fi

mkdir -p '/buildstream/build'
mkdir -p '/buildstream/install'

if [ -d "$SRCDIR/base-base-system/" ]; then
    cp -a "$SRCDIR/base-base-system/." '/buildstream/build'
fi
cd '/buildstream/build'

export PREFIX='/buildstream/install'

export HOME=/tmp LC_ALL=en_US.UTF-8 LDFLAGS=-L/usr/lib LD_LIBRARY_PATH=/usr/lib LOGNAME=tomjon PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/lib/pkgconfig SHELL=/bin/sh TERM=dumb TZ=UTC USER=tomjon USERNAME=tomjon 

# Build the module
(set -ex; mkdir -p /buildstream
) || exit 1
(set -ex; [ ! -e /buildstream/install ] || rmdir /buildstream/install
) || exit 1
(set -ex; mv /buildstream/build/base-base-system /buildstream/install
) || exit 1


rm -rf '/buildstream/build'

# Install the module
echo 'Installing base-base-system'

(cd '/buildstream/install'; find . | cpio -umdp /)


#!/bin/sh
#
# DO NOT EDIT THIS FILE
#
# This is a build script generated by
# [BuildStream](https://wiki.gnome.org/Projects/BuildStream/).
#
# Builds the module base-linker-priority.

set -e

# Prepare the build environment
echo 'Building base-linker-priority'

if [ -d '/buildstream/build' ]; then
    rm -rf '/buildstream/build'
fi

if [ -d '/buildstream/install' ]; then
    rm -rf '/buildstream/install'
fi

mkdir -p '/buildstream/build'
mkdir -p '/buildstream/install'

if [ -d "$SRCDIR/base-linker-priority/" ]; then
    cp -a "$SRCDIR/base-linker-priority/." '/buildstream/build'
fi
cd '/buildstream/build'

export PREFIX='/buildstream/install'

export HOME=/tmp LC_ALL=en_US.UTF-8 LDFLAGS=-L/usr/lib LD_LIBRARY_PATH=/usr/lib LOGNAME=tomjon PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/lib/pkgconfig SHELL=/bin/sh TERM=dumb TZ=UTC USER=tomjon USERNAME=tomjon 

# Build the module
(set -ex; mkdir -p /buildstream
) || exit 1
(set -ex; [ ! -e /buildstream/install ] || rmdir /buildstream/install
) || exit 1
(set -ex; mv /buildstream/build/base-linker-priority /buildstream/install
) || exit 1


rm -rf '/buildstream/build'

# Install the module
echo 'Installing base-linker-priority'

(cd '/buildstream/install'; find . | cpio -umdp /)

#!/bin/sh
#
# DO NOT EDIT THIS FILE
#
# This is a build script generated by
# [BuildStream](https://wiki.gnome.org/Projects/BuildStream/).
#
# Builds the module base-ninja.

set -e

# Prepare the build environment
echo 'Building base-ninja'

if [ -d '/buildstream/build' ]; then
    rm -rf '/buildstream/build'
fi

if [ -d '/buildstream/install' ]; then
    rm -rf '/buildstream/install'
fi

mkdir -p '/buildstream/build'
mkdir -p '/buildstream/install'

if [ -d "$SRCDIR/base-ninja/" ]; then
    cp -a "$SRCDIR/base-ninja/." '/buildstream/build'
fi
cd '/buildstream/build'

export PREFIX='/buildstream/install'

export HOME=/tmp LC_ALL=en_US.UTF-8 LDFLAGS=-L/usr/lib LD_LIBRARY_PATH=/usr/lib LOGNAME=tomjon MAKEFLAGS=-j4 NINJAJOBS=4 PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/lib/pkgconfig SHELL=/bin/sh TERM=dumb TZ=UTC USER=tomjon USERNAME=tomjon V=1 

# Build the module
(set -ex; ./configure.py
) || exit 1
(set -ex; ninja -j ${NINJAJOBS}
) || exit 1
(set -ex; install -d /buildstream/install/usr/bin
) || exit 1
(set -ex; install -m 0755 ninja /buildstream/install/usr/bin
) || exit 1
(set -ex; find "/buildstream/install" -type f \
  '(' -perm -111 -o -name '*.so*' \
      -o -name '*.cmxs' -o -name '*.node' ')' \
  -exec sh -ec \
  'read -n4 hdr <"$1" # check for elf header
   if [ "$hdr" != "$(printf \\x7fELF)" ]; then
       exit 0
   fi
   debugfile="/buildstream/install/usr/lib/debug/$(basename "$1")"
   mkdir -p "$(dirname "$debugfile")"
   objcopy --only-keep-debug "$1" "$debugfile"
   chmod 644 "$debugfile"
   strip --remove-section=.comment --remove-section=.note --strip-unneeded "$1"
   objcopy --add-gnu-debuglink "$debugfile" "$1"' - {} ';'
) || exit 1


rm -rf '/buildstream/build'

# Install the module
echo 'Installing base-ninja'

(cd '/buildstream/install'; find . | cpio -umdp /)

Edited by Tristan Maat

Merge request reports