createpkgs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #!/bin/sh
  2. #sd card with gentoo 8gb card for raspberry pi, assume 2nd partition mounted on /mnt/sdb2
  3. for APKGSPEC in `find /mnt/sdb2/var/db/pkg -mindepth 2 -maxdepth 2 -type d | grep -v 'pkg/virtual' | tr '\n' ' '`
  4. do
  5. #ex: /mnt/sdb2/var/db/pkg/sys-fs/e2fsprogs-1.42
  6. APKGNAME="`basename $APKGSPEC`"
  7. echo "$APKGNAME"
  8. #[ -d ./${APKGNAME} ] && rm -rf ./${APKGNAME}
  9. if [ -f ${APKGSPEC}/CONTENTS ];then
  10. mkdir ${APKGNAME}
  11. [ -f ${APKGSPEC}/CATEGORY ] && cp -a ${APKGSPEC}/CATEGORY ${APKGNAME}/
  12. [ -f ${APKGSPEC}/DESCRIPTION ] && cp -a ${APKGSPEC}/DESCRIPTION ${APKGNAME}/
  13. [ -f ${APKGSPEC}/DEPEND ] && cp -a ${APKGSPEC}/DEPEND ${APKGNAME}/
  14. [ -f ${APKGSPEC}/RDEPEND ] && cp -a ${APKGSPEC}/RDEPEND ${APKGNAME}/
  15. [ -f ${APKGSPEC}/SIZE ] && cp -a ${APKGSPEC}/SIZE ${APKGNAME}/
  16. cat ${APKGSPEC}/CONTENTS | tr '\t' ' ' | tr -s ' ' |
  17. while read ALINE
  18. do
  19. ATYPE="`echo -n "$ALINE" | cut -f 1 -d ' '`"
  20. case $ATYPE in
  21. dir)
  22. ADIR="`echo -n "$ALINE" | cut -f 2-9 -d ' '`"
  23. [ -d /mnt/sdb2"${ADIR}" ] && mkdir -p "${APKGNAME}${ADIR}"
  24. ;;
  25. obj)
  26. #need be careful, may have space chars in path...
  27. AFILE="`echo -n "$ALINE" | rev | cut -f 3-9 -d ' ' | rev | cut -f 2-9 -d ' '`"
  28. if [ -e /mnt/sdb2"${AFILE}" ];then
  29. APATH="`dirname "$AFILE"`"
  30. [ ! -e "${APKGNAME}${APATH}" ] && mkdir -p "${APKGNAME}${APATH}"
  31. cp -a -f --remove-destination /mnt/sdb2"${AFILE}" "${APKGNAME}${APATH}"/
  32. fi
  33. ;;
  34. sym)
  35. ASYM="`echo -n "$ALINE" | cut -f 2 -d ' '`"
  36. if [ -e /mnt/sdb2"${ASYM}" ];then
  37. APATH="`dirname "$ASYM"`"
  38. [ ! -e "${APKGNAME}${APATH}" ] && mkdir -p "${APKGNAME}${APATH}"
  39. cp -a -f --remove-destination /mnt/sdb2"${ASYM}" "${APKGNAME}${APATH}"/
  40. fi
  41. ;;
  42. esac
  43. done
  44. fi
  45. sync
  46. done
  47. ###END###