]> git.saurik.com Git - apt.git/commitdiff
support '-' and no parameter for stdin in apt-helper cat-file
authorDavid Kalnischkies <david@kalnischkies.de>
Thu, 7 Jan 2016 23:35:39 +0000 (00:35 +0100)
committerDavid Kalnischkies <david@kalnischkies.de>
Fri, 8 Jan 2016 14:40:01 +0000 (15:40 +0100)
This way it works more similar to the compressor binaries, which we
can relief in this way from their job in the test framework avoiding the
need of adding e.g. liblz4-tool to the test dependencies.

cmdline/apt-helper.cc
test/integration/framework

index 001b5e5f778db86bf9b79e1a33dc23c59fa9c45f..b92055ab7883e8f024ee781ca71f2e61e71f943a 100644 (file)
@@ -145,14 +145,28 @@ static bool DoCatFile(CommandLine &CmdL)                          /*{{{*/
    }
 
    if (CmdL.FileSize() <= 1)
    }
 
    if (CmdL.FileSize() <= 1)
-      return _error->Error("Must specify at least one file name");
+   {
+      if (fd.OpenDescriptor(STDIN_FILENO, FileFd::ReadOnly) == false)
+        return false;
+      if (CopyFile(fd, out) == false)
+         return false;
+      return true;
+   }
 
    for(size_t i = 1; CmdL.FileList[i] != NULL; ++i)
    {
       std::string const name = CmdL.FileList[i];
 
 
    for(size_t i = 1; CmdL.FileList[i] != NULL; ++i)
    {
       std::string const name = CmdL.FileList[i];
 
-      if (fd.Open(name, FileFd::ReadOnly, FileFd::Extension) == false)
-         return false;
+      if (name != "-")
+      {
+        if (fd.Open(name, FileFd::ReadOnly, FileFd::Extension) == false)
+           return false;
+      }
+      else
+      {
+        if (fd.OpenDescriptor(STDIN_FILENO, FileFd::ReadOnly) == false)
+           return false;
+      }
 
       if (CopyFile(fd, out) == false)
          return false;
 
       if (CopyFile(fd, out) == false)
          return false;
index c97500ffd0bf1ff27780f2bbbe7d56693cecad61..430ee552d241fa03462686e264f3a76b2a2a6c98 100644 (file)
@@ -520,13 +520,13 @@ EOF
        testsuccess --nomsg gcc -Wall -fPIC -shared -o noopchroot.so noopchroot.c -ldl
 }
 configcompression() {
        testsuccess --nomsg gcc -Wall -fPIC -shared -o noopchroot.so noopchroot.c -ldl
 }
 configcompression() {
+       local CMD='apthelper cat-file -C'
        while [ -n "$1" ]; do
                case "$1" in
                '.') printf ".\t.\tcat\n";;
        while [ -n "$1" ]; do
                case "$1" in
                '.') printf ".\t.\tcat\n";;
-               'gz') printf "gzip\tgz\tgzip\n";;
-               'bz2') printf "bzip2\tbz2\tbzip2\n";;
-               'lzma') printf "lzma\tlzma\txz --format=lzma\n";;
-               *) printf "$1\t$1\t$1\n";;
+               'gz') printf "gzip\tgz\t$CMD $1\n";;
+               'bz2') printf "bzip2\tbz2\t$CMD $1\n";;
+               *) printf "$1\t$1\t$CMD $1\n";;
                esac
                shift
        done > "${TMPWORKINGDIRECTORY}/rootdir/etc/testcase-compressor.conf"
                esac
                shift
        done > "${TMPWORKINGDIRECTORY}/rootdir/etc/testcase-compressor.conf"
@@ -550,7 +550,7 @@ confighashes() {
 forcecompressor() {
        COMPRESSOR="$1"
        COMPRESS="$1"
 forcecompressor() {
        COMPRESSOR="$1"
        COMPRESS="$1"
-       COMPRESSOR_CMD="$1"
+       COMPRESSOR_CMD="apthelper cat-file -C $1"
        case $COMPRESSOR in
        gzip) COMPRESS='gz';;
        bzip2) COMPRESS='bz2';;
        case $COMPRESSOR in
        gzip) COMPRESS='gz';;
        bzip2) COMPRESS='bz2';;
@@ -558,20 +558,6 @@ forcecompressor() {
        local CONFFILE="${TMPWORKINGDIRECTORY}/rootdir/etc/apt/apt.conf.d/00force-compressor"
        echo "Acquire::CompressionTypes::Order { \"${COMPRESS}\"; };
 Dir::Bin::uncompressed \"/does/not/exist\";" > "$CONFFILE"
        local CONFFILE="${TMPWORKINGDIRECTORY}/rootdir/etc/apt/apt.conf.d/00force-compressor"
        echo "Acquire::CompressionTypes::Order { \"${COMPRESS}\"; };
 Dir::Bin::uncompressed \"/does/not/exist\";" > "$CONFFILE"
-       for COMP in $(aptconfig dump APT::Compressor --format '%t %v%n' | sed -n 's#^Name \([^.].\+\)$#\1#p'); do
-               echo "Dir::Bin::${COMP} \"/does/not/exist\";"
-       done >> "$CONFFILE"
-       if [ -e "/bin/${COMPRESSOR}" ]; then
-               echo "Dir::Bin::${COMPRESSOR} \"/bin/${COMPRESSOR}\";" >> "$CONFFILE"
-       elif [ -e "/usr/bin/${COMPRESSOR}" ]; then
-               echo "Dir::Bin::${COMPRESSOR} \"/usr/bin/${COMPRESSOR}\";" >> "$CONFFILE"
-       elif [ "${COMPRESSOR}" = 'lzma' ]; then
-               echo 'Dir::Bin::xz "/usr/bin/xz";' >> "$CONFFILE"
-               COMPRESSOR_CMD='xz --format=lzma'
-       else
-               msgtest 'Test for availability of compressor' "${COMPRESSOR}"
-               msgfail "${COMPRESSOR} not available"
-       fi
 }
 
 setupsimplenativepackage() {
 }
 
 setupsimplenativepackage() {