From 33940d2cde706cf6b061a0920e7b936d41edb0de Mon Sep 17 00:00:00 2001 From: Andreas Fankhauser hiddenalpha.ch Date: Tue, 23 Aug 2022 23:07:34 +0200 Subject: Cleanup - Fix version string while dockerbuild. - Use quotes in log msgs. - Add apt cleanup in debian build example. - Fix off-by-one error in summary log msg. - Allow to clone by tag within Dockerfile. - Add some missing LFs in err msgs. --- contrib/build-using-docker/Dockerfile | 4 ++-- contrib/build-using-docker/README.md | 6 +++--- src/bulk_ln/bulk_ln.c | 12 ++++++------ 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/contrib/build-using-docker/Dockerfile b/contrib/build-using-docker/Dockerfile index c56cacd..00c1132 100644 --- a/contrib/build-using-docker/Dockerfile +++ b/contrib/build-using-docker/Dockerfile @@ -2,7 +2,7 @@ ARG PARENT_IMAGE=alpine:3.16.0 FROM $PARENT_IMAGE -ARG GIT_TAG= +ARG GIT_TAG=master ARG CONFIGURE_OPTS= ARG PKGINIT=true ARG PKGADD="apk add" @@ -16,7 +16,7 @@ WORKDIR /work RUN true \ && $PKGINIT \ && $PKGADD $PKGS_TO_ADD \ - && git clone --depth 1 https://github.com/hiddenalpha/bulk-ln.git . \ + && git clone --depth 42 --branch "${GIT_TAG:?}" https://github.com/hiddenalpha/bulk-ln.git . \ && git config advice.detachedHead false \ && if test -n "$GIT_TAG"; then git checkout "$GIT_TAG"; fi \ && ./configure $CONFIGURE_OPTS \ diff --git a/contrib/build-using-docker/README.md b/contrib/build-using-docker/README.md index 35f7429..63b7182 100644 --- a/contrib/build-using-docker/README.md +++ b/contrib/build-using-docker/README.md @@ -24,7 +24,7 @@ curl -sSL http://git.hiddenalpha.ch/bulk-ln.git/plain/contrib/build-using-docker ## Grab distribution archive Most probably we wanna get the distribution archive. We can copy it out the -dockerimage to our host using: +dockerimage into our working dir on the host using: ```sh sudo docker run --rm -i "${IMG:?}" sh -c 'true && cd dist && tar c *' | tar x @@ -51,10 +51,10 @@ differently if you need to keep multiple images. curl -sSL http://git.hiddenalpha.ch/bulk-ln.git/plain/contrib/build-using-docker/Dockerfile | sudo docker build . -f - -t "${IMG:?}" \ --build-arg PARENT_IMAGE=debian:buster-20220622-slim \ --build-arg PKGS_TO_ADD="curl gcc git make libc-dev ca-certificates tar" \ - --build-arg PKGS_TO_DEL="curl gcc git make libc-dev ca-certificates" \ + --build-arg PKGS_TO_DEL="curl gcc git make libc-dev" \ --build-arg PKGINIT="apt update" \ --build-arg PKGADD="apt install -y --no-install-recommends" \ - --build-arg PKGDEL=true \ + --build-arg PKGDEL="apt purge -y" \ --build-arg PKGCLEAN="apt clean" ``` diff --git a/src/bulk_ln/bulk_ln.c b/src/bulk_ln/bulk_ln.c index 682c1aa..c03c2d9 100644 --- a/src/bulk_ln/bulk_ln.c +++ b/src/bulk_ln/bulk_ln.c @@ -191,7 +191,7 @@ static int mkdirs( char*path, BulkLn*bulkLn ){ /* Print if requested */ if( bulkLn->dryRun || bulkLn->isPrintEachMkdir ){ - printf("mkdir(%s)\n", path); + printf("mkdir(\"%s\")\n", path); } /* Create dir up to that found path */ @@ -204,7 +204,7 @@ static int mkdirs( char*path, BulkLn*bulkLn ){ if( errno == EEXIST ){ // Fine :) So just continue with the next one. }else{ - fprintf(stderr, "mkdir(%s): %s\n", path, strerror(errno)); + fprintf(stderr, "mkdir(\"%s\"): %s\n", path, strerror(errno)); err = -1; goto finally; } }else{ @@ -339,13 +339,13 @@ static int parseDataFileAsPairPerLine( BulkLn*bulkLn ){ char *srcPath = buf; char *tab = memchr(buf, DATA_FILE_FIELD_SEP_CHR, buf_len); if( tab == NULL ){ - fprintf(stderr, "Too few field separators (tab) in '%s' @ %lu", + fprintf(stderr, "Too few field separators (tab) in '%s' @ %lu\n", bulkLn->dataFilePath, lineNum); err = -1; goto finally; } char *unwantedTab = memchr(tab + 1, DATA_FILE_FIELD_SEP_CHR, tab + 1 - buf); if( unwantedTab != NULL ){ - fprintf(stderr, "Too many field separators (tab) in '%s' @ %lu", + fprintf(stderr, "Too many field separators (tab) in '%s' @ %lu\n", bulkLn->dataFilePath, lineNum); err = -1; goto finally; } @@ -375,7 +375,7 @@ static int parseDataFileAsPairPerLine( BulkLn*bulkLn ){ } if( bulkLn->isPrintStatus ){ - fprintf(stderr, "Parsed %lu records from '%s'\n", lineNum, bulkLn->dataFilePath); + fprintf(stderr, "Parsed %lu records from '%s'\n", lineNum - 1, bulkLn->dataFilePath); } err = 0; @@ -399,7 +399,7 @@ int bulk_ln_main( int argc, char**argv ){ }else{ bulkLn->dataFd = fopen(bulkLn->dataFilePath, "rb"); if( bulkLn->dataFd == NULL ){ - fprintf(stderr, "fopen(%s): %s", bulkLn->dataFilePath, strerror(errno)); + fprintf(stderr, "fopen(%s): %s\n", bulkLn->dataFilePath, strerror(errno)); err = -1; goto finally; } } -- cgit v1.1