2

OK, I guess this is weird.
I have a small stage.sh script very simply has a bunch of commands:

if [ "$(whoami)" == 'David' ]; then
    rsync -a --delete-excluded --exclude-from=.rsyncrc $(pwd) ~/Sites/local-testing-0/modules/
    rsync -a --delete-excluded --exclude-from=.rsyncrc $(pwd) ~/Sites/local-testing-1/modules/
    rsync -a --delete-excluded --exclude-from=.rsyncrc $(pwd) ~/Sites/local-testing-7/modules/
    rsync -a --delete-excluded --exclude-from=.rsyncrc $(pwd) ~/Sites/local-testing-2/modules/
    echo "Checked out for David"
fi

And there are also other cases according to the current logged-in user. Note that the source is the current directory (see the $(pwd)). I want to add a case that takes the current directory and makes a zipped folder out it. By zipped folder I mean no tarbomb, and it must be in zip format. I'd want to take the output of the rsync transfer, because it already filters stuff. I tried using named pipes. I could also use the file .rsyncrc for exclusions in the tar/zipping process. It reads like this:

# Meta
- stage.sh
- .rsyncrc

# Repo itself
- .git
- .gitignore

# Distribution Packages
- dist/

# Other files
- */.DS_Store

So if I could just use this file for exclusion in the zipping process, than it would be great too. I didn't really test this, but I'm not sure it's possible. The output should be placed in ./dist/, which is excluded from the rsync/zipping process.

Bonus points if the name of the output zip filename had a version number -suffix, taken from inside the file that has the same name of the folder with ".php" appended. The line with the version number is always like this: $this->version = '0.0.1';

1 Answer 1

0

I came up with this build.sh script:

foldername=$(dirname $(pwd))
projname=$(basename $(pwd))
rsync -a --exclude-from=.rsyncrc $(pwd) $TMPDIR
cd $TMPDIR
zip -rq $foldername/$projname/dist/$projname-latest.zip $projname
cd $foldername/$projname

It resides in the root folder, so that whenever I want to package in zip the whole project, I run source build.sh and there it goes, in my dist/ folder as projectname-latest.zip

2
  • $TMPDIR is available on OS X, I don't know if it's available on other OSes
    – mcdado
    Apr 16, 2015 at 9:45
  • It is not a default environment variable, no, but it is widely used in UNIX systems. Though the POSIX standardized version is TMPDIR
    – remmy
    Apr 16, 2015 at 11:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .