diff options
author | Scott James Remnant <scott@netsplit.com> | 2005-03-11 09:00:14 +0000 |
---|---|---|
committer | Scott James Remnant <scott@netsplit.com> | 2005-03-11 09:00:14 +0000 |
commit | 841a630143cd3a35dbf8bce0a111ebd39dd12f44 (patch) | |
tree | 0f85bbcb279f41e840bfcf6faceaab43770d2447 /dpkg-split | |
parent | ac8c6923a8654da81cbc6730213147961026eb8f (diff) | |
download | dpkg-841a630143cd3a35dbf8bce0a111ebd39dd12f44.tar.gz |
dpkg (1.13.1.0.1) experimental; urgency=low
* Bin-MU; recompile against Debian unstable, to make dselect actually
installable.
-- Scott James Remnant <scott@netsplit.com> Fri, 11 Mar 2005 09:00:14 +0000
Diffstat (limited to 'dpkg-split')
-rw-r--r-- | dpkg-split/Makefile.am | 38 | ||||
-rw-r--r-- | dpkg-split/Makefile.in | 530 | ||||
-rw-r--r-- | dpkg-split/dpkg-split.h | 73 | ||||
-rw-r--r-- | dpkg-split/info.c | 232 | ||||
-rw-r--r-- | dpkg-split/join.c | 134 | ||||
-rw-r--r-- | dpkg-split/main.c | 174 | ||||
-rw-r--r-- | dpkg-split/mksplit.pl | 90 | ||||
-rw-r--r-- | dpkg-split/queue.c | 275 | ||||
-rw-r--r-- | dpkg-split/split.c | 71 |
9 files changed, 1617 insertions, 0 deletions
diff --git a/dpkg-split/Makefile.am b/dpkg-split/Makefile.am new file mode 100644 index 000000000..09a700ca4 --- /dev/null +++ b/dpkg-split/Makefile.am @@ -0,0 +1,38 @@ +## Process this file with automake to produce Makefile.in + +localedir = $(datadir)/locale +INCLUDES = \ + -DLOCALEDIR=\"$(localedir)\" -I$(top_srcdir)/intl \ + -DADMINDIR=\"$(admindir)\" -DMKSPLITSCRIPT=\"$(pkglibdir)/mksplit\" \ + -I$(top_srcdir)/lib + + +bin_PROGRAMS = dpkg-split + +dpkg_split_SOURCES = \ + dpkg-split.h \ + info.c \ + join.c \ + main.c \ + queue.c \ + split.c + +dpkg_split_LDADD = $(LIBINTL) ../lib/libdpkg.a + + +pkglib_SCRIPTS = mksplit +EXTRA_DIST = mksplit.pl +CLEANFILES = $(pkglib_SCRIPTS) + + +do_perl_subst = sed -e "s:^\#![:space:]*/usr/bin/perl:\#!$(PERL):" + + +%: %.pl Makefile + @test -d `dirname $@` || $(mkdir_p) `dirname $@` + $(do_perl_subst) <$< >$@ + chmod +x $@ + + +install-data-local: + $(mkdir_p) $(DESTDIR)$(admindir)/parts diff --git a/dpkg-split/Makefile.in b/dpkg-split/Makefile.in new file mode 100644 index 000000000..89dc012b9 --- /dev/null +++ b/dpkg-split/Makefile.in @@ -0,0 +1,530 @@ +# Makefile.in generated by automake 1.8.5 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + + +SOURCES = $(dpkg_split_SOURCES) + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +top_builddir = .. +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +INSTALL = @INSTALL@ +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +target_triplet = @target@ +bin_PROGRAMS = dpkg-split$(EXEEXT) +subdir = dpkg-split +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/arch.m4 \ + $(top_srcdir)/m4/codeset.m4 $(top_srcdir)/m4/compiler.m4 \ + $(top_srcdir)/m4/funcs.m4 $(top_srcdir)/m4/gettext.m4 \ + $(top_srcdir)/m4/glibc21.m4 $(top_srcdir)/m4/iconv.m4 \ + $(top_srcdir)/m4/intdiv0.m4 $(top_srcdir)/m4/intmax.m4 \ + $(top_srcdir)/m4/inttypes-pri.m4 $(top_srcdir)/m4/inttypes.m4 \ + $(top_srcdir)/m4/inttypes_h.m4 $(top_srcdir)/m4/lcmessage.m4 \ + $(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \ + $(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/libs.m4 \ + $(top_srcdir)/m4/linker.m4 $(top_srcdir)/m4/longdouble.m4 \ + $(top_srcdir)/m4/longlong.m4 $(top_srcdir)/m4/nls.m4 \ + $(top_srcdir)/m4/perl.m4 $(top_srcdir)/m4/po.m4 \ + $(top_srcdir)/m4/printf-posix.m4 $(top_srcdir)/m4/progtest.m4 \ + $(top_srcdir)/m4/signed.m4 $(top_srcdir)/m4/size_max.m4 \ + $(top_srcdir)/m4/stdint_h.m4 $(top_srcdir)/m4/types.m4 \ + $(top_srcdir)/m4/uintmax_t.m4 $(top_srcdir)/m4/ulonglong.m4 \ + $(top_srcdir)/m4/wchar_t.m4 $(top_srcdir)/m4/wint_t.m4 \ + $(top_srcdir)/m4/xsize.m4 $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(pkglibdir)" +binPROGRAMS_INSTALL = $(INSTALL_PROGRAM) +PROGRAMS = $(bin_PROGRAMS) +am_dpkg_split_OBJECTS = info.$(OBJEXT) join.$(OBJEXT) main.$(OBJEXT) \ + queue.$(OBJEXT) split.$(OBJEXT) +dpkg_split_OBJECTS = $(am_dpkg_split_OBJECTS) +am__DEPENDENCIES_1 = +dpkg_split_DEPENDENCIES = $(am__DEPENDENCIES_1) ../lib/libdpkg.a +pkglibSCRIPT_INSTALL = $(INSTALL_SCRIPT) +SCRIPTS = $(pkglib_SCRIPTS) +DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +@AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/info.Po ./$(DEPDIR)/join.Po \ +@AMDEP_TRUE@ ./$(DEPDIR)/main.Po ./$(DEPDIR)/queue.Po \ +@AMDEP_TRUE@ ./$(DEPDIR)/split.Po +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ +SOURCES = $(dpkg_split_SOURCES) +DIST_SOURCES = $(dpkg_split_SOURCES) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +ALLOCA = @ALLOCA@ +AMDEP_FALSE = @AMDEP_FALSE@ +AMDEP_TRUE = @AMDEP_TRUE@ +AMTAR = @AMTAR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BUILD_INCLUDED_LIBINTL = @BUILD_INCLUDED_LIBINTL@ +BZ2_CFLAGS = @BZ2_CFLAGS@ +BZ2_LIBS = @BZ2_LIBS@ +CATOBJEXT = @CATOBJEXT@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CURSES_LIBS = @CURSES_LIBS@ +CXX = @CXX@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DATADIRNAME = @DATADIRNAME@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +GENCAT = @GENCAT@ +GLIBC21 = @GLIBC21@ +GMSGFMT = @GMSGFMT@ +HAVE_ASPRINTF = @HAVE_ASPRINTF@ +HAVE_POSIX_PRINTF = @HAVE_POSIX_PRINTF@ +HAVE_SNPRINTF = @HAVE_SNPRINTF@ +HAVE_WPRINTF = @HAVE_WPRINTF@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +INSTOBJEXT = @INSTOBJEXT@ +INTLBISON = @INTLBISON@ +INTLLIBS = @INTLLIBS@ +INTLOBJS = @INTLOBJS@ +INTL_LIBTOOL_SUFFIX_PREFIX = @INTL_LIBTOOL_SUFFIX_PREFIX@ +LDFLAGS = @LDFLAGS@ +LIBICONV = @LIBICONV@ +LIBINTL = @LIBINTL@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LTLIBICONV = @LTLIBICONV@ +LTLIBINTL = @LTLIBINTL@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ +MKINSTALLDIRS = @MKINSTALLDIRS@ +MSGFMT = @MSGFMT@ +MSGMERGE = @MSGMERGE@ +OBJEXT = @OBJEXT@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PERL = @PERL@ +POSUB = @POSUB@ +RANLIB = @RANLIB@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SSD_LIBS = @SSD_LIBS@ +STRIP = @STRIP@ +USE_INCLUDED_LIBINTL = @USE_INCLUDED_LIBINTL@ +USE_NLS = @USE_NLS@ +VERSION = @VERSION@ +WITH_DSELECT_FALSE = @WITH_DSELECT_FALSE@ +WITH_DSELECT_TRUE = @WITH_DSELECT_TRUE@ +WITH_START_STOP_DAEMON_FALSE = @WITH_START_STOP_DAEMON_FALSE@ +WITH_START_STOP_DAEMON_TRUE = @WITH_START_STOP_DAEMON_TRUE@ +XGETTEXT = @XGETTEXT@ +ZLIB_CFLAGS = @ZLIB_CFLAGS@ +ZLIB_LIBS = @ZLIB_LIBS@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_RANLIB = @ac_ct_RANLIB@ +ac_ct_STRIP = @ac_ct_STRIP@ +admindir = @admindir@ +am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ +am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ +am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@ +am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +datadir = @datadir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +sysconfdir = @sysconfdir@ +target = @target@ +target_alias = @target_alias@ +target_cpu = @target_cpu@ +target_os = @target_os@ +target_vendor = @target_vendor@ +localedir = $(datadir)/locale +INCLUDES = \ + -DLOCALEDIR=\"$(localedir)\" -I$(top_srcdir)/intl \ + -DADMINDIR=\"$(admindir)\" -DMKSPLITSCRIPT=\"$(pkglibdir)/mksplit\" \ + -I$(top_srcdir)/lib + +dpkg_split_SOURCES = \ + dpkg-split.h \ + info.c \ + join.c \ + main.c \ + queue.c \ + split.c + +dpkg_split_LDADD = $(LIBINTL) ../lib/libdpkg.a +pkglib_SCRIPTS = mksplit +EXTRA_DIST = mksplit.pl +CLEANFILES = $(pkglib_SCRIPTS) +do_perl_subst = sed -e "s:^\#![:space:]*/usr/bin/perl:\#!$(PERL):" +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .o .obj +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu dpkg-split/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --gnu dpkg-split/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +install-binPROGRAMS: $(bin_PROGRAMS) + @$(NORMAL_INSTALL) + test -z "$(bindir)" || $(mkdir_p) "$(DESTDIR)$(bindir)" + @list='$(bin_PROGRAMS)'; for p in $$list; do \ + p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ + if test -f $$p \ + ; then \ + f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \ + echo " $(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \ + $(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \ + else :; fi; \ + done + +uninstall-binPROGRAMS: + @$(NORMAL_UNINSTALL) + @list='$(bin_PROGRAMS)'; for p in $$list; do \ + f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \ + echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \ + rm -f "$(DESTDIR)$(bindir)/$$f"; \ + done + +clean-binPROGRAMS: + -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS) +dpkg-split$(EXEEXT): $(dpkg_split_OBJECTS) $(dpkg_split_DEPENDENCIES) + @rm -f dpkg-split$(EXEEXT) + $(LINK) $(dpkg_split_LDFLAGS) $(dpkg_split_OBJECTS) $(dpkg_split_LDADD) $(LIBS) +install-pkglibSCRIPTS: $(pkglib_SCRIPTS) + @$(NORMAL_INSTALL) + test -z "$(pkglibdir)" || $(mkdir_p) "$(DESTDIR)$(pkglibdir)" + @list='$(pkglib_SCRIPTS)'; for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + if test -f $$d$$p; then \ + f=`echo "$$p" | sed 's|^.*/||;$(transform)'`; \ + echo " $(pkglibSCRIPT_INSTALL) '$$d$$p' '$(DESTDIR)$(pkglibdir)/$$f'"; \ + $(pkglibSCRIPT_INSTALL) "$$d$$p" "$(DESTDIR)$(pkglibdir)/$$f"; \ + else :; fi; \ + done + +uninstall-pkglibSCRIPTS: + @$(NORMAL_UNINSTALL) + @list='$(pkglib_SCRIPTS)'; for p in $$list; do \ + f=`echo "$$p" | sed 's|^.*/||;$(transform)'`; \ + echo " rm -f '$(DESTDIR)$(pkglibdir)/$$f'"; \ + rm -f "$(DESTDIR)$(pkglibdir)/$$f"; \ + done + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/info.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/join.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/main.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/queue.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/split.Po@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` +uninstall-info-am: + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ + list='$(DISTFILES)'; for file in $$list; do \ + case $$file in \ + $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ + $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ + esac; \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + dir="/$$dir"; \ + $(mkdir_p) "$(distdir)$$dir"; \ + else \ + dir=''; \ + fi; \ + if test -d $$d/$$file; then \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(PROGRAMS) $(SCRIPTS) +installdirs: + for dir in "$(DESTDIR)$(bindir)" "$(DESTDIR)$(pkglibdir)"; do \ + test -z "$$dir" || $(mkdir_p) "$$dir"; \ + done +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) + +distclean-generic: + -rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-binPROGRAMS clean-generic mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: install-data-local + +install-exec-am: install-binPROGRAMS install-pkglibSCRIPTS + +install-info: install-info-am + +install-man: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-binPROGRAMS uninstall-info-am \ + uninstall-pkglibSCRIPTS + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \ + clean-generic ctags distclean distclean-compile \ + distclean-generic distclean-tags distdir dvi dvi-am html \ + html-am info info-am install install-am install-binPROGRAMS \ + install-data install-data-am install-data-local install-exec \ + install-exec-am install-info install-info-am install-man \ + install-pkglibSCRIPTS install-strip installcheck \ + installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \ + uninstall-am uninstall-binPROGRAMS uninstall-info-am \ + uninstall-pkglibSCRIPTS + + +%: %.pl Makefile + @test -d `dirname $@` || $(mkdir_p) `dirname $@` + $(do_perl_subst) <$< >$@ + chmod +x $@ + +install-data-local: + $(mkdir_p) $(DESTDIR)$(admindir)/parts +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/dpkg-split/dpkg-split.h b/dpkg-split/dpkg-split.h new file mode 100644 index 000000000..89fda6922 --- /dev/null +++ b/dpkg-split/dpkg-split.h @@ -0,0 +1,73 @@ +/* + * dpkg-split - splitting and joining of multipart *.deb archives + * dpkg-split.h - external definitions for this program + * + * Copyright (C) 1995 Ian Jackson <ian@chiark.greenend.org.uk> + * + * This is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2, + * or (at your option) any later version. + * + * This is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * 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. + */ + +#ifndef DPKG_SPLIT_H +#define DPKG_SPLIT_H + +typedef void dofunction(const char *const *argv); +dofunction do_split NONRETURNING; +dofunction do_join, do_info, do_auto, do_queue, do_discard; + +struct partinfo { + const char *filename; + const char *fmtversion; + const char *package; + const char *version; + const char *md5sum; + unsigned long orglength; + unsigned int thispartn, maxpartn; + unsigned long maxpartlen; + unsigned long thispartoffset; + size_t thispartlen; + size_t headerlen; /* size of header in part file */ + off_t filesize; +}; + +struct partqueue { + struct partqueue *nextinqueue; + struct partinfo info; + /* only fields filename, md5sum, maxpartlen, thispartn, maxpartn + * are valid; the rest are null. If the file is not named correctly + * to be a part file md5sum is null too and the numbers are zero. + */ +}; + +extern dofunction *action; +extern const struct cmdinfo *cipaction; +extern long maxpartsize; +extern const char *depotdir, *outputfile; +extern struct partqueue *queue; +extern int npquiet, msdos; + +void rerr(const char *fn) NONRETURNING; +void rerreof(FILE *f, const char *fn) NONRETURNING; +void print_info(const struct partinfo *pi); +struct partinfo *read_info(FILE *partfile, const char *fn, struct partinfo *ir); + +void scandepot(void); +void reassemble(struct partinfo **partlist, const char *outputfile); +void mustgetpartinfo(const char *filename, struct partinfo *ri); +void addtopartlist(struct partinfo**, struct partinfo*, struct partinfo *refi); + +#define PARTMAGIC "!<arch>\ndebian-split " +#define HEADERALLOWANCE 1024 + +#endif /* DPKG_SPLIT_H */ diff --git a/dpkg-split/info.c b/dpkg-split/info.c new file mode 100644 index 000000000..3bb9c6095 --- /dev/null +++ b/dpkg-split/info.c @@ -0,0 +1,232 @@ +/* + * dpkg-split - splitting and joining of multipart *.deb archives + * info.c - information about split archives + * + * Copyright (C) 1995 Ian Jackson <ian@chiark.greenend.org.uk> + * + * This is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2, + * or (at your option) any later version. + * + * This is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * 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. + */ +#include <config.h> + +#include <stdio.h> +#include <stdlib.h> +#include <limits.h> +#include <assert.h> +#include <string.h> +#include <unistd.h> +#include <sys/stat.h> +#include <ar.h> +#include <ctype.h> + +#include <dpkg.h> +#include <dpkg-db.h> +#include "dpkg-split.h" + +static unsigned long unsignedlong(const char *value, const char *fn, const char *what) { + unsigned long r; + char *endp; + + r= strtoul(value,&endp,10); + if (*endp) + ohshit(_("file `%.250s' is corrupt - bad digit (code %d) in %s"),fn,*endp,what); + return r; +} + +static unsigned long parseheaderlength(const char *inh, size_t len, + const char *fn, const char *what) { + char lintbuf[15]; + + if (memchr(inh,0,len)) + ohshit(_("file `%.250s' is corrupt - %.250s length contains nulls"),fn,what); + assert(sizeof(lintbuf) > len); + memcpy(lintbuf,inh,len); + lintbuf[len]= ' '; + *strchr(lintbuf,' ')= 0; + return unsignedlong(lintbuf,fn,what); +} + +static char *nextline(char **ripp, const char *fn, const char *what) { + char *newline, *rip; + + rip= *ripp; + if (!rip) ohshit(_("file `%.250s' is corrupt - %.250s missing"),fn,what); + newline= strchr(rip,'\n'); + if (!newline) + ohshit(_("file `%.250s' is corrupt - missing newline after %.250s"),fn,what); + *ripp= newline+1; + while (newline > rip && isspace(newline[-1])) newline--; + *newline= 0; + return rip; +} + +struct partinfo *read_info(FILE *partfile, const char *fn, struct partinfo *ir) { + /* returns info (nfmalloc'd) if was an archive part and we read it, 0 if it wasn't */ + static char *readinfobuf= NULL; + static size_t readinfobuflen= 0; + + size_t thisilen; + unsigned int templong; + char magicbuf[sizeof(PARTMAGIC)-1], *rip, *partnums, *slash; + struct ar_hdr arh; + int c; + struct stat stab; + + if (fread(magicbuf,1,sizeof(PARTMAGIC)-1,partfile) != sizeof(PARTMAGIC)-1) { + if (ferror(partfile)) rerr(fn); else return NULL; + } + if (memcmp(magicbuf,PARTMAGIC,sizeof(magicbuf))) return NULL; + if (fseek(partfile,-sizeof(arh.ar_name),SEEK_CUR)) + ohshite(_("unable to seek back")); + + if (fread(&arh,1,sizeof(arh),partfile) != sizeof(arh)) rerreof(partfile,fn); + if (memcmp(arh.ar_fmag,ARFMAG,sizeof(arh.ar_fmag))) + ohshit(_("file `%.250s' is corrupt - bad magic at end of first header"),fn); + thisilen= parseheaderlength(arh.ar_size,sizeof(arh.ar_size),fn,"info length"); + if (thisilen >= readinfobuflen) { + readinfobuflen= thisilen+1; + readinfobuf= m_realloc(readinfobuf,readinfobuflen); + } + if (fread(readinfobuf,1,thisilen,partfile) != thisilen) rerreof(partfile,fn); + if (thisilen & 1) { + c= getc(partfile); if (c==EOF) rerreof(partfile,fn); + if (c != '\n') + ohshit(_("file `%.250s' is corrupt - bad padding character (code %d)"),fn,c); + } + readinfobuf[thisilen]= 0; + if (memchr(readinfobuf,0,thisilen)) + ohshit(_("file `%.250s' is corrupt - nulls in info section"),fn); + + ir->filename= fn; + + rip= readinfobuf; + ir->fmtversion= nfstrsave(nextline(&rip,fn,"format version number")); + if (strcmp(ir->fmtversion,SPLITVERSION)) + ohshit(_("file `%.250s' is format version `%.250s' - you need a newer dpkg-split"), + fn,ir->fmtversion); + + ir->package= nfstrsave(nextline(&rip,fn,"package name")); + ir->version= nfstrsave(nextline(&rip,fn,"package version number")); + ir->md5sum= nfstrsave(nextline(&rip,fn,"package file MD5 checksum")); + if (strlen(ir->md5sum) != 32 || + strspn(ir->md5sum,"0123456789abcdef") != 32) + ohshit(_("file `%.250s' is corrupt - bad MD5 checksum `%.250s'"),fn,ir->md5sum); + + ir->orglength= unsignedlong(nextline(&rip,fn,"total length"),fn,"total length"); + ir->maxpartlen= unsignedlong(nextline(&rip,fn,"part offset"),fn,"part offset"); + + partnums= nextline(&rip,fn,"part numbers"); + slash= strchr(partnums,'/'); + if (!slash) ohshit(_("file `%.250s' is corrupt - no slash between part numbers"),fn); + *slash++= 0; + + templong= unsignedlong(slash,fn,"number of parts"); + if (templong <= 0 || templong > INT_MAX) + ohshit("file `%.250s' is corrupt - bad number of parts",fn); + ir->maxpartn= templong; + templong= unsignedlong(partnums,fn,"parts number"); + if (templong <= 0 || templong > ir->maxpartn) + ohshit(_("file `%.250s' is corrupt - bad part number"),fn); + ir->thispartn= templong; + + if (fread(&arh,1,sizeof(arh),partfile) != sizeof(arh)) rerreof(partfile,fn); + if (memcmp(arh.ar_fmag,ARFMAG,sizeof(arh.ar_fmag))) + ohshit(_("file `%.250s' is corrupt - bad magic at end of second header"),fn); + if (strncmp(arh.ar_name,"data",4)) + ohshit(_("file `%.250s' is corrupt - second member is not data member"),fn); + + ir->thispartlen= parseheaderlength(arh.ar_size,sizeof(arh.ar_size),fn,"data length"); + ir->thispartoffset= (ir->thispartn-1)*ir->maxpartlen; + + if (ir->maxpartn != (ir->orglength+ir->maxpartlen-1)/ir->maxpartlen) + ohshit(_("file `%.250s' is corrupt - wrong number of parts for quoted sizes"),fn); + if (ir->thispartlen != + (ir->thispartn == ir->maxpartn + ? ir->orglength - ir->thispartoffset : ir->maxpartlen)) + ohshit(_("file `%.250s' is corrupt - size is wrong for quoted part number"),fn); + + ir->filesize= (SARMAG + + sizeof(arh) + thisilen + (thisilen&1) + + sizeof(arh) + ir->thispartlen + (ir->thispartlen&1)); + + if (fstat(fileno(partfile),&stab)) ohshite(_("unable to fstat part file `%.250s'"),fn); + if (S_ISREG(stab.st_mode)) { + /* Don't do this check if it's coming from a pipe or something. It's + * only an extra sanity check anyway. + */ + if (stab.st_size < ir->filesize) + ohshit(_("file `%.250s' is corrupt - too short"),fn); + } + + ir->headerlen= SARMAG + sizeof(arh) + thisilen + (thisilen&1) + sizeof(arh); + + return ir; +} + +void mustgetpartinfo(const char *filename, struct partinfo *ri) { + FILE *part; + + part= fopen(filename,"r"); + if (!part) ohshite(_("cannot open archive part file `%.250s'"),filename); + if (!read_info(part,filename,ri)) + ohshite(_("file `%.250s' is not an archive part"),filename); + fclose(part); +} + +void print_info(const struct partinfo *pi) { + printf(_("%s:\n" + " Part format version: %s\n" + " Part of package: %s\n" + " ... version: %s\n" + " ... MD5 checksum: %s\n" + " ... length: %lu bytes\n" + " ... split every: %lu bytes\n" + " Part number: %d/%d\n" + " Part length: %zi bytes\n" + " Part offset: %lu bytes\n" + " Part file size (used portion): %lu bytes\n\n"), + pi->filename, + pi->fmtversion, + pi->package, + pi->version, + pi->md5sum, + pi->orglength, + pi->maxpartlen, + pi->thispartn, + pi->maxpartn, + pi->thispartlen, + pi->thispartoffset, + (unsigned long)pi->filesize); +} + +void do_info(const char *const *argv) { + const char *thisarg; + struct partinfo *pi, ps; + FILE *part; + + if (!*argv) badusage(_("--info requires one or more part file arguments")); + + while ((thisarg= *argv++)) { + part= fopen(thisarg,"r"); + if (!part) ohshite(_("cannot open archive part file `%.250s'"),thisarg); + pi= read_info(part,thisarg,&ps); + fclose(part); + if (pi) { + print_info(pi); + } else { + printf(_("file `%s' is not an archive part\n"),thisarg); + } + if (ferror(stdout)) werr("stdout"); + } +} diff --git a/dpkg-split/join.c b/dpkg-split/join.c new file mode 100644 index 000000000..4add3904a --- /dev/null +++ b/dpkg-split/join.c @@ -0,0 +1,134 @@ +/* + * dpkg-split - splitting and joining of multipart *.deb archives + * join.c - joining + * + * Copyright (C) 1995 Ian Jackson <ian@chiark.greenend.org.uk> + * + * This is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2, + * or (at your option) any later version. + * + * This is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * 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. + */ +#include <config.h> + +#include <stdio.h> +#include <stdlib.h> +#include <limits.h> +#include <assert.h> +#include <string.h> + +#include <dpkg.h> +#include <dpkg-db.h> +#include "dpkg-split.h" + +void reassemble(struct partinfo **partlist, const char *outputfile) { + FILE *output, *input; + void *buffer; + struct partinfo *pi; + unsigned int i; + size_t nr,buffersize; + + printf("Putting package %s together from %d parts: ", + partlist[0]->package,partlist[0]->maxpartn); + + buffersize= partlist[0]->maxpartlen; + for (i=0; i<partlist[0]->maxpartn; i++) + if (partlist[0]->headerlen > buffersize) buffersize= partlist[0]->headerlen; + buffer= m_malloc(partlist[0]->maxpartlen); + output= fopen(outputfile,"w"); + if (!output) ohshite(_("unable to open output file `%.250s'"),outputfile); + for (i=0; i<partlist[0]->maxpartn; i++) { + pi= partlist[i]; + input= fopen(pi->filename,"r"); + if (!input) ohshite(_("unable to (re)open input part file `%.250s'"),pi->filename); + assert(pi->headerlen <= buffersize); + nr= fread(buffer,1,pi->headerlen,input); + if (nr != pi->headerlen) rerreof(input,pi->filename); + assert(pi->thispartlen <= buffersize); + printf("%d ",i+1); + nr= fread(buffer,1,pi->thispartlen,input); + if (nr != pi->thispartlen) rerreof(input,pi->filename); + if (pi->thispartlen & 1) + if (getc(input) == EOF) rerreof(input,pi->filename); + if (ferror(input)) rerr(pi->filename); + fclose(input); + nr= fwrite(buffer,1,pi->thispartlen,output); + if (nr != pi->thispartlen) werr(outputfile); + } + if (fclose(output)) werr(outputfile); + printf(_("done\n")); +} + + +void addtopartlist(struct partinfo **partlist, + struct partinfo *pi, struct partinfo *refi) { + int i; + + if (strcmp(pi->package,refi->package) || + strcmp(pi->version,refi->version) || + strcmp(pi->md5sum,refi->md5sum) || + pi->orglength != refi->orglength || + pi->maxpartn != refi->maxpartn || + pi->maxpartlen != refi->maxpartlen) { + print_info(pi); + print_info(refi); + ohshit(_("files `%.250s' and `%.250s' are not parts of the same file"), + pi->filename,refi->filename); + } + i= pi->thispartn-1; + if (partlist[i]) + ohshit(_("there are several versions of part %d - at least `%.250s' and `%.250s'"), + pi->thispartn, pi->filename, partlist[i]->filename); + partlist[i]= pi; +} + +void do_join(const char *const *argv) { + char *p; + const char *thisarg; + struct partqueue *pq; + struct partinfo *refi, *pi, **partlist; + unsigned int i; + + assert(!queue); + if (!*argv) badusage(_("--join requires one or more part file arguments")); + while ((thisarg= *argv++)) { + pq= nfmalloc(sizeof(struct partqueue)); + + mustgetpartinfo(thisarg,&pq->info); + + + pq->nextinqueue= queue; + queue= pq; + } + refi= NULL; + for (pq= queue; pq; pq= pq->nextinqueue) + if (!refi || pq->info.thispartn < refi->thispartn) refi= &pq->info; + assert(refi); + partlist= nfmalloc(sizeof(struct partinfo*)*refi->maxpartn); + for (i=0; i<refi->maxpartn; i++) partlist[i]= 0; + for (pq= queue; pq; pq= pq->nextinqueue) { + pi= &pq->info; + addtopartlist(partlist,pi,refi); + } + for (i=0; i<refi->maxpartn; i++) { + if (!partlist[i]) ohshit(_("part %d is missing"),i+1); + } + if (!outputfile) { + p= nfmalloc(strlen(refi->package)+1+strlen(refi->version)+sizeof(DEBEXT)); + strcpy(p,refi->package); + strcat(p,"-"); + strcat(p,refi->version); + strcat(p,DEBEXT); + outputfile= p; + } + reassemble(partlist,outputfile); +} diff --git a/dpkg-split/main.c b/dpkg-split/main.c new file mode 100644 index 000000000..2da27b7be --- /dev/null +++ b/dpkg-split/main.c @@ -0,0 +1,174 @@ +/* + * dpkg-split - splitting and joining of multipart *.deb archives + * main.c - main program + * + * Copyright (C) 1995 Ian Jackson <ian@chiark.greenend.org.uk> + * + * This is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2, + * or (at your option) any later version. + * + * This is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * 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. + */ +#include <config.h> + +#include <string.h> +#include <stdio.h> +#include <stdlib.h> +#include <limits.h> +#include <assert.h> +#include <sys/types.h> +#include <sys/stat.h> + +#include <dpkg.h> +#include <dpkg-db.h> +#include <myopt.h> + +#include "dpkg-split.h" + +static void printversion(void) { + if (fputs + (_("Debian GNU/Linux `dpkg-split' package split/join tool; version "), stdout) < 0) werr ("stdout"); + if (fputs (DPKG_VERSION_ARCH ".\n", stdout) < 0) werr ("stdout"); + if (fputs (_("Copyright (C) 1994-1996 Ian Jackson. This is free software; see the\n" + "GNU General Public Licence version 2 or later for copying conditions.\n" + "There is NO warranty. See dpkg-split --licence for details.\n"), + stdout) < 0) werr("stdout"); +} + +static void usage(void) { + if (printf(_("\ +Usage: dpkg-split -s|--split <file> [<prefix>] Split an archive.\n\ + dpkg-split -j|--join <part> <part> ... Join parts together.\n\ + dpkg-split -I|--info <part> ... Display info about a part.\n\ + dpkg-split -h|--help|--version|--licence Show help/version/licence.\n\ +\n\ + dpkg-split -a|--auto -o <complete> <part> Auto-accumulate parts.\n\ + dpkg-split -l|--listq List unmatched pieces.\n\ + dpkg-split -d|--discard [<filename> ...] Discard unmatched pieces.\n\ +\n\ +Options: --depotdir <directory> (default is %s/%s)\n\ + -S|--partsize <size> (in Kb, for -s, default is 450)\n\ + -o|--output <file> (for -j, default is <package>-<version>.deb)\n\ + -Q|--npquiet (be quiet when -a is not a part)\n\ + --msdos (generate 8.3 filenames)\n\ +\n\ +Exit status: 0 = OK; 1 = -a is not a part; 2 = trouble!\n"), + ADMINDIR, PARTSDIR) < 0) werr("stdout"); +} + +const char thisname[]= SPLITTER; +const char printforhelp[]= N_("Type dpkg-split --help for help."); + +dofunction *action=NULL; +const struct cmdinfo *cipaction=NULL; +long maxpartsize= SPLITPARTDEFMAX; +const char *depotdir= ADMINDIR "/" PARTSDIR, *outputfile= NULL; +struct partqueue *queue= NULL; +int npquiet= 0, msdos= 0; + +void rerr(const char *fn) { + ohshite(_("error reading %s"),fn); +} + +void rerreof(FILE *f, const char *fn) { + if (ferror(f)) ohshite(_("error reading %.250s"),fn); + ohshit(_("unexpected end of file in %.250s"),fn); +} + +static void helponly(const struct cmdinfo *cip, const char *value) NONRETURNING; +static void helponly(const struct cmdinfo *cip, const char *value) { + usage(); exit(0); +} +static void versiononly(const struct cmdinfo *cip, const char *value) NONRETURNING; +static void versiononly(const struct cmdinfo *cip, const char *value) { + printversion(); exit(0); +} + +static void setaction(const struct cmdinfo *cip, const char *value); + +static void setpartsize(const struct cmdinfo *cip, const char *value) { + long newpartsize; + char *endp; + + newpartsize= strtol(value,&endp,10); + if (newpartsize <= 0 || newpartsize > (INT_MAX >> 10)) + badusage(_("part size is far too large or is not positive")); + + maxpartsize= newpartsize << 10; + if (maxpartsize <= HEADERALLOWANCE) + badusage(_("part size must be at least %dk (to allow for header)"), + (HEADERALLOWANCE >> 10) + 1); +} + +static dofunction *const dofunctions[]= { + do_split, + do_join, + do_info, + do_auto, + do_queue, + do_discard, +}; + +/* NB: the entries using setaction must appear first and be in the + * same order as dofunctions: + */ +static const struct cmdinfo cmdinfos[]= { + { "split", 's', 0, NULL, NULL, setaction }, + { "join", 'j', 0, NULL, NULL, setaction }, + { "info", 'I', 0, NULL, NULL, setaction }, + { "auto", 'a', 0, NULL, NULL, setaction }, + { "listq", 'l', 0, NULL, NULL, setaction }, + { "discard", 'd', 0, NULL, NULL, setaction }, + { "help", 'h', 0, NULL, NULL, helponly }, + { "version", 0, 0, NULL, NULL, versiononly }, + { "licence", 0, 0, NULL, NULL, showcopyright }, /* UK spelling */ + { "license", 0, 0, NULL, NULL, showcopyright }, /* US spelling */ + { "depotdir", 0, 1, NULL, &depotdir, NULL }, + { "partsize", 'S', 1, NULL, NULL, setpartsize }, + { "output", 'o', 1, NULL, &outputfile, NULL }, + { "npquiet", 'Q', 0, &npquiet, NULL, NULL, 1 }, + { "msdos", 0, 0, &msdos, NULL, NULL, 1 }, + { NULL, 0 } +}; + +static void setaction(const struct cmdinfo *cip, const char *value) { + if (cipaction) + badusage(_("conflicting actions --%s and --%s"),cip->olong,cipaction->olong); + cipaction= cip; + assert((int)(cip-cmdinfos) < (int)(sizeof(dofunctions)*sizeof(dofunction*))); + action= dofunctions[cip-cmdinfos]; +} + +int main(int argc, const char *const *argv) { + jmp_buf ejbuf; + int l; + char *p; + + standard_startup(&ejbuf, argc, &argv, NULL, 0, cmdinfos); + if (!cipaction) badusage(_("need an action option")); + + l= strlen(depotdir); + if (l && depotdir[l-1] != '/') { + p= nfmalloc(l+2); + strcpy(p,depotdir); + strcpy(p+l,"/"); + depotdir= p; + } + + setvbuf(stdout,NULL,_IONBF,0); + action(argv); + + if (ferror(stderr)) werr("stderr"); + + standard_shutdown(0); + exit(0); +} diff --git a/dpkg-split/mksplit.pl b/dpkg-split/mksplit.pl new file mode 100644 index 000000000..f01741cfa --- /dev/null +++ b/dpkg-split/mksplit.pl @@ -0,0 +1,90 @@ +#!/usr/bin/perl -- +# This script is only supposed to be called by dpkg-split. +# Its arguments are: +# <sourcefile> <partsize> <prefix> <totalsize> <partsizeallow> <msdostruncyesno> +# Stdin is also redirected from the source archive by dpkg-split. + +# Copyright (C) 1995 Ian Jackson <ian@chiark.greenend.org.uk> +# +# This is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2, +# or (at your option) any later version. +# +# This is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# 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. + +@ARGV == 6 || die "mksplit: bad invocation\n"; + +($sourcefile,$partsize,$prefix,$orgsize,$partsizeallow,$msdos) = @ARGV; + +sub output { + $!=0; $rv= `$_[0]`; $? && die "mksplit $_[0]: $! $?\n"; + $rv =~ s/\n$//; $rv =~ s/\s+$//; $rv =~ s/^\s+//; + $rv; +} + +$myversion='2.1'; +$csum= &output("md5sum <\"$sourcefile\""); +$csum =~ s/\s.*//; +$package= &output("dpkg-deb --field \"$sourcefile\" Package"); +$version= &output("dpkg-deb --field \"$sourcefile\" Version"); +$revision= &output("dpkg-deb --field \"$sourcefile\" Package_Revision"); +$version.= "-$revision" if length($revision); +$nparts=int(($orgsize+$partsize-1)/$partsize); +$startat=0; +$showpartnum=1; + +$|=1; +print("Splitting package $package into $nparts parts: "); + +$msdos= ($msdos eq 'yes'); +if ($msdos) { + $prefixdir= $prefix; $prefixdir =~ s:(/?)/*[^/]+$:$1:; + $cleanprefix= $prefix; $cleanprefix =~ s:^.*/+::; + $cleanprefix =~ y/A-Za-z0-9+/a-za-z0-9x/; + $cleanprefix =~ y/a-z0-9//cd; +} + +sub add { + $data .= + sprintf("%-16s%-12d0 0 100644 %-10d%c\n%s%s", + $_[0], time, length($_[1]), 0140, $_[1], + (length($_[1]) & 1) ? "\n" : ""); +} + +while ($startat < $orgsize) { + $dsp= "$myversion\n$package\n$version\n$csum\n$orgsize\n$partsize\n". + "$showpartnum/$nparts\n"; + defined($thispartreallen= read(STDIN,$pd,$partsize)) || die "mksplit: read: $!\n"; + $data= "!<arch>\n"; + print("$showpartnum "); + &add('debian-split',$dsp); + &add("data.$showpartnum",$pd); + if ($thispartreallen > $partsizeallow) { + die "Header is too long, making part too long. Your package name or version\n". + "numbers must be extraordinarily long, or something. Giving up.\n"; + } + if ($msdos) { + $basename= "${showpartnum}of$nparts.$cleanprefix"; + $basename= substr($basename,0,9); + $basename =~ s/^([^.]*)\.(.*)$/$2$1/; + $basename= "$prefixdir$basename"; + } else { + $basename= "$prefix.${showpartnum}of$nparts"; + } + open(O,"> $basename.deb") || die("mksplit: open $basename.deb: $!\n"); + print(O $data) || die("mksplit: write $basename.deb: $!\n"); + close(O) || die("mksplit: close $basename.deb: $!\n"); + $startat += $partsize; + $showpartnum++; +} +print("done\n"); + +exit(0); diff --git a/dpkg-split/queue.c b/dpkg-split/queue.c new file mode 100644 index 000000000..6a1312fa1 --- /dev/null +++ b/dpkg-split/queue.c @@ -0,0 +1,275 @@ +/* + * dpkg-split - splitting and joining of multipart *.deb archives + * queue.c - queue management + * + * Copyright (C) 1995 Ian Jackson <ian@chiark.greenend.org.uk> + * + * This is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2, + * or (at your option) any later version. + * + * This is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * 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. + */ + +/* + * Queue, in /var/lib/dpkg/parts, is a plain directory with one + * file per part. + * + * parts are named + * <md5sum>.<maxpartlen>.<thispartn>.<maxpartn> + * all numbers in hex + */ +#include <config.h> + +#include <stdio.h> +#include <stdlib.h> +#include <limits.h> +#include <assert.h> +#include <unistd.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <dirent.h> +#include <string.h> + +#include <dpkg.h> +#include <dpkg-db.h> +#include "dpkg-split.h" + +static int decompose_filename(const char *filename, struct partqueue *pq) { + const char *p; + char *q; + + if (strspn(filename,"0123456789abcdef") != 32 || filename[32] != '.') return 0; + q= nfmalloc(33); + memcpy(q,filename,32); q[32]= 0; + pq->info.md5sum= q; + p= filename+33; + pq->info.maxpartlen= strtol(p,&q,16); if (q==p || *q++ != '.') return 0; + p=q; pq->info.thispartn= (int)strtol(p,&q,16); if (q==p || *q++ != '.') return 0; + p=q; pq->info.maxpartn= (int)strtol(p,&q,16); if (q==p || *q) return 0; + return 1; +} + +void scandepot(void) { + DIR *depot; + struct dirent *de; + struct partqueue *pq; + char *p; + + assert(!queue); + depot= opendir(depotdir); + if (!depot) ohshite(_("unable to read depot directory `%.250s'"),depotdir); + while ((de= readdir(depot))) { + if (de->d_name[0] == '.') continue; + pq= nfmalloc(sizeof(struct partqueue)); + pq->info.fmtversion= pq->info.package= pq->info.version= NULL; + pq->info.orglength= pq->info.thispartoffset= pq->info.thispartlen= 0; + pq->info.headerlen= 0; + p= nfmalloc(strlen(depotdir)+strlen(de->d_name)+1); + strcpy(p,depotdir); + strcat(p,de->d_name); + pq->info.filename= p; + if (!decompose_filename(de->d_name,pq)) { + pq->info.md5sum= NULL; + pq->info.maxpartlen= pq->info.thispartn= pq->info.maxpartn= 0; + } + pq->nextinqueue= queue; + queue= pq; + } +} + +static int partmatches(struct partinfo *pi, struct partinfo *refi) { + return (pi->md5sum && + !strcmp(pi->md5sum,refi->md5sum) && + pi->maxpartn == refi->maxpartn && + pi->maxpartlen == refi->maxpartlen); +} + +void do_auto(const char *const *argv) { + const char *partfile; + struct partinfo *pi, *refi, *npi, **partlist, *otherthispart; + struct partqueue *pq; + unsigned int i, j; + int ap; + long nr; + FILE *part; + void *buffer; + char *p, *q; + + if (!outputfile) badusage(_("--auto requires the use of the --output option")); + if (!(partfile= *argv++) || *argv) + badusage(_("--auto requires exactly one part file argument")); + + refi= nfmalloc(sizeof(struct partqueue)); + part= fopen(partfile,"r"); + if (!part) ohshite(_("unable to read part file `%.250s'"),partfile); + if (!read_info(part,partfile,refi)) { + if (!npquiet) + printf(_("File `%.250s' is not part of a multipart archive.\n"),partfile); + if (fclose(stdout)) werr("stdout"); + exit(1); + } + fclose(part); + scandepot(); + partlist= nfmalloc(sizeof(struct partinfo*)*refi->maxpartn); + for (i=0; i<refi->maxpartn; i++) partlist[i]= 0; + for (pq= queue; pq; pq= pq->nextinqueue) { + pi= &pq->info; + if (!partmatches(pi,refi)) continue; + npi= nfmalloc(sizeof(struct partinfo)); + mustgetpartinfo(pi->filename,npi); + addtopartlist(partlist,npi,refi); + } + /* If we already have a copy of this version we ignore it and prefer the + * new one, but we still want to delete the one in the depot, so we + * save its partinfo (with the filename) for later. This also prevents + * us from accidentally deleting the source file. + */ + otherthispart= partlist[refi->thispartn-1]; + partlist[refi->thispartn-1]= refi; + for (j=refi->maxpartn-1; j>=0 && partlist[j]; j--); + + if (j>=0) { + + part= fopen(partfile,"r"); + if (!part) ohshite(_("unable to reopen part file `%.250s'"),partfile); + buffer= nfmalloc(refi->filesize); + nr= fread(buffer,1,refi->filesize,part); + if (nr != refi->filesize) rerreof(part,partfile); + if (getc(part) != EOF) ohshit(_("part file `%.250s' has trailing garbage"),partfile); + if (ferror(part)) rerr(partfile); + fclose(part); + p= nfmalloc(strlen(depotdir)+50); + q= nfmalloc(strlen(depotdir)+200); + sprintf(p,"%st.%lx",depotdir,(long)getpid()); + sprintf(q,"%s%s.%lx.%x.%x",depotdir,refi->md5sum, + refi->maxpartlen,refi->thispartn,refi->maxpartn); + part= fopen(p,"w"); + if (!part) ohshite(_("unable to open new depot file `%.250s'"),p); + nr= fwrite(buffer,1,refi->filesize,part); + if (nr != refi->filesize) werr(p); + if (fclose(part)) werr(p); + if (rename(p,q)) ohshite(_("unable to rename new depot file `%.250s' to `%.250s'"),p,q); + + printf(_("Part %d of package %s filed (still want "),refi->thispartn,refi->package); + /* There are still some parts missing. */ + for (i=0, ap=0; i<refi->maxpartn; i++) + if (!partlist[i]) + printf("%s%d", !ap++ ? "" : i==j ? _(" and ") : ", ", i+1); + printf(").\n"); + + } else { + + /* We have all the parts. */ + reassemble(partlist,outputfile); + + /* OK, delete all the parts (except the new one, which we never copied). */ + partlist[refi->thispartn-1]= otherthispart; + for (i=0; i<refi->maxpartn; i++) + if (partlist[i]) + if (unlink(partlist[i]->filename)) + ohshite(_("unable to delete used-up depot file `%.250s'"),partlist[i]->filename); + + } + + if (ferror(stderr)) werr("stderr"); +} + +void do_queue(const char *const *argv) { + struct partqueue *pq, *qq; + struct partinfo ti; + const char *head; + struct stat stab; + unsigned long bytes; + unsigned int i; + + if (*argv) badusage(_("--listq does not take any arguments")); + scandepot(); + + head= N_("Junk files left around in the depot directory:\n"); + for (pq= queue; pq; pq= pq->nextinqueue) { + if (pq->info.md5sum) continue; + fputs(gettext(head),stdout); head= ""; + if (lstat(pq->info.filename,&stab)) + ohshit(_("unable to stat `%.250s'"),pq->info.filename); + if (S_ISREG(stab.st_mode)) { + bytes= stab.st_size; + printf(_(" %s (%lu bytes)\n"),pq->info.filename,bytes); + } else { + printf(_(" %s (not a plain file)\n"),pq->info.filename); + } + } + if (!*head) putchar('\n'); + + head= N_("Packages not yet reassembled:\n"); + for (pq= queue; pq; pq= pq->nextinqueue) { + if (!pq->info.md5sum) continue; + mustgetpartinfo(pq->info.filename,&ti); + fputs(gettext(head),stdout); head= ""; + printf(" Package %s: part(s) ",ti.package); + bytes= 0; + for (i=0; i<ti.maxpartn; i++) { + for (qq= pq; + qq && !(partmatches(&qq->info,&ti) && qq->info.thispartn == i+1); + qq= qq->nextinqueue); + if (qq) { + printf("%d ",i+1); + if (lstat(qq->info.filename,&stab)) + ohshite(_("unable to stat `%.250s'"),qq->info.filename); + if (!S_ISREG(stab.st_mode)) + ohshit(_("part file `%.250s' is not a plain file"),qq->info.filename); + bytes+= stab.st_size; + qq->info.md5sum= NULL; /* don't find this package again */ + } + } + printf(_("(total %lu bytes)\n"),bytes); + } + if (fclose(stdout)) werr("stdout"); +} + +enum discardwhich { ds_junk, ds_package, ds_all }; + +static void discardsome(enum discardwhich which, const char *package) { + struct partqueue *pq; + + for (pq= queue; pq; pq= pq->nextinqueue) { + switch (which) { + case ds_junk: + if (pq->info.md5sum) continue; + break; + case ds_package: + if (!pq->info.md5sum || strcasecmp(pq->info.package,package)) continue; + break; + case ds_all: + break; + default: internerr("bad discardsome which"); + } + if (unlink(pq->info.filename)) + ohshite(_("unable to discard `%.250s'"),pq->info.filename); + printf(_("Deleted %s.\n"),pq->info.filename); + } +} + +void do_discard(const char *const *argv) { + const char *thisarg; + struct partqueue *pq; + + scandepot(); + if (*argv) { + for (pq= queue; pq; pq= pq->nextinqueue) + if (pq->info.md5sum) + mustgetpartinfo(pq->info.filename,&pq->info); + discardsome(ds_junk,NULL); + while ((thisarg= *argv++)) discardsome(ds_package,thisarg); + } else { + discardsome(ds_all,NULL); + } +} diff --git a/dpkg-split/split.c b/dpkg-split/split.c new file mode 100644 index 000000000..2c3b7894d --- /dev/null +++ b/dpkg-split/split.c @@ -0,0 +1,71 @@ +/* + * dpkg-split - splitting and joining of multipart *.deb archives + * split.c - splitting archives + * + * Copyright (C) 1995 Ian Jackson <ian@chiark.greenend.org.uk> + * + * This is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2, + * or (at your option) any later version. + * + * This is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * 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. + */ +#include <config.h> + +#include <stdio.h> +#include <stdlib.h> +#include <limits.h> +#include <assert.h> +#include <unistd.h> +#include <string.h> +#include <sys/stat.h> +#include <fcntl.h> + +#include <dpkg.h> +#include <dpkg-db.h> +#include "dpkg-split.h" + +void do_split(const char *const *argv) { + const char *sourcefile, *prefix; + char *palloc; + int l, fd; + char partsizebuf[30], lengthbuf[30], partsizeallowbuf[30]; + struct stat stab; + + sourcefile= *argv++; + if (!sourcefile) + badusage(_("--split needs a source filename argument")); + prefix= *argv++; + if (prefix && *argv) + badusage(_("--split takes at most a source filename and destination prefix")); + if (!prefix) { + l= strlen(sourcefile); + palloc= nfmalloc(l+1); + strcpy(palloc,sourcefile); + if (!strcmp(palloc+l-(sizeof(DEBEXT)-1),DEBEXT)) { + l -= (sizeof(DEBEXT)-1); + palloc[l]= 0; + } + prefix= palloc; + } + sprintf(partsizebuf,"%ld",maxpartsize-HEADERALLOWANCE); + sprintf(partsizeallowbuf,"%ld",maxpartsize); + fd= open(sourcefile,O_RDONLY); + if (!fd) ohshite(_("unable to open source file `%.250s'"),sourcefile); + if (fstat(fd,&stab)) ohshite(_("unable to fstat source file")); + if (!S_ISREG(stab.st_mode)) ohshit(_("source file `%.250s' not a plain file"),sourcefile); + sprintf(lengthbuf,"%lu",(unsigned long)stab.st_size); + m_dup2(fd,0); + execl(MKSPLITSCRIPT,MKSPLITSCRIPT, + sourcefile,partsizebuf,prefix,lengthbuf,partsizeallowbuf,msdos?"yes":"no", + NULL); + ohshite(_("unable to exec mksplit")); +} |