From: Ben Collins Date: Tue, 19 Oct 1999 22:14:43 +0000 (+0000) Subject: * Ok, TMPDIR usage is back in dpkg-deb and working X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=60e79bfff735323d5291de6f8d02080cf731f087;p=dpkg * Ok, TMPDIR usage is back in dpkg-deb and working * {include,scripts}/Makefile.am: Fix for using DESTDIR * debian/rules: really convert to DESTDIR on install target this time. chmod -x everything in /usr/lib to make lintian happy. in the clean phase just rm -rf $(BUILD), we don't need to run distclean and all that other stuff. Don't run "make dist", we simply copy the .tar.gz that dpkg-source creates for the byhand source. --- diff --git a/ChangeLog b/ChangeLog index b12d6460..89a2e86e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +Tue Oct 19 18:07:28 EDT 1999 Ben Collins + + * Ok, TMPDIR usage is back in dpkg-deb and working + * {include,scripts}/Makefile.am: Fix for using DESTDIR + * debian/rules: really convert to DESTDIR on install target this + time. chmod -x everything in /usr/lib to make lintian happy. + in the clean phase just rm -rf $(BUILD), we don't need to run + distclean and all that other stuff. Don't run "make dist", we + simply copy the .tar.gz that dpkg-source creates for the byhand + source. + Tue Oct 19 09:59:22 EDT 1999 Ben Collins * Reverted the new tmpfile stuff in dpkg-deb. For some reason it's diff --git a/debian/changelog b/debian/changelog index 644c5e0f..5309f2f4 100644 --- a/debian/changelog +++ b/debian/changelog @@ -43,6 +43,11 @@ dpkg (1.4.1.17) unstable; urgency=low * Increased largemem auto detection to >= 24megs, since it's not uncommon for dpkg to actually use 16megs of ram all on its own when using the largemem setting (old minimum was 16megs) + * debian/rules: chmod -x everything in /usr/lib to make lintian happy. + in the clean phase just rm -rf $(BUILD), we don't need to run + distclean and all that other stuff. Don't run "make dist", we + simply copy the .tar.gz that dpkg-source creates for the byhand + source. -- Wichert Akkerman UNRELEASED diff --git a/debian/rules b/debian/rules index eb95800f..fde8bfe4 100755 --- a/debian/rules +++ b/debian/rules @@ -32,11 +32,8 @@ $(BUILD)/config.status: clean: $(checkdir) - -$(MAKE) -C $(BUILD) -i distclean - $(RM) -r debian/{build,files,substvars,tmp*} - $(RM) $(BUILD)/dpkg-*.tar.gz - $(RM) po/*.gmo - $(RM) config.log + $(RM) -r debian/{files,substvars,tmp*} + $(RM) -r $(BUILD) find . \( -name '*~' -o -name '#*#' \) -print0 | xargs -r0 $(RM) -- build: $(BUILD)/config.status @@ -65,16 +62,7 @@ binary-trees: build debian/tmp-dev/etc/dpkg/shlibs.default ; \ fi cp debian/{prerm,postinst} $(mcidir)/. - $(MAKE) -C $(BUILD) top_distdir=. dist - $(MAKE) -C $(BUILD) \ - prefix=$(DIR)/debian/tmp-main/usr \ - sysconfdir=$(DIR)/debian/tmp-main/etc \ - datadir=$(DIR)/debian/tmp-main/usr/share \ - mandir=$(DIR)/debian/tmp-main/usr/share/man \ - infodir=$(DIR)/debian/tmp-main/usr/share/info \ - sharedstatedir=$(DIR)/debian/tmp-main/var/lib \ - localstatedir=$(DIR)/debian/tmp-main/var/lib \ - install + $(MAKE) -C $(BUILD) DESTDIR=$(DIR)/debian/tmp-main install install -m 755 debian/dev-postinst debian/tmp-dev/DEBIAN/postinst install -m 755 debian/dev-prerm debian/tmp-dev/DEBIAN/prerm install -d debian/tmp-dev/etc/emacs/site-start.d @@ -97,6 +85,7 @@ binary-trees: build ln -s ../man7/undocumented.7.gz debian/tmp-main/usr/share/man/man1/dpkg-divert.1.gz gzip -9vf debian/tmp-main/usr/share/doc/dpkg/changelog* cp debian/copyright debian/tmp-main/usr/share/doc/dpkg/copyright + chmod -x `find debian/tmp-{main,dev}/usr/lib -type f` ln -s dpkg debian/tmp-dev/usr/share/doc/dpkg-dev set -e; for f in \ usr/share/doc/dpkg/{internals.html,changelog.manuals.gz} \ @@ -138,7 +127,7 @@ binary-indep: binary-trees set -e; \ version=`sed -n 's/^Version: //p' $(DIR)/debian/tmp-dev/DEBIAN/control`; \ file=dpkg-$${version}.tar.gz; \ - cp $(BUILD)/$${file} $(DIR)/..; \ + cp $(DIR)/../dpkg_$${version}.tar.gz $(DIR)/../$${file}; \ dpkg-distaddfile -f$(DIR)/debian/files $${file} byhand -; binary-arch: binary-trees diff --git a/dpkg-deb/build.c b/dpkg-deb/build.c index d02ae0e8..51f91acd 100644 --- a/dpkg-deb/build.c +++ b/dpkg-deb/build.c @@ -59,17 +59,23 @@ void do_build(const char *const *argv) { char *m; const char *debar, *directory, *const *mscriptp, *versionstring, *arch; - char *controlfile; + char *controlfile, *tfbuf, *envbuf; struct pkginfo *checkedinfo; struct arbitraryfield *field; FILE *ar, *gz, *cf; - int p1[2],p2[2], warns, errs, n, c, subdir; + int p1[2],p2[2], warns, errs, n, c, subdir, gzfd; pid_t c1,c2,c3,c4,c5; struct stat controlstab, datastab, mscriptstab, debarstab; char conffilename[MAXCONFFILENAME+1]; time_t thetime= 0; directory= *argv++; if (!directory) badusage(_("--build needs a directory argument")); + /* template for our tempfiles */ + if ((envbuf= getenv("TMPDIR")) == NULL) + envbuf= P_tmpdir; + tfbuf = (char *)malloc(strlen(envbuf)+13); + strcpy(tfbuf,envbuf); + strcat(tfbuf,"/dpkg.XXXXXX"); subdir= 0; if ((debar= *argv++) !=0) { if (*argv) badusage(_("--build takes at most two arguments")); @@ -209,15 +215,23 @@ void do_build(const char *const *argv) { execlp(TAR,"tar","-cf","-",".",(char*)0); ohshite(_("failed to exec tar -cf")); } close(p1[1]); - if (!(gz= tmpfile())) ohshite(_("failed to make tmpfile (control)")); + if ((gzfd= mkstemp(tfbuf)) == -1) ohshite(_("failed to make tmpfile (control)")); + if ((gz= fdopen(gzfd,"a")) == NULL) ohshite(_("failed to open tmpfile " + "(control), %s"), tfbuf); + /* make sure it's gone, the fd will remain until we close it */ + if (unlink(tfbuf)) ohshit(_("failed to unlink tmpfile (control), %s"), + tfbuf); + /* reset this, so we can use it elsewhere */ + strcpy(tfbuf,envbuf); + strcat(tfbuf,"/dpkg.XXXXXX"); if (!(c2= m_fork())) { - m_dup2(p1[0],0); m_dup2(fileno(gz),1); close(p1[0]); + m_dup2(p1[0],0); m_dup2(gzfd,1); close(p1[0]); execlp(GZIP,"gzip","-9c",(char*)0); ohshite(_("failed to exec gzip -9c")); } close(p1[0]); waitsubproc(c2,"gzip -9c",0); waitsubproc(c1,"tar -cf",0); - if (fstat(fileno(gz),&controlstab)) ohshite(_("failed to fstat tmpfile (control)")); + if (fstat(gzfd,&controlstab)) ohshite(_("failed to fstat tmpfile (control)")); if (oldformatflag) { if (fprintf(ar, "%-8s\n%ld\n", OLDARCHIVEVERSION, (long)controlstab.st_size) == EOF) werr(debar); @@ -237,16 +251,24 @@ void do_build(const char *const *argv) { werr(debar); } - if (lseek(fileno(gz),0,SEEK_SET)) ohshite(_("failed to rewind tmpfile (control)")); + if (lseek(gzfd,0,SEEK_SET)) ohshite(_("failed to rewind tmpfile (control)")); if (!(c3= m_fork())) { - m_dup2(fileno(gz),0); m_dup2(fileno(ar),1); + 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); if (!oldformatflag) { fclose(gz); - if (!(gz= tmpfile())) ohshite(_("failed to make tmpfile (data)")); + if ((gzfd= mkstemp(tfbuf)) == -1) ohshite(_("failed to make tmpfile (data)")); + if ((gz= fdopen(gzfd,"a")) == NULL) ohshite(_("failed to open tmpfile " + "(data), %s"), tfbuf); + /* make sure it's gone, the fd will remain until we close it */ + if (unlink(tfbuf)) ohshit(_("failed to unlink tmpfile (data), %s"), + tfbuf); + /* reset these, in case we want to use the later */ + strcpy(tfbuf,envbuf); + strcat(tfbuf,"/dpkg.XXXXXX"); } m_pipe(p2); if (!(c4= m_fork())) { @@ -258,7 +280,7 @@ void do_build(const char *const *argv) { close(p2[1]); if (!(c5= m_fork())) { m_dup2(p2[0],0); close(p2[0]); - m_dup2(oldformatflag ? fileno(ar) : fileno(gz),1); + m_dup2(oldformatflag ? fileno(ar) : gzfd,1); execlp(GZIP,"gzip","-9c",(char*)0); ohshite(_("failed to exec gzip -9c from tar --exclude")); } @@ -266,7 +288,7 @@ void do_build(const char *const *argv) { waitsubproc(c5,"gzip -9c from tar --exclude",0); waitsubproc(c4,"tar --exclude",0); if (!oldformatflag) { - if (fstat(fileno(gz),&datastab)) ohshite("_(failed to fstat tmpfile (data))"); + if (fstat(gzfd,&datastab)) ohshite("_(failed to fstat tmpfile (data))"); if (fprintf(ar, "%s" DATAMEMBER "%-12lu0 0 100644 %-10ld`\n", @@ -275,9 +297,9 @@ void do_build(const char *const *argv) { (long)datastab.st_size) == EOF) werr(debar); - if (lseek(fileno(gz),0,SEEK_SET)) ohshite(_("failed to rewind tmpfile (data)")); + if (lseek(gzfd,0,SEEK_SET)) ohshite(_("failed to rewind tmpfile (data)")); if (!(c3= m_fork())) { - m_dup2(fileno(gz),0); m_dup2(fileno(ar),1); + 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); diff --git a/dpkg-deb/info.c b/dpkg-deb/info.c index 438d76fd..618e88c5 100644 --- a/dpkg-deb/info.c +++ b/dpkg-deb/info.c @@ -59,12 +59,13 @@ static void info_prepare(const char *const **argvp, const char **debarp, const char **directoryp, int admininfo) { - static char dbuf[L_tmpnam]; + static char *dbuf; pid_t c1; *debarp= *(*argvp)++; if (!*debarp) badusage(_("--%s needs a .deb filename argument"),cipaction->olong); - if (!tmpnam(dbuf)) ohshite(_("failed to make temporary filename")); + if ((dbuf= tempnam(NULL,"dpkg")) == NULL) + ohshite(_("failed to make temporary filename")); *directoryp= dbuf; if (!(c1= m_fork())) { diff --git a/include/Makefile.am b/include/Makefile.am index 031773a4..6e54d761 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -29,12 +29,12 @@ MAINTAINERCLEANFILES = $(srcdir)/Makefile.in .PHONY: install-data-local uninstall-local install-data-local: - $(mkinstalldirs) $(pkglocalstatedir)/{$(pinfo_suffix),$(pupdates_suffix)} + $(mkinstalldirs) $(DESTDIR)$(pkglocalstatedir)/{$(pinfo_suffix),$(pupdates_suffix)} uninstall-local: -for d in $(pkglocalstatedir)/{$(pinfo_suffix),$(pupdates_suffix)} \ $(pkgincludedir) $(pkglocalstatedir) $(pkglocalstatedir); do \ - [ -e $$d ] && rmdir $$d; \ + [ -e $$d ] && rmdir $(DESTDIR)$$d; \ done dpkg.h: stamp-dpkg.h diff --git a/methods/Makefile.am b/methods/Makefile.am index f338c4df..7d092fb8 100644 --- a/methods/Makefile.am +++ b/methods/Makefile.am @@ -26,62 +26,73 @@ MAINTAINERCLEANFILES = $(srcdir)/Makefile.in install-exec-local dist-hook uninstall-local install-data-local: install-methods-data install-descs-data - $(mkinstalldirs) $(methodsmnt) + $(mkinstalldirs) $(DESTDIR)$(methodsmnt) install-methods-data: set -e; for m in $(METHODS); do \ - $(mkinstalldirs) $(methodsdir)/$$m $(methodsdatadir)/$$m; \ - $(INSTALL_DATA) $(srcdir)/$$m.names $(methodsdir)/$$m/names; \ + $(mkinstalldirs) $(DESTDIR)$(methodsdir)/$$m \ + $(DESTDIR)$(methodsdatadir)/$$m; \ + $(INSTALL_DATA) $(srcdir)/$$m.names \ + $(DESTDIR)$(methodsdir)/$$m/names; \ done install-descs-data: set -e; for x in $(DESCS); do \ d=`echo $$x | sed 's:.*/\([^/]*\)$$:\1:; s:\.:/:'`; \ - $(INSTALL_DATA) $(srcdir)/$$x $(methodsdir)/$$d; \ + $(INSTALL_DATA) $(srcdir)/$$x $(DESTDIR)$(methodsdir)/$$d; \ done install-exec-local: set -e; for m in $(METHODS); do \ - $(mkinstalldirs) $(methodsdir)/$$m $(methodsdatadir)/$$m; \ + $(mkinstalldirs) $(DESTDIR)$(methodsdir)/$$m \ + $(DESTDIR)$(methodsdatadir)/$$m; \ done set -e; for m in $(METHODS); do \ for s in $(MSCRIPTS); do \ - $(INSTALL_PROGRAM) $(srcdir)/$$m.$$s $(methodsdir)/$$m/$$s; \ + $(INSTALL_PROGRAM) $(srcdir)/$$m.$$s \ + $(DESTDIR)$(methodsdir)/$$m/$$s; \ done; \ done uninstall-local: -for m in $(METHODS); do \ - rm -f $(methodsdir)/$$m/names; \ - [ -e $(methodsdir)/$$m ] && rmdir $(methodsdir)/$$m; \ + rm -f $(DESTDIR)$(methodsdir)/$$m/names; \ + [ -e $(DESTDIR)$(methodsdir)/$$m ] && rmdir \ + $(DESTDIR)$(methodsdir)/$$m; \ done -for x in $(DESCS); do \ d=`echo $$x | sed 's:\.:/:'`; \ dir=`echo $$d | sed 's:\(.*\)/[^/]*$$:\1:'`; \ - rm -f $(methodsdir)/$$d; \ - [ -e $$dir ] && rmdir $$dir; \ + rm -f $(DESTDIR)$(methodsdir)/$$d; \ + [ -e $(DESTDIR)$$dir ] && rmdir $(DESTDIR)$$dir; \ done -for m in $(METHODS); do \ for s in $(MSCRIPTS); do \ - rm -f $(methodsdir)/$$m/$$s; \ + rm -f $(DESTDIR)$(methodsdir)/$$m/$$s; \ done; \ - [ -e $(methodsdir)/$$m ] && rmdir $(methodsdir)/$$m; \ - [ -e $(methodsdatadir)/$$m ] && rmdir $(methodsdatadir)/$$m; \ - [ -e $(methodsmnt)/$$m ] && rmdir $(methodsmnt)/$$m; \ + [ -e $(DESTDIR)$(methodsdir)/$$m ] && rmdir \ + $(DESTDIR)$(methodsdir)/$$m; \ + [ -e $(DESTDIR)$(methodsdatadir)/$$m ] && rmdir \ + $(DESTDIR)$(methodsdatadir)/$$m; \ + [ -e $(DESTDIR)$(methodsmnt)/$$m ] && rmdir \ + $(DESTDIR)$(methodsmnt)/$$m; \ done - -[ -e $(methodsmnt) ] && rmdir $(methodsmnt) - -[ -e $(methodsdir) ] && rmdir $(methodsdir) - -[ -e $(methodsdatadir) ] && rmdir $(methodsdatadir) + -[ -e $(DESTDIR)$(methodsmnt) ] && rmdir \ + $(DESTDIR)$(methodsmnt) + -[ -e $(DESTDIR)$(methodsdir) ] && rmdir \ + $(DESTDIR)$(methodsdir) + -[ -e $(DESTDIR)$(methodsdatadir) ] && rmdir \ + $(DESTDIR)$(methodsdatadir) dist-hook: set -e; for m in $(METHODS); do \ - cp -p $(srcdir)/$$m.names $(distdir)/; \ + cp -p $(srcdir)/$$m.names $(DESTDIR)$(distdir)/; \ for s in $(MSCRIPTS); do \ - cp -p $(srcdir)/$$m.$$s $(distdir)/; \ + cp -p $(srcdir)/$$m.$$s $(DESTDIR)$(distdir)/; \ done; \ done for d in $(DESCS); do \ - cp -p $(srcdir)/$$d $(distdir)/; \ + cp -p $(srcdir)/$$d $(DESTDIR)$(distdir)/; \ done ## End of file.