Scripting operations
After reading the recent blog Dissecting Ep6 Transport Packages - to deal with Ep5 to Ep6 migration quirks by Viswanath Naidu, I saw that the operations there should be easy to script.
I decided to make a couple of bash scripts which will run on the linux and unix platform. For those of you running windows I recommend that you install cygwin which is "a Linux-like environment for Windows" and allows you to run bash scripts under windows (this is how they were tested).
I didn't have a transport from EP5 or EP6 available, but Viswanath description of the transports file structure ought to be sufficient.
The unpackEPA script
The only complex operation in unpacking the transport file, is that all .ept files in the EPA sub-folder should be unzipped after the transport file has been unzipped.
The scripts is as follows:
#!/bin/sh
#Print usage if parameter count is wrong
if
then
echo "Usage: $0 mytransportpackage.epa" ;
exit 1
fi
TRANSPORT_FILE=$1
#Only do the action if this file actually exist
if
then
echo "Processing transport file $TRANSPORT_FILE"
#Unzip to temporary directory
unzip -q -d $TRANSPORT_FILE.temp $TRANSPORT_FILE
cd $TRANSPORT_FILE.temp/EPT
#For all ept files in the current folder
#1. Unzip into folder The script will move the EPA transport file to a new file with postfix .org since the unpacked folder will have the same name as the orignal EPA transport file.
The packEPA script
The only complex operation in packing the transport file, is that you have to zip all .ept files in the EPA sub-folder before you pack the transport file.
The scripts is as follows:
#/bin/sh
#Print usage if parameter count is wrong
if
then
echo "Usage: $0 mytransportpackage.epa" ;
echo " where the mytransportpackage.epa is a directory"
exit 1
fi
TRANSPORT_DIR=$1
#Only do the action if the inparameter is a directory
if
then
echo "Creating transport file from directory $TRANSPORT_DIR"
cd $TRANSPORT_DIR/EPT
for file in `ls -d *.ept` ;
do echo "Processing EPT file $file" ;
cd $file
zip -q -r $file.zip *
mv $file.zip ../
cd ..
rm -rf $file;
mv $file.zip $file ;
done;
cd ..
echo "Processing transport directory $TRANSPORT_DIR"
#Zip the EPA file
zip -q -r $TRANSPORT_DIR.zip *
mv $TRANSPORT_DIR.zip ../
cd ..
#Since we can't have two files with the same name we delete the
#transport directory
rm -rf $TRANSPORT_DIR;
mv $TRANSPORT_DIR.zip $TRANSPORT_DIR;
else
echo "File $TRANSPORT_DIR does not exist or is not a directory" ;
exit 1
fi
Please note that this script deletes the directory which contained the .epa file contents.
Summary
We have shown two simple bash scripts which let you unpack a transport file, do some work on it and then pack it back together again.