Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have created a rpm package.The part of .spec file is below

%install    
mkdir -p ${RPM_BUILD_ROOT}/etc/xyz    
cp -rf %{BDIR}/console ${RPM_BUILD_ROOT}/etc/xyz

%files    
/etc/xyz/console

So XYZ package copies console directory to /etc/xyz directory. console dir also contains some other dir.

Installation works perfectly fine but when I remove package rpm doesn't remove files and directory under /etc/xyz/console dir.

So on re-installing rpm package it says files are getting conflict.

How do we clean all files under dir?

Updates:

Directory structure:

console-
   -dashboard.html
   -index.html
   -login.html
   -logout.html

   -cgi-bin
   -cgi-bin/authenticate.py
   -cgi-bin/login.py
   -cgi-bin/logout.py

   -media
   -media/script/application.js
   -media/script/bootstrap.js
   -media/script/jquery.min.js960.css
   -media/script/jquery.flot.js

   -media/css/bootstrap.css
   -media/css/style.css
   -media/css/jquery-ui-1.10.0.custom.css

   -media/image/logo.png
   -media/image/banner.png

spec file:

%install

[ "$(cd "${RPM_BUILD_ROOT}" && pwd)" != "/" ] && rm -rf ${RPM_BUILD_ROOT}
mkdir -p ${RPM_BUILD_ROOT}/etc/application/console/cgi-bin
mkdir -p ${RPM_BUILD_ROOT}/etc/application/console/media/css
mkdir -p ${RPM_BUILD_ROOT}/etc/application/console/media/css/images
mkdir -p ${RPM_BUILD_ROOT}/etc/application/console/media/script


cp %{BDIR}/console/dashboard.html ${RPM_BUILD_ROOT}/etc/application/console/dashboard.html
cp %{BDIR}/console/index.html ${RPM_BUILD_ROOT}/etc/application/console/index.html
cp %{BDIR}/console/login.html ${RPM_BUILD_ROOT}/etc/application/console/login.html
cp %{BDIR}/console/logout.html ${RPM_BUILD_ROOT}/etc/application/console/logout.html


cp %{BDIR}/console/cgi-bin/authenticate.py ${RPM_BUILD_ROOT}/etc/application/console/cgi-bin/authenticate.py
cp %{BDIR}/console/cgi-bin/login.py ${RPM_BUILD_ROOT}/etc/application/console/cgi-bin/login.py
cp %{BDIR}/console/cgi-bin/logout.py ${RPM_BUILD_ROOT}/etc/application/console/cgi-bin/logout.py

cp %{BDIR}/console/media/css/boostrap.css ${RPM_BUILD_ROOT}/etc/application/console/media/css/boostrap.css
cp %{BDIR}/console/media/css/style.css ${RPM_BUILD_ROOT}/etc/application/console/media/css/style.css
cp %{BDIR}/console/media/css/jquery-ui-1.10.0.custom.css ${RPM_BUILD_ROOT}/etc/application/console/media/css/jquery-ui-1.10.0.custom.css

cp %{BDIR}/console/media/css/images/logo.png ${RPM_BUILD_ROOT}/etc/application/console/media/css/images/logo.png
cp %{BDIR}/console/media/css/images/banner.png ${RPM_BUILD_ROOT}/etc/application/console/media/css/images/banner.png

%files
%defattr(0700, root, root)

/etc/application/console/dashboard.html
/etc/application/console/index.html
/etc/application/console/login.html
/etc/application/console/logout.html

/etc/application/console/cgi-bin/authenticate.py
/etc/application/console/cgi-bin/authenticate.pyc
/etc/application/console/cgi-bin/authenticate.pyo
/etc/application/console/cgi-bin/login.py
/etc/application/console/cgi-bin/login.pyc
/etc/application/console/cgi-bin/login.pyo
/etc/application/console/cgi-bin/logout.py
/etc/application/console/cgi-bin/logout.pyc
/etc/application/console/cgi-bin/logout.pyo

/etc/application/console/media/css/boostrap.css
/etc/application/console/media/css/style.css
/etc/application/console/media/css/jquery-ui-1.10.0.custom.css

/etc/application/console/media/css/images/logo.png
/etc/application/console/media/css/images/banner.png


%post
echo "post install executing"

%preun

%postun
echo "post remove executing"

rm -rf /etc/application/console/cgi-bin/authenticate.py*
rm -rf /etc/application/console/cgi-bin/login.py*
rm -rf /etc/application/console/cgi-bin/logout.py*

Errors:

file /etc/application/console/cgi-bin/login.py from install of applicationconsole-1.0-1.x86_64 conflicts with file from package application_console-1.0-1.x86_64
file /etc/application/console/cgi-bin/logout.py from install of applicationconsole-1.0-1.x86_64 conflicts with file from package application_console-1.0-1.x86_64
file /etc/application/console/cgi-bin/authenticate.py from install of applicationconsole-1.0-1.x86_64 conflicts with file from package application_console-1.0-1.x86_64

More verbose remove package output

    D:     erase: waitpid(31098) rc 31098 status 0 secs 0.179    
    D: fini      100700  1 (   0,   0)      4827 /etc/application/console/cgi-bin/login.py skip
    D: fini      100700  1 (   0,   0)      1195 /etc/application/console/cgi-bin/logout.py
skip
    D: fini      100700  1 (   0,   0)      7227 /etc/application/console/cgi-bin/authenticate.py skip
    D: fini      100700  1 (   0,   0)     33550 /etc/cachebox/console/application.html
    D: fini      100700  1 (   0,   0)     33550 /etc/cachebox/console/login.html
    D: fini      100700  1 (   0,   0)     33550 /etc/cachebox/console/logout.html

If you notice rpm package manager is skipping some files.Question is why?

share|improve this question
3  
Related: If you want to produce high quality RPM packages, you may find Fedora's RPM packaging guidelines useful. –  Michael Hampton Dec 18 '13 at 6:58

2 Answers 2

RPM will only remove files specified under "%files" directive, but only if there are no files under that directory. If you want "rpm -e" to remove all the files under "/etc/xyz/console" you will have to explicitly specify them under "%files"directive.

RPM does not delete anything it doesn't recognize on purpose as it is not safe, so you do not lose data just by removing the package, think about config files on the update for example. There is always an easy way to see what the RPM gets delivered with into the OS "rpm -qpl your_package.rpm" In your case there are 2 ways to have the files removed:

1) Specify them explicitly under "%files"

2) Or run "%postun" script where you remove your files and directories you intend.

Hope this helps.

share|improve this answer
    
but rpm -qpl your_package.rpm still enlists all files and directory under /etc/xyz/console.So this doesnt seems to be an issue.And as per rpm policy you can specify dir inside %file directive. –  Pilot Dec 17 '13 at 12:31
    
You surely can, but "rpm -e" remove only that directory if it doesn't have any files or other folders in it. –  Danila Ladner Dec 17 '13 at 12:34
    
So you could add "/etc/xyz/console/*" under %files –  Danila Ladner Dec 17 '13 at 12:37
    
seens quite conflicting with rpm policy.Even when I specified /etc/xyz/console/* It doesn't work –  Pilot Dec 17 '13 at 12:38
    
also rpm policy says For packages that create directories containing hundreds of files, it can be quite cumbersome creating a list that contains every file. To make this situation a bit easier, if the %files list contains a path to a directory, RPM will automatically package every file in that directory, as well as every file in each subdirectory. Shell-style globbing can also be used in the %files list. Here is reference rpm.org/max-rpm/s1-rpm-inside-files-list.htm –  Pilot Dec 17 '13 at 12:42
%files    
/etc/xyz/console

%preun
if [ "$1" = 0 ] ; then
   rm -rf /etc/xyz/console/*
fi
exit 0

http://www.rpm.org/max-rpm/s1-rpm-inside-files-list-directives.html

EDIT after chat

rpm -qa --last | head

showed some old crufty package

rpm -e old_crufty

win.

share|improve this answer
    
Off the top of my head, please double check. –  dmourati Dec 20 '13 at 9:09
    
This is not the issue...please re -read question..join in chat if you can.RPM package manager is skipping some files even if I explicitly specify then under %file section in spec file –  Pilot Dec 20 '13 at 9:12
    
Can you explain mystery of specifying directory inside %files section..Y RPM package manager doesnt remove files inside directory..? –  Pilot Dec 21 '13 at 6:25

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.