Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove empty directories only if they match exclude pattern. #323

Merged
merged 5 commits into from
Mar 21, 2013
Merged

Remove empty directories only if they match exclude pattern. #323

merged 5 commits into from
Mar 21, 2013

Conversation

r4um
Copy link
Contributor

@r4um r4um commented Dec 29, 2012

Current exclude logic even removes the directories left empty after "exclude match" but which
don't match the exclude pattern.

This for example makes empty directories maintained under subversion
to be excluded (via --exclude '**.svn*') even though intention is to include them.

@r4um
Copy link
Contributor Author

r4um commented Dec 29, 2012

spec fails though --exclude dirpath via fpm command doesn't work.

$ tree -a ~/tmp/test
/home/cpk/tmp/test
├── etc
│   └── my
│       └── zel
│           └── baz
└── var
    └── lib
        └── rt

6 directories, 1 file
$ rm test-0.1-1.x86_64.rpm; bundle exec fpm -s dir -t rpm -n test -v 0.1 --prefix /  --exclude 'etc' ~/tmp/test
/home/cpk/src/ruby/fpm/lib/fpm/version.rb:2: warning: already initialized constant VERSION
Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.Io8GNZ
Executing(%build): /bin/sh -e /var/tmp/rpm-tmp.OGwwGI
Executing(%install): /bin/sh -e /var/tmp/rpm-tmp.gulMzr
Processing files: test-0.1-1.x86_64
Wrote: /tmp/package-rpm-build20121230-26489-1s9hvuy/RPMS/x86_64/test-0.1-1.x86_64.rpm
Executing(%clean): /bin/sh -e /var/tmp/rpm-tmp.OlLCpT
Created rpm {"path":"test-0.1-1.x86_64.rpm"}

$ rpm -qlp test-0.1-1.x86_64.rpm
/home/cpk/tmp/test/etc/my/zel/baz
/home/cpk/tmp/test/var/lib/rt

$ rm test-0.1-1.x86_64.rpm; bundle exec fpm -s dir -t rpm -n test -v 0.1 --prefix /  --exclude 'etc/my' ~/tmp/test
/home/cpk/src/ruby/fpm/lib/fpm/version.rb:2: warning: already initialized constant VERSION
Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.tc1MBW
Executing(%build): /bin/sh -e /var/tmp/rpm-tmp.WOlVT5
Executing(%install): /bin/sh -e /var/tmp/rpm-tmp.xy2ycf
Processing files: test-0.1-1.x86_64
Wrote: /tmp/package-rpm-build20121230-26608-yezk3m/RPMS/x86_64/test-0.1-1.x86_64.rpm
Executing(%clean): /bin/sh -e /var/tmp/rpm-tmp.mzz0Qx
Created rpm {"path":"test-0.1-1.x86_64.rpm"}

$ rpm -qlp test-0.1-1.x86_64.rpm
/home/cpk/tmp/test/etc/my/zel/baz
/home/cpk/tmp/test/var/lib/rt

@r4um
Copy link
Contributor Author

r4um commented Dec 29, 2012

Looks like an internal check, working on fixing so it passes the spec.

@r4um
Copy link
Contributor Author

r4um commented Dec 29, 2012

I shouldn't be deleting example as per my change, something on following lines doesn't delete example

if File.fnmatch(pattern, d) or File.dirname(file_staging_path) == "#{d}"
   #delete dir

But again breaks the spec as user wanted to delete example/foo not example. Thoughts ?

@jordansissel
Copy link
Owner

Spec can be changed. I'm most interested in fpm behaving in "the most obvious manner by default"

How about writing up the spec changes as well?

@r4um
Copy link
Contributor Author

r4um commented Jan 11, 2013

Thanks, I'll work on the code/spec.

@r4um
Copy link
Contributor Author

r4um commented Jan 21, 2013

The changes are now complete.

  • Use the ruby Find module, this allows to match against all possible paths.
  • Use File.fnmatch only, since File.fnmatch('example/foo, 'example/foo') is true.

jordansissel added a commit that referenced this pull request Mar 21, 2013
Remove empty directories only if they match exclude pattern.
@jordansissel jordansissel merged commit f156fc5 into jordansissel:master Mar 21, 2013
@r4um r4um deleted the fix_exclude branch March 23, 2013 07:01
prof-milki pushed a commit to prof-milki/xpm that referenced this pull request Dec 18, 2014
Remove empty directories only if they match exclude pattern.
prof-milki pushed a commit to prof-milki/xpm that referenced this pull request Dec 27, 2014
Remove empty directories only if they match exclude pattern.
jordansissel added a commit that referenced this pull request Apr 24, 2015
Remove empty directories only if they match exclude pattern.
jordansissel added a commit that referenced this pull request Jun 20, 2016
Remove empty directories only if they match exclude pattern.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants