Le lundi 28 février 2011 19:33:57 Benoît Burnichon, vous avez écrit :
> 
> How could I tell ipkg not to overwrite the already present configuration
> files? I know there is an option when building ipkgs to indicate that
> files are config ones (conffiles in CONTROL directory of the ipk). And how
> to indicate ptxdist that there are some prerm, postrm, preinst and
> postinst scripts?
> 
> 
> Thanks for your help.
> 
> Ben

To add files to conffile, we created new make macros (ptxdist 1.x):

#
# install_control
#
# Installs a file in the control section of the package
# 
#
# $1: packet label
# $2: source
# $3: destination file, either preinst, postinst, prerm  or postrm
#
install_control =                                                               
\
        PKG=$(strip $(1));                                                      
\
        SRC=$(strip $(2));                                                      
\
        DST=$(strip $(3));                                                      
\
        echo "install_control:";                                                
\
        echo "  src=$$SRC";                                                     
\
        echo "  dst=$$DST";                                                     
\
        if [ "$$DST" != "preinst"  -a  "$$DST" != "postinst"  ]; then           
\
                if [ "$$DST" != "prerm"  -a  "$$DST" != "postrm"  ]; then       
\
                echo "Error: install_control failed : $$DST not valid !";       
\
                exit 1;                                                         
\
                fi;                                                             
\
        fi;                                                                     
\
        chmod u+x $$SRC;                                                        
\
        $(INSTALL) -m 0750 $$SRC $(IMAGEDIR)/$$PKG/ipkg/CONTROL/$$DST;          
\
        if [ $$? -ne 0 ]; then                                                  
\
                echo "Error: install_control failed!";                          
\
                exit 1;                                                         
\
        fi;                                                                     
\
        echo "done";    

#
# install_conffile
#
# Flags a file as a configuration file in package
# This enables updating  a packet without overwriting existing
# configuration
# 
#
# $1: packet label
# $2: dest
#
install_conffile =                                                              
\
        PKG=$(strip $(1));                                                      
\
        DST=$(strip $(2));                                                      
\
        echo "install_conffile:";                                               
\
        echo "  dst=$$DST";                                                     
\
        grep  $$DST $(IMAGEDIR)/$$PKG/ipkg/CONTROL/conffiles ||                 
\
        echo $$DST >> $(IMAGEDIR)/$$PKG/ipkg/CONTROL/conffiles;                 
\
        if [ $$? -ne 0 ]; then                                                  
\
                echo "Error: install_conffile failed : " $$?;                   
\
                exit 1;                                                         
\
        fi;                                                                     
\
        echo "done";    

The point is that updating a packet basically boils down to uninstalling the 
old one and installing the new one. In this case, the modified conf files are 
not preserved.

We did not face the issue of preserving modified files, as the first upgrade 
we needed to do was to introduce the ability to modify some conf files which 
were static before.

In your case, I would try to insert new fake packets depending on the main 
packets with preinst rules that copy the conf files in some safe place. Then 
when upgrading, the new main packages are updated and their conf files 
overwritten, but just after the new fake packets'postinst rule copies them 
back with their original content. Once the files are correctly tagged as 
conffiles the fake packet is no longer needed and can be discarded

Hope this helps,

Jean-Noël Avila              

-- 
ptxdist mailing list
[email protected]

Reply via email to