1
0

ipkg-make-index.sh 772 B

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