Is there a way to change the packaging mode of an existing JCR package from replace to update? As far as I know the packaging mode cannot be set in the AEM Package Manager dialogs. What exactly would I have to do? Just change the filter.xml and repackage? Somehow, this didn't work for me. Am I missing something?
You'd have to change the filter.xml
as well as the .content.xml
in the definition
subfolder.
Here is a small batchscript that unpacks, changes the mode and repacks a package.
If you save it as modPkg, you cann call it with two params:
modPkg FILENAME FITLERMODE
where FILENAME
is the filename of the package and FILTERMODE
should be merge
, update
or replace
.
#!/bin/bash
filename=${1}
filterMode=${2}
echo "Extracting package."
jar xf $1
echo "Modifying filter.xml."
perl -pe 's|(root="[^\"]+")(( )*mode="[^\"]+"( )*)?(( )*(/)?>)|\1 mode="'"${filterMode}"'"\5|g' META-INF/vault/filter.xml > META-INF/vault/filter.xml.backup
rm -rf META-INF/vault/filter.xml
mv META-INF/vault/filter.xml.backup META-INF/vault/filter.xml
echo "Modifying .content.xml in definition-folder."
perl -pe 's|mode="[^\"]+"|mode="'"${filterMode}"'"|g' META-INF/vault/definition/.content.xml > META-INF/vault/definition/.content.xml.backup
rm -rf META-INF/vault/definition/.content.xml
mv META-INF/vault/definition/.content.xml.backup META-INF/vault/definition/.content.xml
echo "Repackaging."
jar -cfM ${filterMode}-${filename} META-INF jcr_root
echo "Deleting temp files."
rm -rf META-INF
rm -rf jcr_root
echo "Finished."
There might be more elegant ways to do the job, but it's easy enough.