-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathdist.sh
executable file
·100 lines (87 loc) · 3.05 KB
/
dist.sh
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#!/bin/bash
SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )"
DATE="$( date '+%Y%m%d%H%S' )"
DIST_DIR=$SCRIPTPATH/dist
LAYOUT_DIR=$SCRIPTPATH/res/layout/
BOOT_DOL_SRC=$SCRIPTPATH/boot.dol
BOOT_DOL_DEST=$DIST_DIR/apps/wii7800
BOOT_ELF_SRC=$SCRIPTPATH/boot.elf
BOOT_ELF_DEST=$DIST_DIR
META_FILE=$DIST_DIR/apps/wii7800/meta.xml
EMUCOMMON_DIR=$SCRIPTPATH/wii-emucommon
#
# Function that is invoked when the script fails.
#
# $1 - The message to display prior to exiting.
#
function fail() {
echo $1
echo "Exiting."
exit 1
}
#
# Build in directory specified (if applicable)
#
if [ ! -z $1 ]; then
BUILD_DIR=$1
echo "Building in: $BUILD_DIR..."
rm -rf $BUILD_DIR \
|| { fail 'Unable to delete build directory.'; }
cp -R $SCRIPTPATH $BUILD_DIR \
|| { fail 'Unable to copy files to build directory.'; }
find $BUILD_DIR -type f \
\( -name "*.o" -or -name "*.a" -or -name "*.dol" -or -name "*.elf" \) \
-exec rm {} + \
|| { fail 'Unable to delete previous build output files.'; }
$BUILD_DIR/dist.sh \
|| { fail 'Error running dist script.'; }
rm -rf $DIST_DIR \
|| { fail 'Unable to remove dist directory.'; }
cp -R $BUILD_DIR/dist $DIST_DIR \
|| { fail 'Unable to copy files to final dist directory.'; }
exit 0
fi
# Build wii-emucommon
echo "Building wii-emucommon..."
$EMUCOMMON_DIR/dist.sh || { fail 'Error building wii-emucommon.'; }
# Change to script directory
echo "Changing to script directory..."
cd $SCRIPTPATH || { fail 'Error changing to script directory.'; }
# Build Wii7800
echo "Building Wii7800..."
make || { fail 'Error building Wii7800.'; }
# Clear dist directory
if [ -d $DIST_DIR ]; then
echo "Clearing dist directory..."
rm -rf $DIST_DIR || { fail 'Error clearing dist directory.'; }
fi
# Copy layout
echo "Copy layout..."
cp -R $LAYOUT_DIR $DIST_DIR || { fail 'Error copying layout.'; }
# Remove .gitignore
echo "Cleaning layout..."
find $DIST_DIR -name .gitignore -type f -delete \
|| { fail 'Error cleaning layout.'; }
# Copy boot files
echo "Copying boot files..."
cp $BOOT_DOL_SRC $BOOT_DOL_DEST || { fail 'Error copying boot.dol.'; }
# Update date in meta file
echo "Setting date in meta file..."
sed -i "s,000000000000,$DATE,g" $META_FILE \
|| { fail 'Error setting date in meta file.'; }
# Update version in meta-file (if SNAPSHOT)
echo "Updating version in meta file..."
sed -i "s,-SNAPSHOT,-SNAPSHOT-$DATE,g" $META_FILE \
|| { fail 'Error setting version in meta file.'; }
# Create the distribution (zip)
echo "Creating distribution..."
VERSION=$( sed -ne "s/.*version>\(.*\)<\/version.*/\1/p" $META_FILE )
VERSION_NO_DOTS="${VERSION//./_}"
DIST_FILE=wii7800-$VERSION_NO_DOTS.zip
cd $DIST_DIR || { fail 'Error changing to distribution directory.'; }
zip -r $DIST_FILE . || { fail 'Error creating zip file.'; }
rm -rf $DIST_DIR/wii7800 \
|| { fail 'Error deleting wii7800 directory in dist.'; }
rm -rf $DIST_DIR/apps \
|| { fail 'Error deleting apps directory in dist.'; }
cp $BOOT_ELF_SRC $BOOT_ELF_DEST || { fail 'Error copying boot.elf.'; }