-
Notifications
You must be signed in to change notification settings - Fork 10
/
popcorn-build
executable file
·160 lines (141 loc) · 5.28 KB
/
popcorn-build
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
#!/bin/bash
# Script author: MrVaykadji http://askubuntu.com/users/176689/mrvaykadji
# Changes made by Andrew <[email protected]>:
# - use the NodeJS PPA to avoid build failure with grunt-cli
# - use the Popcorn Time icon
# - added check for apt, dpkg, etc.
# - added some checks when creating symbolic links
# - added video playback work-around for Ubuntu 32bit
# - latest GIT requires ruby-compass
# - build app CSS with ruby compass and place it in the correct folder
# - it's no longer needed to replace the package.json file
# - new way of selecting the architecture to build the app for
# - added installation of compass via gem for Ubuntu 12.04 because the ruby-compass package from Precise is too old and causes the css compilation to fail
# - re-wrote some parts of the script to get it to work with Popcorn Time 0.3.0 beta
# - disable 32bit playback work-around, it's no longer needed
# - Popcorn Time now requires libudev1 instead of libudev0 so use reverse work-around for systems without libudev1 (like Ubuntu 12.04)
# - use dev-0.3 branch
function checkAPT()
{
sleep 1
for lock in synaptic update-manager software-center apt-get "dpkg " aptitude
do
if ps -U root -u root u | grep "$lock" | grep -v grep > /dev/null; then
echo "Installation won't work. Please close $lock first then try again.";
exit
fi
done
}
#information
echo "
Popcorn-Time 0.3.0 beta for Ubuntu
------------------------------------
WARNING: Popcorn Time streams movies from Torrents. Downloading copyrighted material may be illegal in your country. Use at your own risk.
"
#verify awareness
read -p "Do you wish to install Popcorn Time [y/n] ? "
if [ "$REPLY" == "y" ] ; then
sudo echo -e "\nThis may take a while...\n"
else
exit 0
fi
#dependencies install
checkAPT
echo "- Installing dependencies from repositories..."
sudo add-apt-repository -y ppa:chris-lea/node.js
sudo apt-get update
if [ `lsb_release -cs` == "precise" ]; then
#work-around for Ubuntu precise having a too old ruby-compass
sudo apt-get install nodejs git wget rubygems -y
sudo gem install compass && echo -e "...Ok.\n"
else
sudo apt-get install nodejs ruby-compass git wget -y && echo -e "...Ok.\n"
fi
#npm install for CLI
echo "- Installing CLI from 'npm'..."
sudo npm install -g grunt-cli bower && echo -e "...Ok.\n"
#clean up ~/tmp folder or npm install below will fail
sudo rm -rf ~/tmp
#git clone
echo "- Cloning GITHUB repository..."
git clone https://github.com/popcorn-official/popcorn-app.git && echo -e "...Ok.\n"
#check architecture
if [ -n "`arch | grep 64`" ] ; then
#64bits
ARCH=linux64
else
#32bits
ARCH=linux32
fi
#repair broken nodejs symlink
if [ ! -e /usr/bin/node ]; then
sudo ln -s /usr/bin/nodejs /usr/bin/node
fi
#use dev-0.3 branch
cd popcorn-app/
git checkout dev-0.3
#install NPM dependencies
echo "- Installing NPM dependencies..."
npm install && echo -e "...Ok.\n"
#build with grunt
echo "- Building with 'grunt'..."
grunt build --platforms=all && echo -e "...Ok.\n"
#libudev1 fix
#cd build/releases/Popcorn-Time/$ARCH/
#if [ ! -e /lib/x86_64-linux-gnu/libudev.so.0 ] && [ ! -e /lib/i386-linux-gnu/libudev.so.0 ]; then
# sudo sed -i 's/\x75\x64\x65\x76\x2E\x73\x6F\x2E\x30/\x75\x64\x65\x76\x2E\x73\x6F\x2E\x31/g' Popcorn-Time/Popcorn-Time
#fi
if [ "$ARCH" == "linux64" ] ; then
if [ ! -e /lib/x86_64-linux-gnu/libudev.so.1 ]; then
sudo ln -s /lib/x86_64-linux-gnu/libudev.so.0 /lib/x86_64-linux-gnu/libudev.so.1
fi
elif [ "$ARCH" == "linux32" ] ; then
if [ ! -e /lib/i386-linux-gnu/libudev.so.1 ]; then
sudo ln -s /lib/i386-linux-gnu/libudev.so.0 /lib/i386-linux-gnu/libudev.so.1
fi
fi
#Copy program into /opt
echo "- Installing Popcorn-Time in '/opt/Popcorn-Time/'"
sudo mkdir -p /opt
sudo cp -rf build/releases/Popcorn-Time/"$ARCH"/Popcorn-Time /opt
sudo chmod +x /opt/Popcorn-Time/Popcorn-Time
sudo rm -f "/usr/bin/popcorn-time"
sudo ln -s /opt/Popcorn-Time/Popcorn-Time /usr/bin/popcorn-time && echo -e "...Ok.\n"
#fixing playback on 32bit
#if [ "$ARCH" == "linux32" ] ; then
# sudo rm -f "/opt/Popcorn-Time/libffmpegsumo.so"
# wget https://github.com/hotice/webupd8/raw/master/libffmpegsumo.so -O /tmp/libffmpegsumo.so
# sudo cp -f /tmp/libffmpegsumo.so /opt/Popcorn-Time/
#fi
#testing app
echo "The application 'Popcorn-Time' will now be tested for 7 secondes.
"
build/releases/Popcorn-Time/"$ARCH"/Popcorn-Time/Popcorn-Time &
sleep 7
killall Popcorn-Time
read -p "
Did you see the Popcorn-Time application ?
If yes, do you wish to remove all the unecessary files now that the program works [y/n] ? "
if [ "$REPLY" == "y" ] ; then
#remove building files
echo "- Removing building files now unwanted..."
cd ..
sudo rm -rf popcorn-app ~/tmp ~/.npm && echo -e "...Ok.\n"
fi
#create launcher
echo "- Creating launcher/shortcut in '/usr/share/applications/'..."
wget https://github.com/hotice/webupd8/raw/master/popcorntime.png -O /tmp/popcorntime.png
sudo cp -f /tmp/popcorntime.png /usr/share/pixmaps/
echo "[Desktop Entry]
Comment=Watch movies in streaming with P2P.
Name=Popcorn Time
Exec=/usr/bin/popcorn-time
StartupNotify=false
Type=Application
Icon=popcorntime" | sudo tee /usr/share/applications/popcorn-time.desktop
sudo chmod +x /usr/share/applications/popcorn-time.desktop && echo -e "...Ok.\n"
echo "
Installation done ! Popcorn-time should be now available through :
- Dash
- Commandline 'popcorn-time'"
exit 0