blob: 8965d0aa183db47c907beb659d5e00f5d2407182 [file] [log] [blame]
b.liue9582032025-04-17 19:18:16 +08001#!/usr/bin/env bash
2set -e
3
4pkg_dir=$1
5
6if [ -z $pkg_dir ] || [ ! -d $pkg_dir ]; then
7 echo "Usage: ipkg-make-index <package_directory>" >&2
8 exit 1
9fi
10
11empty=1
12
13for pkg in `find $pkg_dir -name '*.ipk' | sort`; do
14 empty=
15 name="${pkg##*/}"
16 name="${name%%_*}"
17 [[ "$name" = "kernel" ]] && continue
18 [[ "$name" = "libc" ]] && continue
19 echo "Generating index for package $pkg" >&2
20 file_size=$(stat -L -c%s $pkg)
21 sha256sum=$($MKHASH sha256 $pkg)
22 # Take pains to make variable value sed-safe
23 sed_safe_pkg=`echo $pkg | sed -e 's/^\.\///g' -e 's/\\//\\\\\\//g'`
24 tar -xzOf $pkg ./control.tar.gz | tar xzOf - ./control | sed -e "s/^Description:/Filename: $sed_safe_pkg\\
25Size: $file_size\\
26SHA256sum: $sha256sum\\
27Description:/"
28 echo ""
29done
30[ -n "$empty" ] && echo
31exit 0