b.liu | e958203 | 2025-04-17 19:18:16 +0800 | [diff] [blame] | 1 | #!/usr/bin/env bash |
| 2 | set -e |
| 3 | |
| 4 | pkg_dir=$1 |
| 5 | |
| 6 | if [ -z $pkg_dir ] || [ ! -d $pkg_dir ]; then |
| 7 | echo "Usage: ipkg-make-index <package_directory>" >&2 |
| 8 | exit 1 |
| 9 | fi |
| 10 | |
| 11 | empty=1 |
| 12 | |
| 13 | for 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\\ |
| 25 | Size: $file_size\\ |
| 26 | SHA256sum: $sha256sum\\ |
| 27 | Description:/" |
| 28 | echo "" |
| 29 | done |
| 30 | [ -n "$empty" ] && echo |
| 31 | exit 0 |