-
Notifications
You must be signed in to change notification settings - Fork 1
/
build_addon.sh
executable file
·130 lines (108 loc) · 3.98 KB
/
build_addon.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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#!/bin/bash
DIR=`pwd`
openelec_src_path=""
selected_cores=""
project=""
arch=""
echo "=================================="
echo "RetroArch/Lakka addon for OpenELEC"
echo "=================================="
echo
echo "This tool will walk you through the process of building a custom RetroArch/Lakka addon for OpenELEC."
echo
echo "First, please enter the path to your local OpenELEC source."
while [ -z "$openelec_src_path" ]; do
echo -n "OpenELEC source path: "
read openelec_src_path
if [ ! -d "$openelec_src_path" ]; then
echo "$openelec_src_path is an invalid directory!"
openelec_src_path=""
fi
done
echo "Cleaning $openelec_src_path..."
cd $openelec_src_path
git clean -df
rm -rf tools/mkpkg/*.git
rm -rf tools/mkpkg/*.xz
cd $DIR
# list of cores
valid_cores=""
real_cores=""
for i in `ls -1 packages/emulator`; do
if [[ "$i" != "RetroArch" && "$i" != "retroarch-joypad-autoconfig" && "$i" != "retroarch-assets" && "$i" != "libcg" && "$i" != "common-shaders" && "$i" != "core-info" ]]; then
real_cores="$real_cores $i"
fi
done
valid_cores="all $real_cores"
valid_core_selection="n"
echo "Next, which emulator cores would you like to build? Type 'all' for all."
echo "Valid cores: $real_cores"
while [[ $valid_core_selection != "y" ]]; do
echo -n "Selected cores? "
read selected_cores
for i in $selected_cores; do
if [[ $valid_cores != *$i* ]]; then
valid_core_selection="n"
break
fi
valid_core_selection="y"
done
done
# project/architecture
echo "What target would you like to build for? Valid options are: ION, Fusion, Intel, Ultra, Generic, ATV"
valid_projects="ION Fusion Intel Ultra Generic ATV"
project="foobar"
while [[ $valid_projects != *$project* ]]; do
echo -n "Target project? "
read project
done
echo "What architecture would you like to build for? Valid options are: i386, x86_64"
valid_archs="i386 x86_64"
arch="foobar"
while [[ $valid_archs != *$arch* ]]; do
echo -n "Target arch? "
read arch
done
# apply options to in files
echo "Arch: $arch"
echo "Project: $project"
echo "Cores: $selected_cores"
echo "OE Source: $openelec_src_path"
[ "$selected_cores" = "all" ] && selected_cores="$real_cores"
echo "CFG_CORES=\"$selected_cores\"" > packages/emulator/RetroArch/config
# copy files to OpenELEC source
cp -R tools/mkpkg/* $openelec_src_path/tools/mkpkg
mkdir -p $openelec_src_path/packages/emulator
cp -R packages/emulator/* $openelec_src_path/packages/emulator
mkdir -p $openelec_src_path/packages/emulator/RetroArch/icon
cp icon/icon.png $openelec_src_path/packages/emulator/RetroArch/icon
cp changelog.txt $openelec_src_path/packages/emulator/RetroArch
mkdir -p $openelec_src_path/packages/emulator/RetroArch/source
cp -R source/* $openelec_src_path/packages/emulator/RetroArch/source
. $openelec_src_path/config/version
# make packages
cd $openelec_src_path/tools/mkpkg
packages="$selected_cores RetroArch retroarch-assets retroarch-joypad-autoconfig common-shaders core-info"
if [ ! -d $openelec_src_path/sources/ ]; then
mkdir $openelec_src_path/sources/
fi
export LAKKA_MIRROR="http://sources.openelec.tv/$OPENELEC_VERSION"
for i in $packages; do
if [ ! -d $openelec_src_path/sources/$i/ ]; then
mkdir $openelec_src_path/sources/$i/
echo "Building $i package..."
./mkpkg_$i > /dev/null 2&>1
package_file=`ls -1 $i*.tar.xz`
package_ver=`echo $package_file | rev | cut -d - -f 1 | rev | cut -d . -f 1`
mv $package_file $openelec_src_path/sources/$i/
echo "Generating md5 and url files for $i..."
md5sum $openelec_src_path/sources/$i/$package_file > $openelec_src_path/sources/$i/$package_file.md5
echo "$LAKKA_MIRROR/$package_file" > $openelec_src_path/sources/$i/$package_file.url
echo "Setting PKG_VERSION in $i package.mk..."
sed -i -e "s/PKG_VERSION=\".*\"/PKG_VERSION=\"$package_ver\"/" $openelec_src_path/packages/emulator/$i/package.mk
fi
done
cd $openelec_src_path
# build addon
PROJECT=$project ARCH=$arch ./scripts/create_addon RetroArch
exit 0