-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate_zip.sh
More file actions
executable file
·38 lines (30 loc) · 1.01 KB
/
create_zip.sh
File metadata and controls
executable file
·38 lines (30 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env bash
# Remove existing zip file, warning before deletion
if [ -e "autograder.zip" ]; then
echo "Warning: autograder.zip already exists. It will be replaced."
rm -f autograder.zip
fi
AUTOGRADER_FILES="src run_autograder setup.sh"
CONFIG_FILES="autograder.config.json replacement_files custom_setup.sh custom_run_autograder.sh required_files.txt"
AUTOGRADER_FOLDER=$(dirname -- "$( readlink -f -- "$0"; )";)
CONFIG_FOLDER=$(dirname "$AUTOGRADER_FOLDER")
# Create a temporary directory for zip operations
TEMP_DIR=$(mktemp -d)
# Copy autograder files
for file in $AUTOGRADER_FILES; do
if [ -e "$AUTOGRADER_FOLDER/$file" ]; then
cp -R "$AUTOGRADER_FOLDER/$file" "$TEMP_DIR/"
fi
done
# Copy config files
for file in $CONFIG_FILES; do
if [ -e "$CONFIG_FOLDER/$file" ]; then
cp -R "$CONFIG_FOLDER/$file" "$TEMP_DIR/"
fi
done
# Create zip from the temporary directory
DST_DIR=$(pwd)
pushd "$TEMP_DIR"
zip -r "$DST_DIR/autograder.zip" * -x "*.DS_Store"
popd
rm -rf "$TEMP_DIR"