[CMake] Data dir

Bo Thorsen bo at askmonty.org
Fri Jun 25 08:21:52 EDT 2010


Just to follow my own advice and give the answer to the question I sent 
here.

The basic problem is this: Can you add a file to the installer that 
isn't uninstalled?

Answer: No, this is impossible. Anything short of patching the CMake 
sourcecode is going to fail. Not even copying the NSIS template to the 
local directory and modify it is going to work.

The workaround I use now installs my datafiles to a clean directory, 
which isn't used by MariaDB on runtime. It then checks if there are 
already database files in the target dir. If they are there, it gives a 
messagebox saying it's reusing the database files. If no files are there 
(or at least not the one file I check), the clean files are copied into 
position.

On uninstall, I just put up a messagebox saying the database files are 
not deleted. I plan to investigate if it's possible to add pages to the 
uninstaller and ask the user if he/she wants to delete the files or not. 
But in the meantime this isn't an unreasonable workaround.

To do this, I have removed my data component, so the clean database 
files are now in the unspecified group, which means the user can't avoid 
them. And then I added these lines to my CMakeLists.txt:

# Handle the database files
FILE(GLOB datafiles "${CMAKE_CURRENT_SOURCE_DIR}/win/data/mysql/*")
INSTALL(FILES ${datafiles} DESTINATION data/clean/mysql)
INSTALL(FILES win/data/maria_log.00000001 win/data/maria_log_control 
DESTINATION data/clean)
INSTALL(DIRECTORY win/data/test DESTINATION data/clean)
SET(CPACK_NSIS_EXTRA_INSTALL_COMMANDS "${CPACK_NSIS_EXTRA_INSTALL_COMMANDS}
   IfFileExists '$INSTDIR\\\\data\\\\mysql\\\\db.frm' 0 CopyDatabaseFiles
     MessageBox MB_OK 'There are already database files present in the 
data directory. Clean database files are not written to the directory'
     GoTo EndCopyDatabaseFiles
   CopyDatabaseFiles:
     CopyFiles '$INSTDIR\\\\data\\\\clean\\\\*' '$INSTDIR\\\\data'
   EndCopyDatabaseFiles:")
SET(CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS 
"${CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS}
   MessageBox MB_OK 'This will not delete the database files in 
$INSTDIR\\\\data'")

Another solution I'm considering is to write a CMake patch that can do 
this in a prettier way, but that's going to be a while from now, if ever.

Bo.

Den 09-06-2010 14:48, Bo Thorsen skrev:
> Den 09-06-2010 14:25, Yegor Yefremov skrev:
>>> I am working on a CPack/NSIS based installer for MariaDB. The early
>>> parts were really easy to do, but now it becomes more complicated.
>>>
>>> First problem: I have a set of files with the bootstrap MySQL/MariaDB
>>> database files. Some users might not want to install these, if they are
>>> installing to a set of database files that are already there.
>>
>> Have you already looked at this article:
>> http://www.cmake.org/Wiki/CMake:Component_Install_With_CPack
>
> Yes, I already implemented this, and it works very well. However, I
> think it's too little. I guess I'm not really certain how the installer
> should actually work, which is one of the reasons I'm fishing for an
> answer.
>
> It think anything less than a page where the user has to answer this
> manually will be too subtle for the data dir. I'm happy with this on
> stuff like installing header files for installation.
>
> The reason I'm worried is if a user had a previous installation with the
> datafiles in there, and installs in the same directory, it might be easy
> to overwrite the files.
>
> I think a separate page with three options to choose from
>
> - install new files
> - use existing files in the installation directory
> - use data files in a separate location
>
> Or something like this. If someone already did something this advanced
> with CPack, it would be great to hear about it. I suspect that I'll have
> to work directly in the nsis module file to implement this.
>
> Anyway, components doesn't answer the uninstall problem.
>
> Bo Thorsen.
> Monty Program AB.
>



Bo Thorsen.
Monty Program AB.

-- 

MariaDB: MySQL replacement
Community developed. Feature enhanced. Backward compatible.


More information about the CMake mailing list