Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(pipelines/split): Support overriding source package #1472

Merged
merged 6 commits into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 24 additions & 9 deletions pkg/build/pipelines/split/debug.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,43 @@ name: Split debug files
needs:
packages:
- binutils
- busybox
- scanelf

inputs:
package:
description: |
The package to split debug files from
required: false

pipeline:
- if: ${{targets.destdir}} != ${{targets.contextdir}}
runs: |
mkdir -p "${{targets.destdir}}/.dbg-tmp"
- runs: |
PACKAGE_DIR="${{targets.destdir}}"
if [ -n "${{inputs.package}}" ]; then
PACKAGE_DIR="/home/build/melange-out/${{inputs.package}}"
fi

if [ "$PACKAGE_DIR" == "${{targets.contextdir}}" ]; then
echo "ERROR: Package can not split files from itself!" && exit 1
fi

mkdir -p "$PACKAGE_DIR/.dbg-tmp"
# note: the ${{targets.subpkgdir}} doesn't exist when the glob is evaluated
scanelf -Ry "${{targets.destdir}}"/* | while read type src; do
scanelf -Ry "$PACKAGE_DIR"/* | while read type src; do
if [ "$type" != ET_DYN ]; then
continue
fi
dst=${{targets.contextdir}}/usr/lib/debug/${src#"${{targets.destdir}}"/*/}.debug
dst=${{targets.contextdir}}/usr/lib/debug/${src#"$PACKAGE_DIR"/*/}.debug
mkdir -p "${dst%/*}"
ino=$(stat -c %i "$src")
if ! [ -e "${{targets.destdir}}/.dbg-tmp/$ino" ]; then
tmp=${{targets.destdir}}/.dbg-tmp/${src##*/}
if ! [ -e "$PACKAGE_DIR/.dbg-tmp/$ino" ]; then
tmp=$PACKAGE_DIR/.dbg-tmp/${src##*/}
objcopy --only-keep-debug "$src" "$dst"
objcopy --add-gnu-debuglink="$dst" --strip-unneeded -R .comment "$src" "$tmp"
# preserve attributes, links
cat "$tmp" > "$src"
rm "$tmp"
ln "$dst" "${{targets.destdir}}/.dbg-tmp/$ino"
ln "$dst" "$PACKAGE_DIR/.dbg-tmp/$ino"
fi
done
rm -r "${{targets.destdir}}/.dbg-tmp"
rm -r "$PACKAGE_DIR/.dbg-tmp"
32 changes: 26 additions & 6 deletions pkg/build/pipelines/split/dev.yaml
Original file line number Diff line number Diff line change
@@ -1,28 +1,48 @@
name: Split development files

needs:
packages:
- busybox

inputs:
package:
description: |
The package to split development files from
required: false

pipeline:
- if: ${{targets.destdir}} != ${{targets.contextdir}}
runs: |
- runs: |
PACKAGE_DIR="${{targets.destdir}}"
if [ -n "${{inputs.package}}" ]; then
PACKAGE_DIR="/home/build/melange-out/${{inputs.package}}"
fi

if [ "$PACKAGE_DIR" == "${{targets.contextdir}}" ]; then
echo "ERROR: Package can not split files from itself!" && exit 1
fi

i= j=
cd "${{targets.destdir}}" || exit 0
cd "$PACKAGE_DIR" || exit 0

libdirs=usr/
[ -d lib/ ] && libdirs="lib/ $libdirs"
[ -d lib64/ ] && libdirs="lib64/ $libdirs"
for i in usr/include usr/lib/pkgconfig usr/share/pkgconfig \
usr/share/aclocal usr/share/gettext \
usr/bin/*-config usr/bin/*_config usr/share/vala/vapi \
usr/share/gir-[0-9]* usr/share/qt*/mkspecs \
usr/lib/qt*/mkspecs usr/lib/cmake \
usr/lib/glade/modules usr/share/glade/catalogs \
usr/local/*/include usr/local/*/lib64 \
$(find . -name include -type d) \
$(find $libdirs -name '*.a' 2>/dev/null) \
$(find $libdirs -name '*.[cho]' \
-o -name '*.prl' 2>/dev/null); do
if [ -e "${{targets.destdir}}/$i" ] || [ -L "${{targets.destdir}}/$i" ]; then
if [ -e "$PACKAGE_DIR/$i" ] || [ -L "$PACKAGE_DIR/$i" ]; then
d="${{targets.contextdir}}/${i%/*}" # dirname $i
mkdir -p "$d"
mv "${{targets.destdir}}/$i" "$d"
rmdir "${{targets.destdir}}/${i%/*}" 2>/dev/null || :
mv "$PACKAGE_DIR/$i" "$d"
rmdir "$PACKAGE_DIR/${i%/*}" 2>/dev/null || :
fi
done

Expand Down
28 changes: 23 additions & 5 deletions pkg/build/pipelines/split/infodir.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,29 @@
name: Split GNU info pages

needs:
packages:
- busybox

inputs:
package:
description: |
The package to split info pages files from
required: false

pipeline:
- if: ${{targets.destdir}} != ${{targets.contextdir}}
runs: |
if [ -d "${{targets.destdir}}/usr/share/info" ]; then
rm -f "${{targets.destdir}}"/usr/share/info/dir
- runs: |
PACKAGE_DIR="${{targets.destdir}}"
if [ -n "${{inputs.package}}" ]; then
PACKAGE_DIR="/home/build/melange-out/${{inputs.package}}"
fi

if [ "$PACKAGE_DIR" == "${{targets.contextdir}}" ]; then
echo "ERROR: Package can not split files from itself!" && exit 1
fi

if [ -d "$PACKAGE_DIR/usr/share/info" ]; then
rm -f "$PACKAGE_DIR"/usr/share/info/dir

mkdir -p "${{targets.contextdir}}/usr/share"
mv "${{targets.destdir}}"/usr/share/info "${{targets.contextdir}}/usr/share"
mv "$PACKAGE_DIR"/usr/share/info "${{targets.contextdir}}/usr/share"
fi
26 changes: 22 additions & 4 deletions pkg/build/pipelines/split/locales.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,27 @@
name: Split locales

needs:
packages:
- busybox

inputs:
package:
description: |
The package to split locales from
required: false

pipeline:
- if: ${{targets.destdir}} != ${{targets.contextdir}}
runs: |
if [ -d "${{targets.destdir}}"/usr/share/locale ]; then
- runs: |
PACKAGE_DIR="${{targets.destdir}}"
if [ -n "${{inputs.package}}" ]; then
PACKAGE_DIR="/home/build/melange-out/${{inputs.package}}"
fi

if [ "$PACKAGE_DIR" == "${{targets.contextdir}}" ]; then
echo "ERROR: Package can not split files from itself!" && exit 1
fi

if [ -d "$PACKAGE_DIR"/usr/share/locale ]; then
mkdir -p "${{targets.contextdir}}"/usr/share
mv "${{targets.destdir}}"/usr/share/locale "${{targets.contextdir}}"/usr/share/locale
mv "$PACKAGE_DIR"/usr/share/locale "${{targets.contextdir}}"/usr/share/locale
fi
26 changes: 22 additions & 4 deletions pkg/build/pipelines/split/manpages.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,27 @@
name: Split manpages

needs:
packages:
- busybox

inputs:
package:
description: |
The package to split manpages from
required: false

pipeline:
- if: ${{targets.destdir}} != ${{targets.contextdir}}
runs: |
if [ -d "${{targets.destdir}}/usr/share/man" ]; then
- runs: |
PACKAGE_DIR="${{targets.destdir}}"
if [ -n "${{inputs.package}}" ]; then
PACKAGE_DIR="/home/build/melange-out/${{inputs.package}}"
fi

if [ "$PACKAGE_DIR" == "${{targets.contextdir}}" ]; then
echo "ERROR: Package can not split files from itself!" && exit 1
fi

if [ -d "$PACKAGE_DIR/usr/share/man" ]; then
mkdir -p "${{targets.contextdir}}/usr/share"
mv "${{targets.destdir}}/usr/share/man" "${{targets.contextdir}}/usr/share"
mv "$PACKAGE_DIR/usr/share/man" "${{targets.contextdir}}/usr/share"
fi
31 changes: 25 additions & 6 deletions pkg/build/pipelines/split/static.yaml
Original file line number Diff line number Diff line change
@@ -1,19 +1,38 @@
name: Split static library files

needs:
packages:
- busybox

inputs:
package:
description: |
The package to split static library files from
required: false

pipeline:
- if: ${{targets.destdir}} != ${{targets.contextdir}}
runs: |
- runs: |
PACKAGE_DIR="${{targets.destdir}}"
if [ -n "${{inputs.package}}" ]; then
PACKAGE_DIR="/home/build/melange-out/${{inputs.package}}"
fi

if [ "$PACKAGE_DIR" == "${{targets.contextdir}}" ]; then
echo "ERROR: Package can not split files from itself!" && exit 1
fi

i= j=
cd "${{targets.destdir}}" || exit 0
cd "$PACKAGE_DIR" || exit 0

libdirs=usr/
[ -d lib/ ] && libdirs="lib/ $libdirs"
[ -d lib64/ ] && libdirs="lib64/ $libdirs"
for i in \
$(find $libdirs -name '*.a' 2>/dev/null); do
if [ -e "${{targets.destdir}}/$i" ] || [ -L "${{targets.destdir}}/$i" ]; then
if [ -e "$PACKAGE_DIR/$i" ] || [ -L "$PACKAGE_DIR/$i" ]; then
d="${{targets.contextdir}}/${i%/*}" # dirname $i
mkdir -p "$d"
mv "${{targets.destdir}}/$i" "$d"
rmdir "${{targets.destdir}}/${i%/*}" 2>/dev/null || :
mv "$PACKAGE_DIR/$i" "$d"
rmdir "$PACKAGE_DIR/${i%/*}" 2>/dev/null || :
fi
done
Loading