![pkgsrc의 압축 해제가 손상되었나요?](https://linux55.com/image/105766/pkgsrc%EC%9D%98%20%EC%95%95%EC%B6%95%20%ED%95%B4%EC%A0%9C%EA%B0%80%20%EC%86%90%EC%83%81%EB%90%98%EC%97%88%EB%82%98%EC%9A%94%3F.png)
우분투 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,이는 명령줄에 잘못된 옵션이 지정되었음을 의미합니다.. 왜? 옵션을 추가한 줄도 몰랐네요. 혼란스러워요.
그래서 우분투의 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이 되었음을 이해했습니다 .swich
uz_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