create-test-data 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #!/bin/sh
  2. set +e # its okay to fail in these script, most of the time the apt* stuff will generate errors
  3. if [ -z "$1" -o -z "$2" ]; then
  4. echo "Usage: $0 file codename pkg…"
  5. exit 1
  6. fi
  7. TESTDIR="$(readlink -f "$(dirname "$0")")"
  8. . "$TESTDIR/framework"
  9. BUILDDIRECTORY="${TESTDIR}/../../build/bin"
  10. GENERATE=$1
  11. CODENAME=$2
  12. shift 2
  13. WORKDIR=$(mktemp -d)
  14. trap "rm -rf $WORKDIR" 0 HUP INT QUIT ILL ABRT FPE SEGV PIPE TERM
  15. touch $WORKDIR/status
  16. TMPGEN=$WORKDIR/Packages
  17. export LANG=C
  18. LISTOFPKGS=$(aptget install $* -t $CODENAME -so Dir::state::status=$WORKDIR/status -o Dir::Cache::archives=$WORKDIR -o pkgCacheGen::Essential=none -o APT::Immediate-Configure=0 2> /dev/null | awk '/^Inst/ {print $2}' | sed -e "s#\$#/$CODENAME#")
  19. if [ -z "$LISTOFPKGS" ]; then
  20. echo "List of packages is empty: run apt-get install command again for you now"
  21. aptget install $* -t $CODENAME -so Dir::state::status=$WORKDIR/status -o Dir::Cache::archives=$WORKDIR -o pkgCacheGen::Essential=none -o APT::Immediate-Configure=0
  22. exit 1
  23. fi
  24. aptcache show $LISTOFPKGS --no-all-versions 2> $WORKDIR/error.lst > $TMPGEN
  25. sed -i $TMPGEN \
  26. -e '/^ / d' \
  27. -e '/^SHA1: / d' -e '/^SHA256: / d' \
  28. -e '/^Homepage: / d' -e '/^Tag: / d' \
  29. -e '/^Xul-Appid: / d' \
  30. -e '/^Status: / d'
  31. if [ "$CODENAME" = "experimental" ]; then
  32. aptcache show $(cat $WORKDIR/error.lst | cut -d"'" -f 4 | sed -e 's#$#/sid#') --no-all-versions 2> /dev/null >> $TMPGEN
  33. fi
  34. if echo "$GENERATE" | grep '^status-' > /dev/null; then
  35. sed -i $TMPGEN -e '/^Package: / a\
  36. Status: install ok installed' \
  37. -e '/^Filename: / d' -e '/^Size: / d' -e '/^MD5sum: / d'
  38. fi
  39. apt-sortpkgs $TMPGEN > $GENERATE