2
0

ipkg-make-index.sh 789 B

12345678910111213141516171819202122232425262728
  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. which md5sum >/dev/null 2>&1 || alias md5sum=md5
  9. for pkg in `find $pkg_dir -name '*.ipk' | sort`; do
  10. name="${pkg##*/}"
  11. name="${name%%_*}"
  12. [[ "$name" = "kernel" ]] && continue
  13. [[ "$name" = "libc" ]] && continue
  14. echo "Generating index for package $pkg" >&2
  15. file_size=$(ls -l $pkg | awk '{print $5}')
  16. md5sum=$(md5sum $pkg | awk '{print $1}')
  17. # Take pains to make variable value sed-safe
  18. sed_safe_pkg=`echo $pkg | sed -e 's/^\.\///g' -e 's/\\//\\\\\\//g'`
  19. tar -xzOf $pkg ./control.tar.gz | tar xzOf - ./control | sed -e "s/^Description:/Filename: $sed_safe_pkg\\
  20. Size: $file_size\\
  21. MD5Sum: $md5sum\\
  22. Description:/"
  23. echo ""
  24. done