ipkg-make-index.sh 872 B

123456789101112131415161718192021222324252627282930
  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. sha256sum=$(openssl dgst -sha256 $pkg | awk '{print $2}')
  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. MD5Sum: $md5sum\\
  23. SHA256sum: $sha256sum\\
  24. Description:/"
  25. echo ""
  26. done