Properly build shared/static libxbps and utils.
xbps-fetch: added -v flag to see verbose messages in libfetch. --HG-- extra : convert_revision : xtraeme%40gmail.com-20091030111726-axf9paz2k01ntqzz
This commit is contained in:
34
lib/Makefile
34
lib/Makefile
@@ -1,27 +1,10 @@
|
||||
include ../vars.mk
|
||||
|
||||
INET6 ?= yes
|
||||
SSL ?= yes
|
||||
LIBS = -larchive -lprop
|
||||
|
||||
ifdef SSL
|
||||
CPPFLAGS += -DWITH_SSL
|
||||
LIBS += -lssl -lcrypto
|
||||
endif
|
||||
|
||||
ifdef INET6
|
||||
CPPFLAGS += -DINET6
|
||||
endif
|
||||
|
||||
ifdef DEBUG
|
||||
CPPFLAGS += -DDEBUG
|
||||
endif
|
||||
|
||||
LIBMAJOR = 0
|
||||
LIBMINOR = 0
|
||||
LIBMICRO = 0
|
||||
LIBXBPS_SHLIB = libxbps.so.$(LIBMAJOR).$(LIBMINOR).$(LIBMICRO)
|
||||
LIBXBPS_LDFLAGS = $(LIBS) -shared -Wl,-soname,libxbps.so.$(LIBMAJOR)
|
||||
LIBXBPS_LDFLAGS = -shared -Wl,-soname,libxbps.so.$(LIBMAJOR)
|
||||
|
||||
# libfetch
|
||||
OBJS = fetch/common.o fetch/fetch.o fetch/file.o fetch/ftp.o fetch/http.o
|
||||
@@ -32,14 +15,25 @@ OBJS += humanize_number.o orphans.o plist.o purge.o register.o remove.o
|
||||
OBJS += repository.o requiredby.o sha256.o sortdeps.o state.o
|
||||
OBJS += sync_remote_pkgidx.o unpack.o util.o
|
||||
|
||||
ifdef STATIC
|
||||
all: libfetch libxbps.a
|
||||
else
|
||||
LDFLAGS = -lprop -larchive
|
||||
ifdef WITH_SSL
|
||||
LDFLAGS += -lssl -lcrypto
|
||||
endif
|
||||
all: libfetch libxbps.so libxbps.a
|
||||
endif
|
||||
.PHONY: all
|
||||
|
||||
libfetch:
|
||||
$(MAKE) -C fetch
|
||||
|
||||
%.o: %.c
|
||||
$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -c $<
|
||||
|
||||
libxbps.so: $(OBJS)
|
||||
$(CC) $(LIBXBPS_LDFLAGS) $^ -o $(LIBXBPS_SHLIB)
|
||||
$(CC) $(LDFLAGS) $(LIBXBPS_LDFLAGS) $^ -o $(LIBXBPS_SHLIB)
|
||||
-ln -sf $(LIBXBPS_SHLIB) libxbps.so.$(LIBMAJOR)
|
||||
-ln -sf $(LIBXBPS_SHLIB) libxbps.so
|
||||
|
||||
@@ -50,7 +44,9 @@ libxbps.a: $(OBJS)
|
||||
.PHONY: install
|
||||
install: all
|
||||
install -d $(LIBDIR)
|
||||
ifdef STATIC
|
||||
install -m 644 libxbps.a $(LIBDIR)
|
||||
endif
|
||||
install -m 644 $(LIBXBPS_SHLIB) $(LIBDIR)
|
||||
cp -a libxbps.so $(LIBDIR)
|
||||
cp -a libxbps.so.$(LIBMAJOR) $(LIBDIR)
|
||||
|
@@ -171,7 +171,7 @@ xbps_fetch_error_string(void)
|
||||
}
|
||||
|
||||
int SYMEXPORT
|
||||
xbps_fetch_file(const char *uri, const char *outputdir)
|
||||
xbps_fetch_file(const char *uri, const char *outputdir, const char *flags)
|
||||
{
|
||||
struct stat st;
|
||||
struct xferstat xs;
|
||||
@@ -181,7 +181,7 @@ xbps_fetch_file(const char *uri, const char *outputdir)
|
||||
struct timeval tv[2];
|
||||
ssize_t bytes_read, bytes_written;
|
||||
off_t bytes_dld = -1;
|
||||
char buf[32768], *filename, *destfile = NULL;
|
||||
char buf[32768], *filename, *destfile = NULL, fetchflags[8];
|
||||
int fd = -1, rv = 0;
|
||||
bool restart = false;
|
||||
|
||||
@@ -221,7 +221,12 @@ xbps_fetch_file(const char *uri, const char *outputdir)
|
||||
goto out;
|
||||
|
||||
}
|
||||
if ((rv = fetchStat(url, &url_st, "i")) == -1) {
|
||||
memset(&fetchflags, 0, sizeof(fetchflags));
|
||||
if (flags != NULL)
|
||||
strcat(fetchflags, flags);
|
||||
strcat(fetchflags, "i");
|
||||
|
||||
if ((rv = fetchStat(url, &url_st, fetchflags)) == -1) {
|
||||
rv = fetchLastErrCode;
|
||||
goto out;
|
||||
}
|
||||
@@ -234,7 +239,7 @@ xbps_fetch_file(const char *uri, const char *outputdir)
|
||||
if (restart)
|
||||
url->offset = st.st_size;
|
||||
|
||||
fio = fetchXGet(url, &url_st, "i");
|
||||
fio = fetchXGet(url, &url_st, fetchflags);
|
||||
if (fio == NULL) {
|
||||
rv = fetchLastErrCode;
|
||||
goto out;
|
||||
|
@@ -4,6 +4,22 @@ include $(TOPDIR)/vars.mk
|
||||
CFLAGS += -Wno-unused-macros -Wno-conversion
|
||||
CPPFLAGS += -DFTP_COMBINE_CWDS -DNETBSD -I$(TOPDIR)/include
|
||||
|
||||
ifdef WITH_INET6
|
||||
CPPFLAGS += -DINET6
|
||||
endif
|
||||
|
||||
ifdef WITH_SSL
|
||||
CPPFLAGS += -DWITH_SSL
|
||||
endif
|
||||
|
||||
ifdef WITH_DEBUG
|
||||
CPPFLAGS += -DDEBUG
|
||||
endif
|
||||
|
||||
ifdef STATIC
|
||||
CFLAGS += -static
|
||||
endif
|
||||
|
||||
OBJS= fetch.o common.o ftp.o http.o file.o
|
||||
INCS= common.h
|
||||
GEN = ftperr.h httperr.h
|
||||
@@ -12,7 +28,7 @@ GEN = ftperr.h httperr.h
|
||||
all: $(OBJS)
|
||||
|
||||
%.o: %.c $(INCS) $(GEN)
|
||||
$(CC) $(CPPFLAGS) $(CFLAGS) -c $<
|
||||
$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -c $<
|
||||
|
||||
ftperr.h: ftp.errors
|
||||
./errlist.sh ftp_errlist FTP ftp.errors > $@
|
||||
|
@@ -123,7 +123,7 @@ static const uint32_t sha256_initial_hash_value[8] = {
|
||||
|
||||
/*** SHA-256: *********************************************************/
|
||||
int
|
||||
SHA256_Init(SHA256_CTX *context)
|
||||
XBPS_SHA256_Init(SHA256_CTX *context)
|
||||
{
|
||||
if (context == NULL)
|
||||
return 1;
|
||||
@@ -220,7 +220,7 @@ SHA256_Transform(SHA256_CTX *context, const uint32_t *data)
|
||||
|
||||
#else /* SHA2_UNROLL_TRANSFORM */
|
||||
|
||||
void
|
||||
static void
|
||||
SHA256_Transform(SHA256_CTX *context, const uint32_t *data)
|
||||
{
|
||||
uint32_t a, b, c, d, e, f, g, h, s0, s1;
|
||||
@@ -298,7 +298,7 @@ SHA256_Transform(SHA256_CTX *context, const uint32_t *data)
|
||||
#endif /* SHA2_UNROLL_TRANSFORM */
|
||||
|
||||
int
|
||||
SHA256_Update(SHA256_CTX *context, const uint8_t *data, size_t len)
|
||||
XBPS_SHA256_Update(SHA256_CTX *context, const uint8_t *data, size_t len)
|
||||
{
|
||||
unsigned int freespace, usedspace;
|
||||
|
||||
@@ -441,7 +441,7 @@ SHA256_Final(uint8_t digest[], SHA256_CTX *context)
|
||||
static const char sha2_hex_digits[] = "0123456789abcdef";
|
||||
|
||||
char *
|
||||
SHA256_End(SHA256_CTX *ctx, uint8_t *buffer)
|
||||
XBPS_SHA256_End(SHA256_CTX *ctx, uint8_t *buffer)
|
||||
{
|
||||
uint8_t digest[SHA256_DIGEST_LENGTH], *d = digest;
|
||||
uint8_t *ret;
|
||||
|
@@ -133,7 +133,7 @@ xbps_sync_repository_pkg_index(const char *uri)
|
||||
free(lrepodir);
|
||||
return errno;
|
||||
}
|
||||
rv = xbps_fetch_file(rpidx, lrepodir);
|
||||
rv = xbps_fetch_file(rpidx, lrepodir, NULL);
|
||||
|
||||
free(rpidx);
|
||||
free(lrepodir);
|
||||
|
@@ -53,10 +53,10 @@ xbps_get_file_hash(const char *file)
|
||||
if ((fd = open(file, O_RDONLY)) == -1)
|
||||
return NULL;
|
||||
|
||||
SHA256_Init(&ctx);
|
||||
XBPS_SHA256_Init(&ctx);
|
||||
while ((bytes = read(fd, buf, sizeof(buf))) > 0)
|
||||
SHA256_Update(&ctx, buf, (size_t)bytes);
|
||||
hash = strdup(SHA256_End(&ctx, digest));
|
||||
XBPS_SHA256_Update(&ctx, buf, (size_t)bytes);
|
||||
hash = strdup(XBPS_SHA256_End(&ctx, digest));
|
||||
(void)close(fd);
|
||||
|
||||
return hash;
|
||||
|
Reference in New Issue
Block a user