From ef5a6bb5934506474d21e87cea1d4ba59e6facb1 Mon Sep 17 00:00:00 2001 From: Wichert Akkerman Date: Fri, 24 Dec 1999 16:28:10 +0000 Subject: [PATCH] From the ChangeLog * debian/control: add Build-Depends * THANKS: new file which lists everyone who contributed to the code * Change `Debian Linux' to `Debian GNU/Linux' in a couple of manpages * main/enquiry.c: modify list1package to use the full width of the tty * Merge patches from Adam Heath: + lib/mlib.c: new function do_fd_copy to read a file into a fd + dpkg-deb/build.c: use do_fd_copy + dpkg-deb/build.c: use dpkg-deb-filelist to reorder files when building a package + dpkg-deb/info.c: use do_fd_copy + lib/showcright.c: use do_fd_copy to read license + scripts/dpkg-safelist.{1,pl}: new script to reorder a filelist to make sure symlinks are listed after their targets. + dpkg-deb/main.c: add -z option to set compression level + dpkg-deb/build.c: pass new -z options to gzip * dpkg-deb/dpkg-deb.1: document new -z option --- ChangeLog | 23 +++++++++++++++++ THANKS | 50 +++++++++++++++++++++++++++++++++++++ debian/changelog | 5 ++++ debian/control | 2 ++ debian/rules | 2 +- dpkg-deb/build.c | 39 ++++++++++++++++++----------- dpkg-deb/dpkg-deb.1 | 6 +++++ dpkg-deb/dpkg-deb.h | 2 ++ dpkg-deb/info.c | 6 +---- dpkg-deb/main.c | 3 +++ include/dpkg.h.in | 3 +++ lib/mlib.c | 44 ++++++++++++++++++++++++++++++++ lib/showcright.c | 4 +-- main/enquiry.c | 40 +++++++++++++++++++++++------ main/main.c | 13 +++++----- scripts/Makefile.in | 6 +++-- scripts/dpkg-name.1 | 2 +- scripts/dpkg-scanpackages.8 | 2 +- 18 files changed, 211 insertions(+), 41 deletions(-) create mode 100644 THANKS diff --git a/ChangeLog b/ChangeLog index d5cbee61..cdf53044 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,26 @@ +Fri Dec 24 15:35:29 CET 1999 Wichert Akkerman + + * debian/control: add Build-Depends + * THANKS: new file which lists everyone who contributed to the code + * Change `Debian Linux' to `Debian GNU/Linux' in a couple of manpages + * main/enquiry.c: modify list1package to use the full width of the tty + * Merge patches from Adam Heath: + + lib/mlib.c: new function do_fd_copy to read a file into a fd + + dpkg-deb/build.c: use do_fd_copy + + dpkg-deb/build.c: use dpkg-deb-filelist to reorder files when + building a package + + dpkg-deb/info.c: use do_fd_copy + + lib/showcright.c: use do_fd_copy to read license + + scripts/dpkg-safelist.{1,pl}: new script to reorder a filelist to + make sure symlinks are listed after their targets. + + dpkg-deb/main.c: add -z option to set compression level + + dpkg-deb/build.c: pass new -z options to gzip + * dpkg-deb/dpkg-deb.1: document new -z option + +Wed Dec 22 13:41:41 CET 1999 Wichert Akkerman + + * main/main.c: cleanup printversion + Wed Dec 22 12:07:40 CET 1999 Wichert Akkerman * debian/dpkg-doc.postrm: Use doc-name instead of file-name (probably diff --git a/THANKS b/THANKS new file mode 100644 index 00000000..dcfdec68 --- /dev/null +++ b/THANKS @@ -0,0 +1,50 @@ +Adam Heath +Andrew Hobson +Ben Collins +Branko Lankester +Bruce Perens +Carl Streeter +Charles Briscoe-Smith +Charles Briscoe-Smith +Christophe Le Bars +Colin Plumb +Dan Gohman +Darren Stalder +Erick Branderhorst +Galen Hazelwood +Guy Maor +Heiko Schlittermann +Ian Jackson +Ian Murdock +J.H.M. Dassen +Jim Pick +Jim Van Zandt +Jim Van Zandt +Joel Klecker +Josip Rodin +Juan Cespedes +Juan Cespedes +Juergen Menden +Juho Vuori +Kim-Minh Kaplan +Klee Dienes +Marcus Brinkmann +Masato Taruishi +Matt Welsh +Michael Alan Dorman +Michael Shields +Michael Sobolev +Miquel van Smoorenburg +Nicolás Lichtmaier +Nils Rennebarth +Peter Karlsson +Petr Cech +Piotr Roszatycki +Raphael Hertzog +Richard Kettlewell +Roderick Schertler +Roman Hodek +Scott Barker +Tom Lees +Topi Miettinen +Wichert Akkerman diff --git a/debian/changelog b/debian/changelog index 47829816..fe6bfd48 100644 --- a/debian/changelog +++ b/debian/changelog @@ -4,6 +4,11 @@ dpkg (1.6.5) unstable; urgency=low * Correctly unregister internals manual, Closes: Bug# 53200 * dselect helpessages can be translated now, Closes: Bug# 51381 * dselect UI tweaks, including a new --expert mode + * Added build-depends, Closes: Bug# 53394 + * Added THANKS-file with people who have contributed to the code + * Use full width of tty in packagelisting, Closes: Bug# 53395 + * Add -z option to dpkg-deb to set compressionlevel when building + packages, Closes: Bug# 53398 -- Wichert Akkerman UNRELEASED diff --git a/debian/control b/debian/control index beaf8087..1eac54b7 100644 --- a/debian/control +++ b/debian/control @@ -3,6 +3,8 @@ Section: base Priority: required Maintainer: Wichert Akkerman Standards-Version: 3.1.0 +Build-Depends: debiandoc-sgml, ncurses-dev + Package: dpkg Architecture: any diff --git a/debian/rules b/debian/rules index 71adaef6..57f45e77 100755 --- a/debian/rules +++ b/debian/rules @@ -74,7 +74,7 @@ binary-dpkg: stamp-binary set -e ; for i in dpkg dpkg-deb dpkg-split md5sum dselect ; do \ mv $(TMP)/usr/bin/$$i $(TMP_DPKG)/usr/bin/ ; \ done - set -e ; for i in ChangeLog TODO copyright ; do \ + set -e ; for i in ChangeLog THANKS TODO copyright ; do \ mv $(TMP)/usr/share/doc/dpkg/$$i $(TMP_DPKG)/usr/share/doc/dpkg/ ; \ done set -e ; for i in "" ja ; do \ diff --git a/dpkg-deb/build.c b/dpkg-deb/build.c index 71c1c6b7..8e2581e4 100644 --- a/dpkg-deb/build.c +++ b/dpkg-deb/build.c @@ -252,12 +252,8 @@ void do_build(const char *const *argv) { } if (lseek(gzfd,0,SEEK_SET)) ohshite(_("failed to rewind tmpfile (control)")); - if (!(c3= m_fork())) { - m_dup2(gzfd,0); m_dup2(fileno(ar),1); - execlp(CAT,"cat",(char*)0); ohshite(_("failed to exec cat (control)")); - } - waitsubproc(c3,"cat (control)",0); - + do_fd_copy(gzfd, fileno(ar), _("control")); + if (!oldformatflag) { fclose(gz); if ((gzfd= mkstemp(tfbuf)) == -1) ohshite(_("failed to make tmpfile (data)")); @@ -270,23 +266,42 @@ void do_build(const char *const *argv) { strcpy(tfbuf,envbuf); strcat(tfbuf,"/dpkg.XXXXXX"); } + m_pipe(p1); + if (!(c3= m_fork())) { + m_dup2(p1[1],1); close(p1[0]); close(p1[1]); + if (chdir(directory)) ohshite(_("failed to chdir to `%.255s'"),directory); + execlp(SAFEFILELIST,"dpkg-deb-filelist",(char*)0); + ohshite(_("failed to exec dpkg-deb-filelist")); + } + close(p1[1]); m_pipe(p2); if (!(c4= m_fork())) { - m_dup2(p2[1],1); close(p2[0]); close(p2[1]); + m_dup2(p2[1],1); m_dup2(p1[0],0); close(p2[0]); close(p2[1]); if (chdir(directory)) ohshite(_("failed to chdir to `%.255s'"),directory); - execlp(TAR,"tar","--exclude",BUILDCONTROLDIR,"-cf","-",".",(char*)0); + execlp(TAR,"tar","--no-recursion", "--exclude",BUILDCONTROLDIR,"-T","-","-cf","-",(char*)0); ohshite(_("failed to exec tar --exclude")); } close(p2[1]); + close(p1[0]); if (!(c5= m_fork())) { + char *combuf; m_dup2(p2[0],0); close(p2[0]); m_dup2(oldformatflag ? fileno(ar) : gzfd,1); - execlp(GZIP,"gzip","-9c",(char*)0); + combuf = strdup("-9c"); + if(compression != NULL) { + if(*compression = '0') { + do_fd_copy(0, 1, _("no compression copy loop")); + exit(0); + } + combuf[1] = *compression; + } + execlp(GZIP,"gzip",combuf,(char*)0); ohshite(_("failed to exec gzip -9c from tar --exclude")); } close(p2[0]); waitsubproc(c5,"gzip -9c from tar --exclude",0); waitsubproc(c4,"tar --exclude",0); + waitsubproc(c3,"dpkg-deb-filelist",0); if (!oldformatflag) { if (fstat(gzfd,&datastab)) ohshite("_(failed to fstat tmpfile (data))"); if (fprintf(ar, @@ -298,11 +313,7 @@ void do_build(const char *const *argv) { werr(debar); if (lseek(gzfd,0,SEEK_SET)) ohshite(_("failed to rewind tmpfile (data)")); - if (!(c3= m_fork())) { - m_dup2(gzfd,0); m_dup2(fileno(ar),1); - execlp(CAT,"cat",(char*)0); ohshite(_("failed to exec cat (data)")); - } - waitsubproc(c3,"cat (data)",0); + do_fd_copy(gzfd, fileno(ar), _("data")); if (datastab.st_size & 1) if (putc('\n',ar) == EOF) diff --git a/dpkg-deb/dpkg-deb.1 b/dpkg-deb/dpkg-deb.1 index a235ff6b..589e5c57 100644 --- a/dpkg-deb/dpkg-deb.1 +++ b/dpkg-deb/dpkg-deb.1 @@ -60,6 +60,12 @@ appear in the binary package's filesystem archive, but instead the files in it will be put in the binary package's control information area. +You can specify the compressionlevel used by adding a +.B \-z# +option. +.B dpkg-deb +will pass that option on to gzip. + Unless you specify .BR \-\-nocheck ", " dpkg\-deb " will read diff --git a/dpkg-deb/dpkg-deb.h b/dpkg-deb/dpkg-deb.h index e48e29e2..589d6f47 100644 --- a/dpkg-deb/dpkg-deb.h +++ b/dpkg-deb/dpkg-deb.h @@ -33,6 +33,8 @@ extern dofunction *action; void extracthalf(const char *debar, const char *directory, const char *taroption, int admininfo); +extern char *compression; + #define DEBMAGIC "!\ndebian-binary " #define ADMINMEMBER "control.tar.gz " #define ADMINMEMBER_COMPAT "control.tar.gz/ " diff --git a/dpkg-deb/info.c b/dpkg-deb/info.c index 618e88c5..d9253558 100644 --- a/dpkg-deb/info.c +++ b/dpkg-deb/info.c @@ -90,11 +90,7 @@ static void info_spew(const char *debar, const char *directory, while ((component= *argv++) != 0) { co= fopen(component,"r"); if (co) { - if (!(c1= m_fork())) { - m_dup2(fileno(co),0); - execlp(CAT,"cat",(char*)0); ohshite(_("failed to exec cat component")); - } - waitsubproc(c1,"cat component",0); + do_fd_copy(fileno(co), 1, _("info_spew")); } else if (errno == ENOENT) { if (fprintf(stderr, _("dpkg-deb: `%.255s' contains no control component `%.255s'\n"), debar, component) == EOF) werr("stderr"); diff --git a/dpkg-deb/main.c b/dpkg-deb/main.c index 838ab8a4..f12dd80d 100644 --- a/dpkg-deb/main.c +++ b/dpkg-deb/main.c @@ -66,6 +66,7 @@ Usage: dpkg-deb -b|--build [] Build an archive.\n\ is the name of a field in the main `control' file.\n\ Options: -D for debugging output; --old or --new controls archive format;\n\ --nocheck to suppress control file check (build bad package).\n\ + -z# to set the compression when building \n\ Use `dpkg' to install and remove packages from your system, or\n\ `dselect' for user-friendly package management. Packages unpacked\n\ @@ -79,6 +80,7 @@ const char printforhelp[]= "Type dpkg --help for help about installing and deinstalling packages."); int debugflag=0, nocheckflag=0, oldformatflag=BUILDOLDPKGFORMAT; +const char* compression=NULL; const struct cmdinfo *cipaction=0; dofunction *action=0; @@ -118,6 +120,7 @@ static const struct cmdinfo cmdinfos[]= { { "old", 0, 0, &oldformatflag, 0, 0, 1 }, { "debug", 'D', 0, &debugflag, 0, 0, 1 }, { "nocheck", 0, 0, &nocheckflag, 0, 0, 1 }, + { "compression", 'z', 1, 0, &compression, 0, 1 }, { "help", 'h', 0, 0, 0, helponly }, { "version", 0, 0, 0, 0, versiononly }, { "licence", 0, 0, 0, 0, showcopyright }, /* UK spelling */ diff --git a/include/dpkg.h.in b/include/dpkg.h.in index 637f0e70..00444f49 100644 --- a/include/dpkg.h.in +++ b/include/dpkg.h.in @@ -120,6 +120,7 @@ #define DSELECT "dselect" #define DPKG "dpkg" +#define SAFEFILELIST "dpkg-safefilelist" #define TAR "tar" #define GZIP "gzip" #define CAT "cat" @@ -197,6 +198,8 @@ void m_pipe(int fds[2]); void checksubprocerr(int status, const char *description, int sigpipeok); void waitsubproc(pid_t pid, const char *description, int sigpipeok); +int do_fd_copy(int fd1, int fd2, char *desc); + extern volatile int onerr_abort; /*** from showcright.c ***/ diff --git a/lib/mlib.c b/lib/mlib.c index df8acc85..a700db02 100644 --- a/lib/mlib.c +++ b/lib/mlib.c @@ -122,3 +122,47 @@ void waitsubproc(pid_t pid, const char *description, int sigpipeok) { if (r != pid) { onerr_abort++; ohshite(_("wait for %s failed"),description); } checksubprocerr(status,description,sigpipeok); } + +int do_fd_copy(int fd1, int fd2, char *desc) { + char *buf, *sbuf; + int count; + char *er_msg_1 = _("failed to allocate buffer for copy (%s)"); + char *er_msg_2 = _("failed in copy on write (%s)"); + char *er_msg_3 = _("failed in copy on read (%s)"); + + count = strlen(er_msg_1) + strlen(desc) + 1; + sbuf = malloc(count); + if(sbuf == NULL) + ohshite(_("failed to allocate buffer for snprintf 1")); + snprintf(sbuf, count, er_msg_1, desc); + sbuf[count-1] = 0; + + buf = malloc(32768); + if(buf == NULL) + ohshite(sbuf); + free(sbuf); + + count = strlen(er_msg_2) + strlen(desc) + 1; + sbuf = malloc(count); + if(sbuf == NULL) + ohshite(_("failed to allocate buffer for snprintf 2")); + snprintf(sbuf, count, er_msg_2, desc); + sbuf[count-1] = 0; + + while((count = read(fd1, buf, 32768)) > 0) + if(write(fd2, buf, count) < count) + ohshite(sbuf); + + free(sbuf); + count = strlen(er_msg_3) + strlen(desc) + 1; + sbuf = malloc(count); + if(sbuf == NULL) + ohshite(_("failed to allocate buffer for snprintf 2")); + snprintf(sbuf, count, er_msg_3, desc); + sbuf[count-1] = 0; + + if(count < 0) + ohshite(_("failed in copy on read (control)")); + free(sbuf); + free(buf); +} diff --git a/lib/showcright.c b/lib/showcright.c index c327076b..c0236ce4 100644 --- a/lib/showcright.c +++ b/lib/showcright.c @@ -29,7 +29,5 @@ void showcopyright(const struct cmdinfo *c, const char *v) { int fd; fd= open(COPYINGFILE,O_RDONLY); if (fd < 0) ohshite(_("cannot open GPL file " COPYINGFILE)); - m_dup2(fd,0); - execlp(CAT,CAT,"-",(char*)0); - ohshite(_("unable to exec cat for displaying GPL file")); + do_fd_copy(fd, 1, _("showcopyright")); } diff --git a/main/enquiry.c b/main/enquiry.c index cdce2028..e164d9f3 100644 --- a/main/enquiry.c +++ b/main/enquiry.c @@ -27,6 +27,10 @@ #include #include #include +#include +#include +#include +#include #include #include @@ -55,24 +59,44 @@ static void limiteddescription(struct pkginfo *pkg, int maxl, *pdesc_r=pdesc; *l_r=l; } +static int getttywidth() { + int fd; + int res; + struct winsize ws; + + if ((fd=open("/dev/tty",O_RDONLY))!=-1) { + if (ioctl(fd, TIOCGWINSZ, &ws)==-1) + ws.ws_col=80; + close(fd); + } + return ws.ws_col; +} + static void list1package(struct pkginfo *pkg, int *head) { - int l; + int l,w; const char *pdesc; + char format[80]; + w=getttywidth()-(3+1+15+1+14+1+44); /* get spare width */ + w>>=1; /* halve that so we can add that to the both the name and description */ + sprintf(format,"%%c%%c%%c %%-%d.%ds %%-14.14s %%.*s\n", (14+w), (14+w)); + if (!*head) { fputs(_("\ Desired=Unknown/Install/Remove/Purge\n\ | Status=Not/Installed/Config-files/Unpacked/Failed-config/Half-installed\n\ -|/ Err?=(none)/Hold/Reinst-required/X=both-problems (Status,Err: uppercase=bad)\n\ -||/ Name Version Description\n\ -+++-===============-==============-============================================\n"), - stdout); +|/ Err?=(none)/Hold/Reinst-required/X=both-problems (Status,Err: uppercase=bad)\n"), stdout); + printf(format,'|','|','/', _("Name"), _("Version"), 40, _("Description")); + printf("+++-"); + for (l=0;l<(14+w);l++) printf("="); printf("-"); + printf("==============-"); + for (l=0;l<(44+w);l++) printf("="); + printf("\n"); *head= 1; } - if (!pkg->installed.valid) blankpackageperfile(&pkg->installed); - limiteddescription(pkg,44,&pdesc,&l); - printf("%c%c%c %-15.15s %-14.14s %.*s\n", + limiteddescription(pkg,(44+w),&pdesc,&l); + printf(format, "uihrp"[pkg->want], "nUFiHc"[pkg->status], " R?#"[pkg->eflag], diff --git a/main/main.c b/main/main.c index 16a1fd3e..c1148f92 100644 --- a/main/main.c +++ b/main/main.c @@ -41,13 +41,14 @@ #include "main.h" static void printversion(void) { - if (fputs(_("Debian Linux `dpkg' package management program version "), stdout) < 0) - werr("stdout"); + if (fputs(_("Debian Linux `"), stdout) < 0) werr("stdout"); + if (fputs(DPKG, stdout) < 0) werr("stdout"); + if (fputs(_("' package management program version "), stdout) < 0) werr("stdout"); if (fputs( DPKG_VERSION_ARCH ".\n", stdout) < 0) werr("stdout"); - if (fputs(_("Copyright 1994-1996 Ian Jackson, Bruce Perens. This is free software;\n" - "see the GNU General Public Licence version 2 or later for copying\n" - "conditions. There is NO warranty. See dpkg --licence for details.\n"), - stdout) < 0) werr("stdout"); + if (fputs(_( "This is free software; see the GNU General Public Licence version 2 or\n" + "later for copying conditions. There is NO warranty.\n" + "See dpkg --licence for copyright and license details.\n"), + stdout) < 0) werr("stdout"); } /* options that need fixing: diff --git a/scripts/Makefile.in b/scripts/Makefile.in index db49dd26..c73e8f0a 100644 --- a/scripts/Makefile.in +++ b/scripts/Makefile.in @@ -7,12 +7,14 @@ include ../Makefile.conf BIN_SCRIPTS = dpkg-name dpkg-source dpkg-genchanges \ dpkg-gencontrol dpkg-shlibdeps dpkg-buildpackage \ dpkg-parsechangelog dpkg-distaddfile 822-date \ - dpkg-scanpackages dpkg-scansources dpkg-architecture + dpkg-scanpackages dpkg-scansources dpkg-architecture \ + dpkg-safefilelist SBIN_SCRIPTS = update-rc.d update-alternatives install-info \ dpkg-divert cleanup-info -MAN1PAGES = dpkg-name.1 dpkg-source.1 822-date.1 dpkg-architecture.1 +MAN1PAGES = dpkg-name.1 dpkg-source.1 822-date.1 dpkg-architecture.1 \ + dpkg-safefilelist.1 MAN8PAGES = update-rc.d.8 update-alternatives.8 install-info.8 \ cleanup-info.8 dpkg-scanpackages.8 dpkg-scansources.8 \ dpkg-divert.8 diff --git a/scripts/dpkg-name.1 b/scripts/dpkg-name.1 index 6f7d2c0a..ee964c98 100644 --- a/scripts/dpkg-name.1 +++ b/scripts/dpkg-name.1 @@ -4,7 +4,7 @@ .\" This is free software; see the GNU General Public Licence version 2 .\" or later for copying conditions. There is NO warranty. .\" Time-stamp: <96/05/03 14:00:06 root> -.TH dpkg-name 1 "May 1996" "Debian Project" "Debian Linux" +.TH dpkg-name 1 "May 1996" "Debian Project" "Debian GNU/Linux" .SH NAME dpkg\-name \- rename Debian packages to full package names .SH SYNOPSIS diff --git a/scripts/dpkg-scanpackages.8 b/scripts/dpkg-scanpackages.8 index 827cc83e..5125a48e 100644 --- a/scripts/dpkg-scanpackages.8 +++ b/scripts/dpkg-scanpackages.8 @@ -13,7 +13,7 @@ .\" You should have received a copy of the GNU General Public .\" License along with dpkg; if not, write to the Free Software .\" Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -.TH DPKG-SCANPACKAGES 8 "1996-07-08" "Debian Linux" +.TH DPKG-SCANPACKAGES 8 "1996-07-08" "Debian GNU/Linux" .SH NAME dpkg-scanpackages \- create Packages files . -- 2.39.5