Commit ed5e3e09 authored by Bernhard Link's avatar Bernhard Link

Initial revision

parents
Bernhard R. Link <brlink@debian.org>
This diff is collapsed.
Basic Installation
==================
These are generic installation instructions.
The `configure' shell script attempts to guess correct values for
various system-dependent variables used during compilation. It uses
those values to create a `Makefile' in each directory of the package.
It may also create one or more `.h' files containing system-dependent
definitions. Finally, it creates a shell script `config.status' that
you can run in the future to recreate the current configuration, a file
`config.cache' that saves the results of its tests to speed up
reconfiguring, and a file `config.log' containing compiler output
(useful mainly for debugging `configure').
If you need to do unusual things to compile the package, please try
to figure out how `configure' could check whether to do them, and mail
diffs or instructions to the address given in the `README' so they can
be considered for the next release. If at some point `config.cache'
contains results you don't want to keep, you may remove or edit it.
The file `configure.in' is used to create `configure' by a program
called `autoconf'. You only need `configure.in' if you want to change
it or regenerate `configure' using a newer version of `autoconf'.
The simplest way to compile this package is:
1. `cd' to the directory containing the package's source code and type
`./configure' to configure the package for your system. If you're
using `csh' on an old version of System V, you might need to type
`sh ./configure' instead to prevent `csh' from trying to execute
`configure' itself.
Running `configure' takes awhile. While running, it prints some
messages telling which features it is checking for.
2. Type `make' to compile the package.
3. Optionally, type `make check' to run any self-tests that come with
the package.
4. Type `make install' to install the programs and any data files and
documentation.
5. You can remove the program binaries and object files from the
source code directory by typing `make clean'. To also remove the
files that `configure' created (so you can compile the package for
a different kind of computer), type `make distclean'. There is
also a `make maintainer-clean' target, but that is intended mainly
for the package's developers. If you use it, you may have to get
all sorts of other programs in order to regenerate files that came
with the distribution.
Compilers and Options
=====================
Some systems require unusual options for compilation or linking that
the `configure' script does not know about. You can give `configure'
initial values for variables by setting them in the environment. Using
a Bourne-compatible shell, you can do that on the command line like
this:
CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure
Or on systems that have the `env' program, you can do it like this:
env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure
Compiling For Multiple Architectures
====================================
You can compile the package for more than one kind of computer at the
same time, by placing the object files for each architecture in their
own directory. To do this, you must use a version of `make' that
supports the `VPATH' variable, such as GNU `make'. `cd' to the
directory where you want the object files and executables to go and run
the `configure' script. `configure' automatically checks for the
source code in the directory that `configure' is in and in `..'.
If you have to use a `make' that does not supports the `VPATH'
variable, you have to compile the package for one architecture at a time
in the source code directory. After you have installed the package for
one architecture, use `make distclean' before reconfiguring for another
architecture.
Installation Names
==================
By default, `make install' will install the package's files in
`/usr/local/bin', `/usr/local/man', etc. You can specify an
installation prefix other than `/usr/local' by giving `configure' the
option `--prefix=PATH'.
You can specify separate installation prefixes for
architecture-specific files and architecture-independent files. If you
give `configure' the option `--exec-prefix=PATH', the package will use
PATH as the prefix for installing programs and libraries.
Documentation and other data files will still use the regular prefix.
In addition, if you use an unusual directory layout you can give
options like `--bindir=PATH' to specify different values for particular
kinds of files. Run `configure --help' for a list of the directories
you can set and what kinds of files go in them.
If the package supports it, you can cause programs to be installed
with an extra prefix or suffix on their names by giving `configure' the
option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
Optional Features
=================
Some packages pay attention to `--enable-FEATURE' options to
`configure', where FEATURE indicates an optional part of the package.
They may also pay attention to `--with-PACKAGE' options, where PACKAGE
is something like `gnu-as' or `x' (for the X Window System). The
`README' should mention any `--enable-' and `--with-' options that the
package recognizes.
For packages that use the X Window System, `configure' can usually
find the X include and library files automatically, but if it doesn't,
you can use the `configure' options `--x-includes=DIR' and
`--x-libraries=DIR' to specify their locations.
Specifying the System Type
==========================
There may be some features `configure' can not figure out
automatically, but needs to determine by the type of host the package
will run on. Usually `configure' can figure that out, but if it prints
a message saying it can not guess the host type, give it the
`--host=TYPE' option. TYPE can either be a short name for the system
type, such as `sun4', or a canonical name with three fields:
CPU-COMPANY-SYSTEM
See the file `config.sub' for the possible values of each field. If
`config.sub' isn't included in this package, then this package doesn't
need to know the host type.
If you are building compiler tools for cross-compiling, you can also
use the `--target=TYPE' option to select the type of system they will
produce code for and the `--build=TYPE' option to select the type of
system on which you are compiling the package.
Sharing Defaults
================
If you want to set default values for `configure' scripts to share,
you can create a site shell script called `config.site' that gives
default values for variables like `CC', `cache_file', and `prefix'.
`configure' looks for `PREFIX/share/config.site' if it exists, then
`PREFIX/etc/config.site' if it exists. Or, you can set the
`CONFIG_SITE' environment variable to the location of the site script.
A warning: not all `configure' scripts look for a site script.
Operation Controls
==================
`configure' recognizes the following options to control how it
operates.
`--cache-file=FILE'
Use and save the results of the tests in FILE instead of
`./config.cache'. Set FILE to `/dev/null' to disable caching, for
debugging `configure'.
`--help'
Print a summary of the options to `configure', and exit.
`--quiet'
`--silent'
`-q'
Do not print messages saying which checks are being made. To
suppress all normal output, redirect it to `/dev/null' (any error
messages will still be shown).
`--srcdir=DIR'
Look for the package's source code in directory DIR. Usually
`configure' can determine that directory automatically.
`--version'
Print the version of Autoconf used to generate the `configure'
script, and exit.
`configure' also accepts some other, not widely useful, options.
bin_PROGRAMS = mirrorer
CPPFLAGS = @CPPFLAGS@ -D_GNU_SOURCE=1 -DPKGDATADIR=\"$(pkgdatadir)\" -Wall
mirrorer_SOURCES = main.c files.c md5.c md5sum.c dirs.c chunks.c reference.c packages.c binaries.c sources.c names.c dpkgversions.c release.c
mirrorer_LDFLAGS += -ldb3
noinst_HEADERS = md5.h md5sum.h dirs.h files.h chunks.h reference.h packages.h binaries.h sources.h names.h release.h
This diff is collapsed.
No news yet, as nothing finished.
TODO: write this file
dnl aclocal.m4 generated automatically by aclocal 1.4-p6
dnl Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
dnl This program is distributed in the hope that it will be useful,
dnl but WITHOUT ANY WARRANTY, to the extent permitted by law; without
dnl even the implied warranty of MERCHANTABILITY or FITNESS FOR A
dnl PARTICULAR PURPOSE.
# Like AC_CONFIG_HEADER, but automatically create stamp file.
AC_DEFUN([AM_CONFIG_HEADER],
[AC_PREREQ([2.12])
AC_CONFIG_HEADER([$1])
dnl When config.status generates a header, we must update the stamp-h file.
dnl This file resides in the same directory as the config header
dnl that is generated. We must strip everything past the first ":",
dnl and everything past the last "/".
AC_OUTPUT_COMMANDS(changequote(<<,>>)dnl
ifelse(patsubst(<<$1>>, <<[^ ]>>, <<>>), <<>>,
<<test -z "<<$>>CONFIG_HEADERS" || echo timestamp > patsubst(<<$1>>, <<^\([^:]*/\)?.*>>, <<\1>>)stamp-h<<>>dnl>>,
<<am_indx=1
for am_file in <<$1>>; do
case " <<$>>CONFIG_HEADERS " in
*" <<$>>am_file "*<<)>>
echo timestamp > `echo <<$>>am_file | sed -e 's%:.*%%' -e 's%[^/]*$%%'`stamp-h$am_indx
;;
esac
am_indx=`expr "<<$>>am_indx" + 1`
done<<>>dnl>>)
changequote([,]))])
# Do all the work for Automake. This macro actually does too much --
# some checks are only needed if your package does certain things.
# But this isn't really a big deal.
# serial 1
dnl Usage:
dnl AM_INIT_AUTOMAKE(package,version, [no-define])
AC_DEFUN([AM_INIT_AUTOMAKE],
[AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl
AC_REQUIRE([AC_PROG_INSTALL])
PACKAGE=[$1]
AC_SUBST(PACKAGE)
VERSION=[$2]
AC_SUBST(VERSION)
dnl test to see if srcdir already configured
if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then
AC_MSG_ERROR([source directory already configured; run "make distclean" there first])
fi
ifelse([$3],,
AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package])
AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package]))
AC_REQUIRE([AM_SANITY_CHECK])
AC_REQUIRE([AC_ARG_PROGRAM])
dnl FIXME This is truly gross.
missing_dir=`cd $ac_aux_dir && pwd`
AM_MISSING_PROG(ACLOCAL, aclocal-${am__api_version}, $missing_dir)
AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
AM_MISSING_PROG(AUTOMAKE, automake-${am__api_version}, $missing_dir)
AM_MISSING_PROG(AUTOHEADER, autoheader, $missing_dir)
AM_MISSING_PROG(MAKEINFO, makeinfo, $missing_dir)
AC_REQUIRE([AC_PROG_MAKE_SET])])
# Copyright 2002 Free Software Foundation, Inc.
# This program 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 program 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 this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
# AM_AUTOMAKE_VERSION(VERSION)
# ----------------------------
# Automake X.Y traces this macro to ensure aclocal.m4 has been
# generated from the m4 files accompanying Automake X.Y.
AC_DEFUN([AM_AUTOMAKE_VERSION],[am__api_version="1.4"])
# AM_SET_CURRENT_AUTOMAKE_VERSION
# -------------------------------
# Call AM_AUTOMAKE_VERSION so it can be traced.
# This function is AC_REQUIREd by AC_INIT_AUTOMAKE.
AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
[AM_AUTOMAKE_VERSION([1.4-p6])])
#
# Check to make sure that the build environment is sane.
#
AC_DEFUN([AM_SANITY_CHECK],
[AC_MSG_CHECKING([whether build environment is sane])
# Just in case
sleep 1
echo timestamp > conftestfile
# Do `set' in a subshell so we don't clobber the current shell's
# arguments. Must try -L first in case configure is actually a
# symlink; some systems play weird games with the mod time of symlinks
# (eg FreeBSD returns the mod time of the symlink's containing
# directory).
if (
set X `ls -Lt $srcdir/configure conftestfile 2> /dev/null`
if test "[$]*" = "X"; then
# -L didn't work.
set X `ls -t $srcdir/configure conftestfile`
fi
if test "[$]*" != "X $srcdir/configure conftestfile" \
&& test "[$]*" != "X conftestfile $srcdir/configure"; then
# If neither matched, then we have a broken ls. This can happen
# if, for instance, CONFIG_SHELL is bash and it inherits a
# broken ls alias from the environment. This has actually
# happened. Such a system could not be considered "sane".
AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken
alias in your environment])
fi
test "[$]2" = conftestfile
)
then
# Ok.
:
else
AC_MSG_ERROR([newly created file is older than distributed files!
Check your system clock])
fi
rm -f conftest*
AC_MSG_RESULT(yes)])
dnl AM_MISSING_PROG(NAME, PROGRAM, DIRECTORY)
dnl The program must properly implement --version.
AC_DEFUN([AM_MISSING_PROG],
[AC_MSG_CHECKING(for working $2)
# Run test in a subshell; some versions of sh will print an error if
# an executable is not found, even if stderr is redirected.
# Redirect stdin to placate older versions of autoconf. Sigh.
if ($2 --version) < /dev/null > /dev/null 2>&1; then
$1=$2
AC_MSG_RESULT(found)
else
$1="$3/missing $2"
AC_MSG_RESULT(missing)
fi
AC_SUBST($1)])
# Add --enable-maintainer-mode option to configure.
# From Jim Meyering
# serial 1
AC_DEFUN([AM_MAINTAINER_MODE],
[AC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles])
dnl maintainer-mode is disabled by default
AC_ARG_ENABLE(maintainer-mode,
[ --enable-maintainer-mode enable make rules and dependencies not useful
(and sometimes confusing) to the casual installer],
USE_MAINTAINER_MODE=$enableval,
USE_MAINTAINER_MODE=no)
AC_MSG_RESULT($USE_MAINTAINER_MODE)
AM_CONDITIONAL(MAINTAINER_MODE, test $USE_MAINTAINER_MODE = yes)
MAINT=$MAINTAINER_MODE_TRUE
AC_SUBST(MAINT)dnl
]
)
# Define a conditional.
AC_DEFUN([AM_CONDITIONAL],
[AC_SUBST($1_TRUE)
AC_SUBST($1_FALSE)
if $2; then
$1_TRUE=
$1_FALSE='#'
else
$1_TRUE='#'
$1_FALSE=
fi])
#include <string.h>
#include <strings.h>
#include <stdio.h>
#include <malloc.h>
#include "packages.h"
#include "chunks.h"
#include "binaries.h"
#include "names.h"
#include "dpkgversions.h"
extern int verbose;
extern int force;
/* get somefields out of a "Packages.gz"-chunk. returns 1 on success, 0 if incomplete, -1 on error */
static int binaries_parse_chunk(const char *chunk,char **packagename,char **origfilename,char **sourcename,char **filename,char **md5andsize) {
const char *f,*f2;
char *pmd5,*psize,*ppackage;
#define IFREE(p) if(p) free(*p);
f = chunk_getfield("Package",chunk);
if( !f ) {
return 0;
}
ppackage = chunk_dupvalue(f);
if( !ppackage ) {
return -1;
}
if( packagename ) {
*packagename = ppackage;
}
if( origfilename ) {
/* Read the filename given there */
f = chunk_getfield("Filename",chunk);
if( ! f ) {
free(ppackage);
return 0;
}
*origfilename = chunk_dupvalue(f);
if( !*origfilename ) {
free(ppackage);
return -1;
}
if( verbose > 3 )
fprintf(stderr,"got: %s\n",*origfilename);
}
/* collect the given md5sum and size */
if( md5andsize ) {
f = chunk_getfield("MD5sum",chunk);
f2 = chunk_getfield("Size",chunk);
if( !f || !f2 ) {
free(ppackage);
IFREE(origfilename);
return 0;
}
pmd5 = chunk_dupvalue(f);
psize = chunk_dupvalue(f2);
if( !pmd5 || !psize ) {
free(ppackage);
free(psize);free(pmd5);
IFREE(origfilename);
return -1;
}
asprintf(md5andsize,"%s %s",pmd5,psize);
free(pmd5);free(psize);
if( !*md5andsize ) {
free(ppackage);
IFREE(origfilename);
return -1;
}
}
/* get the sourcename */
if( sourcename ) {
f = chunk_getfield("Source",chunk);
if( f )
/* do something with the version here? */
*sourcename = chunk_dupword(f);
else {
*sourcename = strdup(ppackage);
}
if( !*sourcename ) {
free(ppackage);
IFREE(origfilename);
IFREE(md5andsize);
return -1;
}
}
/* generate a filename based on package,version and architecture */
if( filename ) {
char *parch,*pversion,*v;
f = chunk_getfield("Version",chunk);
f2 = chunk_getfield("Architecture",chunk);
if( !f || !f2 ) {
free(ppackage);
IFREE(origfilename);
IFREE(md5andsize);
IFREE(sourcename);
return 0;
}
pversion = chunk_dupvalue(f);
parch = chunk_dupvalue(f2);
if( !parch || !pversion ) {
free(ppackage);
IFREE(origfilename);
IFREE(md5andsize);
IFREE(sourcename);
return -1;
}
v = index(pversion,':');
if( v )
v++;
else
v = pversion;
/* TODO check parts to contain out of save charakters */
*filename = calc_package_filename(ppackage,v,parch);
if( !*filename ) {
free(pversion);free(parch);
free(ppackage);
IFREE(origfilename);
IFREE(md5andsize);
IFREE(sourcename);
return -1;
}
free(pversion);free(parch);
}
if( packagename == NULL)
free(ppackage);
return 1;
}
/* check if one chunk describes a packages superseded by another
* return 1=new is better, 0=old is better, <0 error */
static int binaries_isnewer(const char *newchunk,const char *oldchunk) {
char *nv,*ov;
int r;
/* if new broken, old is better, if old broken, new is better: */
nv = chunk_dupvalue(chunk_getfield("Version",newchunk));
if( !nv )
return -1;
ov = chunk_dupvalue(chunk_getfield("Version",oldchunk));
if( !ov ) {
free(nv);
return 1;
}
r = isVersionNewer(nv,ov);
free(nv);free(ov);
return r;
}
/* call action for each package in packages_file */
int binaries_add(DB *pkgs,const char *part,const char *packages_file, binary_package_action action,void *data) {
gzFile *fi;
char *chunk,*oldchunk;
char *package,*filename,*oldfile,*sourcename,*filekey,*md5andsize;
int r,hadold=0;
fi = gzopen(packages_file,"r");
if( !fi ) {
fprintf(stderr,"Unable to open file %s\n",packages_file);
return -1;
}
while( (chunk = chunk_read(fi))) {
if( binaries_parse_chunk(chunk,&package,&oldfile,&sourcename,&filename,&md5andsize) > 0) {
hadold = 0;
oldchunk = getpackage(pkgs,package);
if( oldchunk && (r=binaries_isnewer(chunk,oldchunk)) != 0 ) {
if( r < 0 ) {
fprintf(stderr,"Omitting %s because of parse errors.\n",package);
goto err;
}
/* old package will be obsoleted */
hadold=1;
free(oldchunk);
oldchunk = NULL;
}
if( oldchunk == NULL ) {
/* add package (or whatever action wants to do) */
filekey = calc_filekey(part,sourcename,filename);
if( !filekey )
goto err;
r = (action)(data,chunk,package,sourcename,oldfile,filename,filekey,md5andsize,hadold);
free(filekey);
if( (r < 0 && !force) || r< -1 )
goto err;
} else
free(oldchunk);
free(package);free(md5andsize);
free(oldfile);free(filename);free(sourcename);
} else {
fprintf(stderr,"Cannot parse chunk: '%s'!\n",chunk);
}
free(chunk);
}
gzclose(fi);
return 0;
err:
free(md5andsize);free(oldfile);free(package);
free(sourcename);free(filename);
gzclose(fi);
return -1;
}
#ifndef __MIRRORER_BINARIES_H
#define __MIRRORER_BINARIES_H
/* the type of a action for binaries_add */
typedef int binary_package_action(
/* the data supplied to binaries_add */
void *data,
/* the chunk to be added */
const char *chunk,
/* the package name */
const char *package,
/* the sourcename */
const char *sourcename,
/* the filename (and path relative to dists) found in the chunk */
const char *oldfile,
/* the calculated filename it should have (without directory) */
const char *filename,
/* with directory relative to the pool/-dir */
const char *filekey,
/* the expected md5sum and size */
const char *md5andsize,
/* the pkgs database had an entry of the same name already
(which was considered older) */
int hadold);
/* call action for each package in packages_file */
int binaries_add(
/* the database of already included packages */
DB *pkgs,
/* the part (i.e. "main","contrib","non-free") to be used for dirs */
const char *part,
/* the file to traverse */
const char *packages_file,
/* the action to take for each package to add */
binary_package_action action,
/* some data to pass to the action */
void *data);
#endif
#include <malloc.h>
#include <string.h>
#include <stdio.h>
#include <ctype.h>
#include <zlib.h>
#include <assert.h>
#include "chunks.h"
/* get the next chunk from file f */
char *chunk_read(gzFile f) {
char *buffer,*bhead;
int m,c,l;
m = 4096;
c = 0;
bhead = (buffer = (char*)malloc(m));
while( gzgets(f,bhead,m-1-c) ) {
c += (l = strlen(bhead));
if( *bhead == '\n' ) {
/* we do not want to include the final newline */
*bhead = 0; c--;
if( c == 0 ) {
bhead = buffer;
continue;
}
buffer = realloc(buffer,c+1);
return buffer;
}
while( bhead[l-1] != '\n' ) {
if( m-c < 100 ) {
m *= 2;
buffer = realloc(buffer,m);
if( !buffer )
return NULL;
}
bhead = buffer + c;
if( !gzgets(f,bhead,m-1-c)) {
buffer = realloc(buffer,c+1);
return buffer;
}
c += (l = strlen(bhead));
}
if( m-c < 100 ) {
m *= 2;
buffer = realloc(buffer,m);
if( !buffer )
return NULL;
}
bhead = buffer + c;
}
if( c == 0 ) {
free(buffer);
return NULL;
} else {
buffer = realloc(buffer,c+1);
return buffer;
}
}
/* point to a specified field in a chunk */
const char *chunk_getfield(const char *name,const char *chunk) {
int l;
if( !chunk)
return NULL;
l = strlen(name);
while( *chunk ) {
if(strncmp(name,chunk,l) == 0 && chunk[l] == ':' ) {
chunk += l+1;
return chunk;
}
while( *chunk != '\n' && *chunk != '\0' )
chunk++;
if( ! *chunk || *(++chunk) == '\n' )
return NULL;
}
return NULL;
}
/* strdup a field given by chunk_getfield */
char *chunk_dupvalue(const char *field) {
const char *h;
if( !field)
return NULL;
if( isspace(*field) )
field++;
h = field;
while( *h != '\n' && *h != '\0' )
h++;
return strndup(field,h-field);
}
/* strdup the following lines of a field */
char *chunk_dupextralines(const char *field) {