...
 
Commits (6)
# This is just the bootstrapping makefile; the one to build udpkg is makefile
all: configure
./configure && make
configure: configure.in
autoconf
.PHONY: clean distclean
bin_PROGRAMS = udpkg
udpkg_SOURCES = \
depends.c \
status.c \
udpkg.c
udpkg_LDFLAGS = -ldebian-installer
#undef PACKAGE
#undef VERSION
/*
* Should we do full dependency checking?
*/
#undef DODEPENDS
/*
* Should we do debugging?
*/
#undef DODEBUG
/*
* Should we call debconf-loadtemplate?
*/
#undef DOLOADTEMPLATE
/*
* Support l18n?
*/
#undef SUPPORTL18N
This diff is collapsed.
AC_INIT([udpkg],[0.1])
AC_CONFIG_SRCDIR([udpkg.c])
AM_INIT_AUTOMAKE([foreign 1.8 no-define no-dist no-installinfo no-installman -Wall])
AC_CONFIG_HEADER([config.h])
AM_MAINTAINER_MODE
AC_PROG_CC
AC_ISC_POSIX
AC_GNU_SOURCE
AC_MSG_CHECKING(architecture)
DEB_ARCH=$(dpkg-architecture -qDEB_BUILD_ARCH)
AC_MSG_RESULT($DEB_ARCH)
AC_DEFINE_UNQUOTED([ARCH_TEXT],["$DEB_ARCH"],[Debian architecture])
AC_ARG_ENABLE(debug,AS_HELP_STRING([--enable-debug],[debugging]),,[enable_debug=no])
if test "$enable_debug" = "yes"; then
AC_DEFINE(DODEBUG,[],[Enable debug])
CFLAGS="$CFLAGS -g"
fi
dnl Do dependency checking?
AC_ARG_ENABLE(depends,AS_HELP_STRING([--enable-depends],[do not do dependency checking]),,[enable_depends=no])
if test "$enable_depends" = "yes"; then
AC_DEFINE(DODEPENDS,[],[Should we do full dependency checking])
fi
dnl Load templates?
AC_ARG_ENABLE(loadtemplate,AS_HELP_STRING([--disable-loadtemplate],[do not call debconf-loadtemplate]),,[enable_loadtemplate=yes])
if test "$enable_loadtemplate" = "yes"; then
AC_DEFINE(DOLOADTEMPLATE,[],[Should we call debconf-loadtemplate])
fi
dnl Support localized status files?
AC_ARG_ENABLE(l18n,AS_HELP_STRING([--enable-l18n],[support localized status files]),,[enable_l18n=no])
if test "$enable_l18n" = "yes"; then
AC_DEFINE(SUPPORTL18N,[],[Support l18n])
fi
dnl Do we need --remove support?
AC_ARG_ENABLE(remove,AS_HELP_STRING([--enable-remove],[support the --remove flag]),,[enable_remove=no])
if test "$enable_remove" = "yes"; then
AC_DEFINE(DOREMOVE,[],[Support --remove])
fi
dnl dpkg library directory
ADMINDIR="/var/lib/dpkg"
AC_ARG_WITH(admindir,AS_HELP_STRING([--with-admindir=DIR],[store dpkg data in DIR [/var/lib/dpkg]]),
[case "$withval" in
"") AC_MSG_ERROR(invalid admindir specified) ;;
*) ADMINDIR="$withval" ;;
esac])
AC_DEFINE_UNQUOTED(ADMINDIR,"$ADMINDIR",[Admindir])
AC_HEADER_SYS_WAIT
AC_CHECK_HEADERS(fcntl.h string.h sys/time.h unistd.h)
AC_C_CONST
AC_C_INLINE
AC_HEADER_TIME
AC_TYPE_SIGNAL
AC_CONFIG_FILES(Makefile)
AC_OUTPUT
dnl Process this file with autoconf to produce a configure script.
dnl The ONLY thing this is used for is to configure for different
dnl linux architectures and configurations, it is not used to make the
dnl code more portable
AC_INIT(configure.in)
CFLAGS="-Wall $CFLAGS"
AC_CONFIG_AUX_DIR(.)
AC_CONFIG_HEADER(config.h:config.h.in)
AC_DEFINE_UNQUOTED(VERSION,"0.1")
AC_DEFINE_UNQUOTED(PACKAGE,"udpkg")
dnl Checks for programs.
AC_PROG_CC
AC_ISC_POSIX
dnl Checks for libraries.
dnl Enable debugging?
AC_ARG_WITH(debug,[ --without-debug turn off debugging?])
if test "$with_debug" != "no"; then
AC_DEFINE(DODEBUG)
CFLAGS="$CFLAGS -g"
fi
dnl Do dependency checking?
AC_ARG_WITH(depends,[ --without-depends do not do dependency checking])
if test "$with_depends" != "no"; then
AC_DEFINE(DODEPENDS)
fi
dnl Load templates?
AC_ARG_WITH(loadtemplate,[ --without-loadtemplate do not call debconf-loadtemplate])
if test "$with_loadtemplate" != "no"; then
AC_DEFINE(DOLOADTEMPLATE)
fi
dnl Support localized status files?
AC_ARG_WITH(l18n,[ --without-l18n do not support localized status files])
if test "$with_l18n" != "no"; then
AC_DEFINE(SUPPORTL18N)
fi
dnl Do we need --remove support?
AC_ARG_WITH(remove,[ --without-remove do not support the --remove flag])
if test "$with_remove" != "no"; then
AC_DEFINE(DOREMOVE)
fi
dnl dpkg library directory
ADMINDIR="/var/lib/dpkg"
AC_ARG_WITH(admindir,[ --with-admindir=DIR store dpkg data in DIR [/var/lib/dpkg]],
[case "$withval" in
"") AC_MSG_ERROR(invalid admindir specified) ;;
*) ADMINDIR="$withval" ;;
esac])
AC_SUBST(ADMINDIR)
dnl use busybox?
AC_ARG_WITH(busybox,[ --with-busybox=DIR link with busybox in DIR [/usr/src/busybox]])
if test -n "$with_busybox"; then
BUSYBOXDIR="/usr/src/busybox"
if test "$with_busybox" != "yes"; then
BUSYBOXDIR="$with_busybox"
fi
AC_MSG_CHECKING(for busybox in $BUSYBOXDIR)
if test -f "$BUSYBOXDIR/busybox.def.h"; then
AC_MSG_RESULT(yes)
else
AC_MSG_RESULT(no)
exit 1
fi
fi
AC_SUBST(BUSYBOXDIR)
dnl Checks for header files.
AC_HEADER_SYS_WAIT
AC_CHECK_HEADERS(fcntl.h string.h sys/time.h unistd.h)
dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_C_INLINE
AC_HEADER_TIME
dnl Checks for library functions.
AC_TYPE_SIGNAL
AC_OUTPUT(makefile:makefile.in)
udpkg (0.025) UNRELEASED; urgency=low
* Bastian Blank
- Remove autogenerated files.
- Update autoconf files.
* Colin Watson
- dpkg_doconfigure returns di_exec_mangle_status of the postinst rather
than just WEXITSTATUS, so that a segfaulting postinst doesn't send
main-menu into an infinite loop.
* Thiemo Seufer
- Don't generate useless Makefile targets, fix package name, require
modern automake versions in configure.ac.
- Replace asprintf with snprintf, in udpkg.c. Improve error messages.
Formatting fixes.
-- Bastian Blank <waldi@debian.org> Sun, 11 Apr 2004 10:32:10 +0200
udpkg (0.024) unstable; urgency=low
* Use /var/lib/dpkg/status, not /var/lib/dpkg/status.udeb.
......
......@@ -3,7 +3,7 @@ Section: debian-installer
Priority: standard
Maintainer: Debian Install System Team <debian-boot@lists.debian.org>
Uploaders: Bastian Blank <waldi@debian.org>, Petter Reinholdtsen <pere@debian.org>
Build-Depends: debhelper (>= 4.2), dpkg-dev (>= 1.7.0), libdebian-installer4-dev
Build-Depends: debhelper (>= 4.2), dpkg-dev (>= 1.7.0), libdebian-installer4-dev, autotools-dev
Standards-Version: 3.6.0
Package: udpkg
......
#!/usr/bin/make -f
# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1
DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
CFLAGS = -Wall -W -gstabs
ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
CFLAGS += -O0
else
CFLAGS += -Os -fomit-frame-pointer
endif
export CFLAGS
configure:
AUTOMAKE=automake-1.8 ACLOCAL=aclocal-1.8 \
autoreconf -i -v
config.status: configure
dh_testdir
./configure \
--host=$(DEB_HOST_GNU_TYPE) \
--build=$(DEB_BUILD_GNU_TYPE) \
--prefix=/usr \
--with-admindir=/var/lib/dpkg
build: build-stamp
build-stamp:
build-stamp: config.status
dh_testdir
CFLAGS="-W -Wall -Os" ./configure --without-depends --without-debug \
--without-remove --with-admindir=/var/lib/dpkg
$(MAKE) small
touch build-stamp
$(MAKE)
touch $@
clean:
dh_testdir
dh_testroot
rm -f build-stamp
-$(MAKE) distclean
ifneq "$(wildcard /usr/share/misc/config.sub)" ""
-cp -f /usr/share/misc/config.sub config.sub
endif
ifneq "$(wildcard /usr/share/misc/config.guess)" ""
-cp -f /usr/share/misc/config.guess config.guess
endif
dh_clean
install: build
......
/* $Id: depends.c,v 1.7 2000/12/21 23:58:12 bug1 Rel $ */
/* $Id$ */
#include "udpkg.h"
#ifdef DODEPENDS
......
#! /bin/sh
#
# install - install a program, script, or datafile
# This comes from X11R5.
#
# Calling this script install-sh is preferred over install.sh, to prevent
# `make' implicit rules from creating a file called install from it
# when there is no Makefile.
#
# This script is compatible with the BSD install script, but was written
# from scratch.
#
# set DOITPROG to echo to test this script
# Don't use :- since 4.3BSD and earlier shells don't like it.
doit="${DOITPROG-}"
# put in absolute paths if you don't have them in your path; or use env. vars.
mvprog="${MVPROG-mv}"
cpprog="${CPPROG-cp}"
chmodprog="${CHMODPROG-chmod}"
chownprog="${CHOWNPROG-chown}"
chgrpprog="${CHGRPPROG-chgrp}"
stripprog="${STRIPPROG-strip}"
rmprog="${RMPROG-rm}"
mkdirprog="${MKDIRPROG-mkdir}"
tranformbasename=""
transform_arg=""
instcmd="$mvprog"
chmodcmd="$chmodprog 0755"
chowncmd=""
chgrpcmd=""
stripcmd=""
rmcmd="$rmprog -f"
mvcmd="$mvprog"
src=""
dst=""
dir_arg=""
while [ x"$1" != x ]; do
case $1 in
-c) instcmd="$cpprog"
shift
continue;;
-d) dir_arg=true
shift
continue;;
-m) chmodcmd="$chmodprog $2"
shift
shift
continue;;
-o) chowncmd="$chownprog $2"
shift
shift
continue;;
-g) chgrpcmd="$chgrpprog $2"
shift
shift
continue;;
-s) stripcmd="$stripprog"
shift
continue;;
-t=*) transformarg=`echo $1 | sed 's/-t=//'`
shift
continue;;
-b=*) transformbasename=`echo $1 | sed 's/-b=//'`
shift
continue;;
*) if [ x"$src" = x ]
then
src=$1
else
# this colon is to work around a 386BSD /bin/sh bug
:
dst=$1
fi
shift
continue;;
esac
done
if [ x"$src" = x ]
then
echo "install: no input file specified"
exit 1
else
true
fi
if [ x"$dir_arg" != x ]; then
dst=$src
src=""
if [ -d $dst ]; then
instcmd=:
else
instcmd=mkdir
fi
else
# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
# might cause directories to be created, which would be especially bad
# if $src (and thus $dsttmp) contains '*'.
if [ -f $src -o -d $src ]
then
true
else
echo "install: $src does not exist"
exit 1
fi
if [ x"$dst" = x ]
then
echo "install: no destination specified"
exit 1
else
true
fi
# If destination is a directory, append the input filename; if your system
# does not like double slashes in filenames, you may need to add some logic
if [ -d $dst ]
then
dst="$dst"/`basename $src`
else
true
fi
fi
## this sed command emulates the dirname command
dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
# Make sure that the destination directory exists.
# this part is taken from Noah Friedman's mkinstalldirs script
# Skip lots of stat calls in the usual case.
if [ ! -d "$dstdir" ]; then
defaultIFS='
'
IFS="${IFS-${defaultIFS}}"
oIFS="${IFS}"
# Some sh's can't handle IFS=/ for some reason.
IFS='%'
set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
IFS="${oIFS}"
pathcomp=''
while [ $# -ne 0 ] ; do
pathcomp="${pathcomp}${1}"
shift
if [ ! -d "${pathcomp}" ] ;
then
$mkdirprog "${pathcomp}"
else
true
fi
pathcomp="${pathcomp}/"
done
fi
if [ x"$dir_arg" != x ]
then
$doit $instcmd $dst &&
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi &&
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi &&
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi &&
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi
else
# If we're going to rename the final executable, determine the name now.
if [ x"$transformarg" = x ]
then
dstfile=`basename $dst`
else
dstfile=`basename $dst $transformbasename |
sed $transformarg`$transformbasename
fi
# don't allow the sed command to completely eliminate the filename
if [ x"$dstfile" = x ]
then
dstfile=`basename $dst`
else
true
fi
# Make a temp file name in the proper directory.
dsttmp=$dstdir/#inst.$$#
# Move or copy the file name to the temp name
$doit $instcmd $src $dsttmp &&
trap "rm -f ${dsttmp}" 0 &&
# and set any options; do chmod last to preserve setuid bits
# If any of these fail, we abort the whole thing. If we want to
# ignore errors from any of these, just make sure not to ignore
# errors from the above "$doit $instcmd $src $dsttmp" command.
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi &&
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi &&
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi &&
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi &&
# Now rename the file to the real destination.
$doit $rmcmd -f $dstdir/$dstfile &&
$doit $mvcmd $dsttmp $dstdir/$dstfile
fi &&
exit 0
DEB_HOST_ARCH ?= $(shell dpkg-architecture -qDEB_HOST_ARCH)
CC=@CC@
CFLAGS=@CFLAGS@ -D_GNU_SOURCE -DADMINDIR=\"@ADMINDIR@\" -DARCH_TEXT='"$(DEB_HOST_ARCH)"'
OBJS=$(subst .c,.o,$(wildcard *.c))
BIN=udpkg
BUSYBOX=@BUSYBOXDIR@
LIBS=-ldebian-installer
ifdef DEBUG
CFLAGS:=$(CFLAGS) -DDODEBUG
endif
all: $(BIN)
# Size optimized and stripped binary target.
small: CFLAGS += -Os
small: clean $(BIN)
strip --remove-section=.comment --remove-section=.note $(BIN)
ls -l $(BIN)
$(BIN): $(OBJS)
$(CC) -o $(BIN) $(OBJS) $(LIBS)
clean:
-rm -f $(BIN) $(OBJS) *~
distclean: clean
-rm -f config.status config.log config.cache makefile config.h
*.o: udpkg.h
/* $Id: status.c,v 1.27 2003/02/12 03:12:39 kraai Rel $ */
/* $Id$ */
#include "udpkg.h"
#include <stdio.h>
......
/* $Id: udpkg.c,v 1.49 2004/03/08 21:49:20 joeyh Exp $ */
/* $Id$ */
#include "udpkg.h"
#include <errno.h>
......@@ -76,13 +76,12 @@ static int dpkg_doconfigure(struct package_t *pkg)
char buf[1024];
DPRINTF("Configuring %s [force=%d]\n", pkg->package, force_configure);
if ((pkg->status & STATUS_STATUSINSTALLED) != 0 &&
!force_configure)
{
PRINTF("Package %s is already installed and configured\n",
pkg->package);
return 1;
}
if ((pkg->status & STATUS_STATUSINSTALLED) != 0 && !force_configure)
{
PRINTF("Package %s is already installed and configured\n",
pkg->package);
return 1;
}
pkg->status &= STATUS_STATUSMASK;
......@@ -105,9 +104,9 @@ static int dpkg_doconfigure(struct package_t *pkg)
if ((r = di_exec_shell_log(buf)) != 0)
{
FPRINTF(stderr, "%s's postinst exited with status %d\n",
pkg->package, WEXITSTATUS(r));
pkg->package, di_exec_mangle_status(r));
pkg->status |= STATUS_STATUSHALFCONFIGURED;
return WEXITSTATUS(r);
return di_exec_mangle_status(r);
}
}
......@@ -121,7 +120,7 @@ static int dpkg_dounpack(struct package_t *pkg)
int r = 0;
char *cwd;
char buf[1024], buf2[1024];
int i;
unsigned int i;
char *adminscripts[] = { "prerm", "postrm", "preinst", "postinst",
"conffiles", "md5sums", "shlibs",
"templates", "menutest", "isinstallable",
......@@ -387,17 +386,18 @@ static int dpkg_install(struct package_t *pkgs)
static int dpkg_fields(struct package_t *pkg)
{
char *command;
int ret;
char buf[1024];
if (pkg == NULL)
{
FPRINTF(stderr, "udpkg: The -f flag requires an argument.\n");
return 1;
}
asprintf(&command, "ar -p %s control.tar.gz|tar -xzOf - ./control", pkg->file);
ret = system(command);
free(command);
snprintf(buf, sizeof(buf), "ar -p %s control.tar.gz|tar -xzOf - ./control", pkg->file);
if ((ret = system(buf)) != 0)
FPRINTF(stderr, "field extraction failed with status %d\n", ret);
return ret;
}
......@@ -408,6 +408,8 @@ static int dpkg_remove(struct package_t *pkgs)
void *status = status_read();
for (p = pkgs; p != 0; p = p->next)
{
FPRINTF(stderr, "udpkg: Support for -r not implemented.\n");
return 1;
}
status_merge(status, 0);
return 0;
......@@ -426,52 +428,55 @@ int main(int argc, char **argv)
int opt = 0;
struct package_t *p, *packages = NULL;
char *cwd = getcwd(0, 0);
char **origargv = argv;
struct option longopts[] = {
char **origargv = argv;
struct option longopts[] = {
/* name, has_arg, flag, val */
{ "unpack", 0, 0, 'u' },
{ "configure", 0, 0, 'c' },
{ "print-architecture", 0, 0, 'p' } ,
{ "force-configure", 0, &force_configure, 1 },
{ 0, 0, 0, 0 },
};
{ "unpack", 0, 0, 'u' },
{ "configure", 0, 0, 'c' },
{ "print-architecture", 0, 0, 'p' } ,
{ "force-configure", 0, &force_configure, 1 },
{ 0, 0, 0, 0 },
};
while (*++argv)
{
if (**argv != '-')
{
p = (struct package_t *)malloc(sizeof(struct package_t));
memset(p, 0, sizeof(struct package_t));
p = (struct package_t *)calloc(1, sizeof(struct package_t));
if (**argv == '/')
p->file = *argv;
else
asprintf(&p->file, "%s/%s", cwd, *argv);
else
{
size_t len = strlen(cwd) + strlen(*argv) + 2;
p->file = (char *)malloc(len);
snprintf(p->file, len, "%s/%s", cwd, *argv);
}
p->package = strdup(*argv);
p->next = packages;
packages = p;
}
}
/* let's do this in a silly way, the first pass let's us
* set flags (e.g. --force-configure), whereas the second
* will actually do stuff
*/
while (getopt_long(argc, origargv, "irf", longopts, 0) >= 0)
/* nothing */;
optind = 1;
/* let's do this in a silly way, the first pass let's us
* set flags (e.g. --force-configure), whereas the second
* will actually do stuff
*/
while (getopt_long(argc, origargv, "irf", longopts, 0) >= 0)
/* nothing */;
optind = 1;
while ((opt = getopt_long(argc, origargv, "irf", longopts, 0)) >= 0)
{
while ((opt = getopt_long(argc, origargv, "irf", longopts, 0)) >= 0)
{
switch (opt)
{
case 'i': return dpkg_install(packages); break;
case 'r': return dpkg_remove(packages); break;
case 'u': return dpkg_unpack(packages); break;
case 'c': return dpkg_configure(packages); break;
case 'p': return dpkg_print_architecture(); break;
case 'f': return dpkg_fields(packages); break;
case 0: /* option, not action */; break;
}
{
case 'i': return dpkg_install(packages); break;
case 'r': return dpkg_remove(packages); break;
case 'u': return dpkg_unpack(packages); break;
case 'c': return dpkg_configure(packages); break;
case 'p': return dpkg_print_architecture(); break;
case 'f': return dpkg_fields(packages); break;
case 0: /* option, not action */; break;
}
}
/* if it falls through to here, some of the command line options were
......