pkgsrcの解凍が壊れていますか?

pkgsrcの解凍が壊れていますか?

Ubuntu 16.04 LTSでpkgsrcを使用しようとしています。

インストールが簡単です。

$ cvs -q -z3 -d [email protected]:/cvsroot checkout -P pkgsrc
$ ./bootstrap --unprivileged

その後、ソースから解凍したパッケージをインストールしました。それも非常に正常に見えます。

$ cd pkgsrc/archivers/unzip/
$ bmake
$ bmake install
$ which unzip
/home/xxxx/pkg/bin/unzip

しかし、実行時には動作しませんでした。

$ cd ~

$ ls
aaa.zip

$unzip aaa.zip
UnZip 6.00 of 20 April 2009, by Info-ZIP.  Maintained by C. Spieler.  Send
bug reports using http://www.info-zip.org/zip-bug.html; see README for details.

Usage: unzip [-Z] [-opts[modifiers]] file[.zip] [list] [-x xlist] [-d exdir]
  Default action is to extract files in list, except those in xlist, to exdir;
  file[.zip] may be a wildcard.  -Z => ZipInfo mode ("unzip -Z" for usage).

  -p  extract files to pipe, no messages     -l  list files (short format)
  -f  freshen existing files, create none    -t  test compressed archive data
  -u  update files, create if necessary      -z  display archive comment only
  -v  list verbosely/show version info       -T  timestamp archive to latest
  -x  exclude files that follow (in xlist)   -d  extract files into exdir
modifiers:
  -n  never overwrite existing files         -q  quiet mode (-qq => quieter)
  -o  overwrite files WITHOUT prompting      -a  auto-convert any text files
  -j  junk paths (do not make directories)   -aa treat ALL files as text
  -C  match filenames case-insensitively     -L  make (some) names lowercase
  -X  restore UID/GID info                   -V  retain VMS version numbers
  -K  keep setuid/setgid/tacky permissions   -M  pipe through "more" pager
See "unzip -hh" or unzip.txt for more help.  Examples:
  unzip data1 -x joe   => extract all files except joe from zipfile data1.zip
  unzip -p foo | more  => send contents of foo.zip via pipe into program more
  unzip -fo foo ReadMe => quietly replace existing ReadMe if archive file newer

$ echo $?
10

$ ls
aaa.zip

エラーコードは10、これは、コマンドラインに無効なオプションが指定されたことを意味します。。なぜ?オプションを追加したことも知りませんでした。混乱しています。

そのため、Ubuntuのunzipを比較するためにpkgsrcのunzipを削除しましたが、結果は成功しました。

$ pkg_delete unzip

$ which unzip
/usr/bin/unzip

$ /usr/bin/unzip aaa.zip
Archive:  aaa.zip
 extracting: aaa.txt

$ls
aaa.txt aaa.zip

pkgsrcの解凍が壊れていますか?それとも私が作るべきいくつかの設定を見落としましたか?

アップデート(2017-2-19 14:30): pkgsrc(pkgsrc/archivers/unzip) のソースコードを読み込んでいます。その後に生成されますbmake。これまでunzip.cを次のように一部変更しました。

-- unzip.c --
int MAIN(argc, argv)
  int argc;
  char *argv[];
{
  int r;

  CONSTRUCTGLOBALS();

  /* for debug ----> */
  int hoge;
  printf("argc %d\n", argc);
  for(hoge = 0; hoge < argc; hoge++){
     printf("argv[%d] %s\n", hoge, argv[hoge]);
  }
  /* for debug <---- */
    r = unzip(__G__ argc, argv);
    DESTROYGLOBALS();
    RETURN(r);
} 

....
....
int unzip(__G__ argc, argv)
  __GDEF
  int argc;
  char *argv[];
{
....
....
#endif /* !NO_ZIPINFO */

      /* for debug ----> */
      printf("argc: %d\n", argc);
      printf("&argc: %d\n", &argc);
      int hoge = 0;
      for(hoge = 0; hoge < argc; hoge++){
        printf("argv[%d]: %s\n", hoge, argv[hoge]);
      }
      /* for debug <---- */

      error = uz_opts(__G__ &argc, &argv);
}

int uz_opts(__G__ pargc, pargv)
  __GDEF
  int *pargc;
  char ***pargv;
{
...
...
  while (++argv, (--argc > 0 && *argv != NULL && **argv == '-')) {
    s = *argv + 1;
    while ((c = *s++) != 0) {    /* "!= 0":  prevent Turbo C warning */

    /* for debug ----> */
    printf("c: %c\n",c);
    /* for debug <---- */

#ifdef CMS_MVS
        switch (tolower(c))
#else
        switch (c)
#endif
       {
       case ('-'):
         ++negative;
         break;
       ...
       ...
       default:
         printf("SET ERROR\n"); /* for debug */
         error = TRUE;
         break;
       }
...
...
#endif /* !SFX */
  return USAGE(error);
...
...
}

#else /* !SFX */
#  ifdef VMS
#    define QUOT '\"'
#    define QUOTS "\""
#  else
#    define QUOT ' '
#    define QUOTS ""
#  endif

int usage(__G__ error)   /* return PK-type error code */
  __GDEF
  int error;
{
  if (error){
    /* for debug ----> */
    puts("PK_PARAM: L");
    /* for debug <---- */
    return PK_PARAM;
  } else {
  ...
  }
}

uz_opts()この変更により、argcとargvが以前にunzip()存在し-O CP932、内部的に追加されたオプションがinステートメントに存在しなかったため、終了コードが10になったことがわかりました。swichuz_opts()

$ unzip aaa.zip
argc 2
argv[0] unzip
argv[1] /home/xxxx/aaa.zip
argc: 4
&argc: -740106452
argv[0]: unzip
argv[1]: -O
argv[2]: CP932
argv[3]: /home/xxxx/aaa.zip
c: O
SET ERROR
UnZip 6.00 of 20 April 2009, by Info-ZIP.  Maintained by C. Spieler.  Send
bug reports using http://www.info-zip.org/zip-bug.html; see README for details.

Usage: unzip [-Z] [-opts[modifiers]] file[.zip] [list] [-x xlist] [-d exdir]
  Default action is to extract files in list, except those in xlist, to exdir;
  file[.zip] may be a wildcard.  -Z => ZipInfo mode ("unzip -Z" for usage).

  -p  extract files to pipe, no messages     -l  list files (short format)
  -f  freshen existing files, create none    -t  test compressed archive data
  -u  update files, create if necessary      -z  display archive comment only
  -v  list verbosely/show version info       -T  timestamp archive to latest
  -x  exclude files that follow (in xlist)   -d  extract files into exdir
modifiers:
  -n  never overwrite existing files         -q  quiet mode (-qq => quieter)
  -o  overwrite files WITHOUT prompting      -a  auto-convert any text files
  -j  junk paths (do not make directories)   -aa treat ALL files as text
  -C  match filenames case-insensitively     -L  make (some) names lowercase
  -X  restore UID/GID info                   -V  retain VMS version numbers
  -K  keep setuid/setgid/tacky permissions   -M  pipe through "more" pager
See "unzip -hh" or unzip.txt for more help.  Examples:
  unzip data1 -x joe   => extract all files except joe from zipfile data1.zip
  unzip -p foo | more  => send contents of foo.zip via pipe into program more
  unzip -fo foo ReadMe => quietly replace existing ReadMe if archive file newer
PK_PARAM: L

それから環境変数を確認しましたが、そこにいました。

$env
...
... 
UNZIP=-O CP932

これは何ですか?.profile私と私の間には割れません。.bashrc.

ベストアンサー1

この問題の原因を理解してください。これは環境変数です。

$ env | sort
...
...
UNZIP=-O CP932

~によるとこのページ(申し訳ありませんが、日本語で書かれています。)UNZIPこの変数は、マルチバイト文字(日本語文字など)を含むWindowsで作成されたzipアーカイブを抽出するために必要です。この変数は日本語版のUbuntu unpackから得られたようです。

したがって、次のようにUNZIP変数を無効にする必要があります。

$ UNZIP='' unzip aaa.zip
Archive:  aaa.zip
 extracting: aaa.txt

$ ls
aaa.zip aaa.txt

おすすめ記事