This is a static archive of our old Q&A Site. Please post any new questions and answers at ask.wireshark.org.

How to copy custom configuration files to staging directory for inclusion in installer?

0

I have generated the following nsi script, which gets it done - but is there a way to use an environment variable to the local appdata\wireshark folder for the mate file?

Section "Custom Deployed Preferences" SecCustomPrefs
;-------------------------------------------
SetShellVarContext current
!include "VPatchLib.nsh"
SetOutPath '$INSTDIR'
File "${STAGING_DIR}\quantel.mate"
File "${STAGING_DIR}\preferences"
IfFileExists $APPDATA\Wireshark\decode_as_entries 0 patchdecode
; Extract the old file under name 'updatefile.txt'
;File /oname=decode_as_entries decode_as_entries_old
; Update the file - it will be replaced with the new version
DetailPrint "Updating decode_as_entries using patch..."
!insertmacro VPatchFile "${STAGING_DIR}\decode_as.pat" "$APPDATA\Wireshark\decode_as_entries" "$APPDATA\Wireshark\temporaryfile.txt"
goto enddecode
patchdecode:
SetOutPath '$APPDATA\Wireshark'
File "${STAGING_DIR}\decode_as_entries"
enddecode:
SetShellVarContext all
SectionEnd

*Edit - vastly better - dumped the quentin.mate file, and a stub properties file (with some prefdefined filters) into the application directory, so Wireshark loads those first. I've got a small patch that will be applied to decode_as_entries if it exists, otherwise it gets replaced. What would be the recommended way to get the files into the staging directory for deployment, or is it better to keep this as a manual process? Thanks for your help,

asked 30 Jun '16, 22:24

Scott%20Harman's gravatar image

Scott Harman
46131319
accept rate: 50%

edited 01 Jul '16, 02:34

grahamb's gravatar image

grahamb ♦
19.8k330206

Your answer has been converted to a comment as that's how this site works. Please read the FAQ for more information.

(01 Jul '16, 01:26) Jaap ♦

Note I changed the title to better reflect what this question is actually asking.

(01 Jul '16, 02:34) grahamb ♦

One Answer:

1

Add a CMakeListsCustom.txt that adds a custom target with a copy command to copy your files from the source location to the staging dir. There's lots of examples of that in the top level CMakeLists.txt

answered 01 Jul '16, 02:33

grahamb's gravatar image

grahamb ♦
19.8k330206
accept rate: 22%

Hi @grahamb - can you give me a pointer on this please - I'm trying to add either a block or a command, and both are failing - Here's an example of what I've most recently tried which causes a crash:

#COMMAND (if not exist \"${DATAFILE_DIR}\\quantel.mate\" xcopy     "${CMAKE_SOURCE_DIR}/quantel.mate" "${DATAFILE_DIR}" /D /Y)
#COMMAND (xcopy "${CMAKE_SOURCE_DIR}/preferences" "${DATAFILE_DIR}" /D     /Y)
(06 Jul '16, 20:06) Scott Harman

Something like:

ADD_CUSTOM_TARGET(copy-quantel-files
    COMMAND  ${CMAKE_COMMAND} -E copy_if_different
        "${CMAKE_SOURCE_DIR}/quantel.mate"
        $<TARGET_FILE_DIR:wireshark>
)

Although some of those variable definitions might not be set up when your custom file is included.

(07 Jul '16, 04:58) grahamb ♦

Here's the values I've added to CMakeListsCustom.txt The necessary bit was ADD_DEPENDENCIES

ADD_CUSTOM_TARGET(copy-quantel-files ALL
    COMMAND  ${CMAKE_COMMAND} -E copy_if_different
        "${CMAKE_SOURCE_DIR}/quantel.mate"
        $<TARGET_FILE_DIR:wireshark>
)
ADD_DEPENDENCIES(copy-quantel-files wireshark)

I've got a bunch of patches and stock preferences in there for first run up.

(19 Jul '16, 21:54) Scott Harman