Skip to content
This repository has been archived by the owner on Apr 16, 2019. It is now read-only.

Build fixes #1

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
language: c
compiler:
- gcc
# - clang
before_install:
- sudo apt-get update -qq
- sudo apt-get install -qq libcurl4-openssl-dev
script: cd c && ./doit.sh && ./testit.sh

notifications:
irc: "irc.freenode.net#range"
email: false
2 changes: 1 addition & 1 deletion c/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ zsyncmake_SOURCES = make.c makegz.c makegz.h format_string.h
zsyncmake_LDADD = libzsync/libzsync.a librcksum/librcksum.a zlib/libinflate.a zlib/libdeflate.a -lm

zsync_SOURCES = client.c http.c http.h url.c url.h progress.c progress.h base64.c format_string.h zsglobal.h
zsync_LDADD = libzsync/libzsync.a librcksum/librcksum.a zlib/libinflate.a $(LIBOBJS)
zsync_LDADD = libzsync/libzsync.a librcksum/librcksum.a zlib/libinflate.a -lcurl $(LIBOBJS)

EXTRA_zsync_SOURCES = getaddrinfo.h

Expand Down
2 changes: 1 addition & 1 deletion c/configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ case $host_os in
esac
AM_CONDITIONAL([MINGW32], test "x$host_os_mingw32" = "xyes")

X_C_COMPILE_FLAGS($ZS_CFLAGS -g -Wall -Wwrite-strings -Winline -Wextra -Winline -Wmissing-noreturn -Wredundant-decls -Wnested-externs -Wundef -Wbad-function-cast -Wcast-align -Wvolatile-register-var -ffast-math)
#X_C_COMPILE_FLAGS($ZS_CFLAGS -g -Wall -Wwrite-strings -Winline -Wextra -Winline -Wmissing-noreturn -Wredundant-decls -Wnested-externs -Wundef -Wbad-function-cast -Wcast-align -Wvolatile-register-var -ffast-math)

dnl --- output
AC_SUBST(ac_aux_dir)
Expand Down
18 changes: 18 additions & 0 deletions c/doit.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/sh

set -e
set -x
export DESTDIR=$HOME/prefix

rm -rf $DESTDIR || exit 1
make clean || true # ignore failures

aclocal || exit 1
#libtoolize --force || exit 1
autoheader || exit 1
automake -a || exit 1
autoconf || exit 1
./configure --prefix=/usr || exit 1
make || exit 1
make install || exit 1

5 changes: 5 additions & 0 deletions c/index.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
default:
name: zsync
version: 0.6.2
summary: 'http based rsync style file fetching with precomputed checksums'
sourcedir: .
44 changes: 21 additions & 23 deletions c/make.c
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@ int main(int argc, char **argv) {

{ /* Options parsing */
int opt;
while ((opt = getopt(argc, argv, "b:Ceo:f:u:U:vVzZ")) != -1) {
while ((opt = getopt(argc, argv, "b:Ceo:f:s:u:U:vVzZ")) != -1) {
switch (opt) {
case 'e':
do_exact = 1;
Expand Down Expand Up @@ -637,31 +637,29 @@ int main(int argc, char **argv) {
case 'Z':
no_look_inside = 1;
break;
}
}

/* Open data to create .zsync for - either it's a supplied filename, or stdin */
if (optind == argc - 1) {
infname = strdup(argv[optind]);
instream = fopen(infname, "rb");
if (!instream) {
perror("open");
exit(2);
}

{ /* Get mtime if available */
struct stat st;
if (fstat(fileno(instream), &st) == 0) {
mtime = st.st_mtime;
case 's':
/* Open data to create .zsync its supplied filename */
infname = strdup(optarg);
instream = fopen(infname, "rb");
if (!instream) {
perror("open");
exit(2);
}
{
struct stat st;
if (fstat(fileno(instream), &st) == 0) {
mtime = st.st_mtime;
}
}
if (!fname)
fname = basename(optarg);
break;
}

/* Use supplied filename as the target filename */
if (!fname)
fname = basename(argv[optind]);
}
else {
instream = stdin;

if (!instream) {
printf("ERR: -s infile required\n");
exit(2);
}
}

Expand Down
9 changes: 9 additions & 0 deletions c/scripts/build
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/sh

aclocal
autoheader
automake --add-missing
autoconf
./configure --prefix=/usr
make install LDFLAGS='-lcurl' DESTDIR="$DESTDIR"

39 changes: 39 additions & 0 deletions c/t/zsyncmake.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/usr/bin/perl -w

use warnings;
use strict;

use Test::More qw(no_plan);
use FindBin;
use File::Temp;

my $build_root = $ENV{DESTDIR} || "$ENV{HOME}/prefix";
my $zsm = "$build_root/usr/bin/zsyncmake";

my ($small_data_file_fh, $small_data_file) = File::Temp::tempfile();
my ($medium_data_file_fh, $medium_data_file) = File::Temp::tempfile();

print $small_data_file_fh "hello world\n" x 8;
close $small_data_file_fh;

for (1..1024) {
print $medium_data_file_fh "hello world\n" x 8;
}
close $medium_data_file_fh;

is(`cat $small_data_file|md5sum`,
"c206bfeb596f75167b404119249403e1 -\n",
"test that our small setup file was generated properly",);

like( `$zsm -s $small_data_file -o /dev/stdout -u relative/url/path`,
qr!
Filename:\s\w+\s+
MTime:\s\w+, \s \d+ \s \w+ \s \d+ \s [0-9:]+ \s \+\d+ \s+
Blocksize: \s 2048 \s+
Length: \s 96 \s+
Hash-Lengths: \s 1,2,4 \s+
URL: \s relative/url/path \s+
SHA-1: \s \w{40}
!mx,
"zsyncmake small_data_file");

4 changes: 4 additions & 0 deletions c/testit.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh

cd t
for i in *.t; do ./$i || exit 1; done