Estou tentando usar o pkgsrc no Ubuntu 16.04 LTS.
A instalação foi muito fácil.
$ cvs -q -z3 -d [email protected]:/cvsroot checkout -P pkgsrc
$ ./bootstrap --unprivileged
Depois instalei o pacote unzip da origem. Também parecia sucesso.
$ cd pkgsrc/archivers/unzip/
$ bmake
$ bmake install
$ which unzip
/home/xxxx/pkg/bin/unzip
No entanto, não funcionou quando foi executado.
$ 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
O código de erro era 10, que significa que opções inválidas foram especificadas na linha de comando .
Por quê? Eu não acho que adicionei nenhuma opção. Eu estava confuso.
Então eu deletei o unzip do pkgsrc para comparar o unzip do ubuntu e funcionou.
$ pkg_delete unzip
$ which unzip
/usr/bin/unzip
$ /usr/bin/unzip aaa.zip
Archive: aaa.zip
extracting: aaa.txt
$ls
aaa.txt aaa.zip
A descompactação do pkgsrc está quebrada? ou ignorei algumas configurações que tinha que fazer?
atualização (2017-2-19 14:30) :
Estou lendo o código fonte do pkgsrc (pkgsrc / archivers / unzip). é gerado após bmake
.
Até agora, eu mudei parcialmente unzip.c da seguinte forma:
-- 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 {
...
}
}
Com essa alteração, entendi que argc e argv foram alterados antes de uz_opts()
in unzip()
. E a opção -O CP932
, que é adicionada internamente, não existe na instrução swich
em uz_opts()
, que causa o código de saída 10.
$ 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
Então eu verifiquei as variáveis de ambiente, está lá ...
$env
...
...
UNZIP=-O CP932
O que é isto? Não consegui confirmar no meu .profile
e .bashrc.