Skip to content
This repository has been archived by the owner on Feb 24, 2020. It is now read-only.

copy-to-dir fails if the directory exists? #259

Open
andy-twosticks opened this issue Oct 3, 2016 · 2 comments
Open

copy-to-dir fails if the directory exists? #259

andy-twosticks opened this issue Oct 3, 2016 · 2 comments

Comments

@andy-twosticks
Copy link

In my build script I have:

acbuild --debug run -- /bin/busybox mkdir -p /usr/src/app/
acbuild --debug run -- /bin/busybox chmod 777 /usr/src/app/

And then later:

acbuild --debug copy-to-dir \
     ./deliverance ./lib/ ./projects/ \
     ./Gemfile ./Gemfile.lock ./rkt-build-setup \
     ./deliverance.yaml                         /usr/src/app

Which appears to cause the following error:

Copying ./deliverance ./lib/ ./projects/ ./Gemfile ./Gemfile.lock ./rkt-build-setup ./deliverance.yaml to /usr/src/app
copy-to-dir: mkdir /tmp/acbuild284630606/.acbuild/currentaci/rootfs/usr/src/app: file exists
script: exit status 1
exit status 1

Here's the whole build script:

#!/usr/bin/env bash
set -e
acbuildend () {
    export EXIT=$?;
    exit $EXIT;
}
rm -f deliverance.aci
rm -rf .acbuild
acbuild --debug begin ./library-alpine-3.4.aci
trap acbuildend EXIT

# Initial setup
acbuild --debug set-name jhallpr.com/deliverance
acbuild --debug label add version 0.1

# alpine and packages
acbuild --debug run -- apk update
acbuild --debug run -- apk add g++ musl-dev make build-base
acbuild --debug run -- apk add freetds freetds-dev unixodbc unixodbc-dev
acbuild --debug run -- apk add postgresql-dev
acbuild --debug run -- apk add ruby ruby-io-console ruby-dev
acbuild --debug run -- /bin/busybox rm -rf /var/cache/apk/*

# Deliverance user setup
acbuild --debug run -- /bin/busybox mkdir -p /usr/src/app/
acbuild --debug run -- /bin/busybox chmod 777 /usr/src/app/
acbuild --debug run -- /bin/busybox adduser -D -h /usr/src/app/ -s /bin/ash deliverance
acbuild --debug set-user deliverance

# Deliverance setup
acbuild --debug run -- gem install bundler --no-doc --no-ri
acbuild --debug copy ./freetds.conf /etc/freetds.conf

acbuild --debug copy-to-dir \
     ./deliverance ./lib/ ./projects/ \
     ./Gemfile ./Gemfile.lock ./rkt-build-setup \
     ./deliverance.yaml                         /usr/src/app

acbuild --debug run -- /bin/busybox chmod 777 /usr/src/app/deliverance
acbuild --debug run -- /bin/busybox su -c "/usr/src/app/rkt_build_setup" - deliverance

# Final write
acbuild --debug set-working-directory /usr/src/app/
acbuild --debug set-exec -- ruby deliverance -c deliverance.yaml
acbuild --debug write deliverance.aci
@sanmai-NL
Copy link
Contributor

@andy-twosticks: what behavior do you desire and for what reason? I think I can follow what you mean, but let's make it explicit in order arrive at a solution.

@andy-twosticks
Copy link
Author

Oof, that was eight months ago. I would have been perfectly happy with any behaviour that didn't give me an error?

Re-reading the above, and from what I remember, there was no existing file to overwrite, so the error was entirely spurious. /usr/src/app was a directory, not a file. acbuild should simply have added the given files and directories to it without complaint --- or, if there is some problem I am missing in my script, it should have given an error message that explained the problem.

By analogy if I

mkdir foo
cp -R /some/stuff/ foo/

Then I don't get an error because directory foo exists?

It looks like I was creating the directory beforehand so that I could create a user that had it as a home directory. But I'm not sure. It was a while ago.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants