Skip to content

Commit c6c69ed

Browse files
committed
I'm starting to get kinda good at this bash thing
1 parent b293f57 commit c6c69ed

File tree

3 files changed

+213
-120
lines changed

3 files changed

+213
-120
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ devscripts/
1010
lib/ncurses-6.4/
1111
lib/ffmpeg-6.0/
1212
lib/build
13-
install
13+
install
14+
test*.sh

build.sh

Lines changed: 127 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,94 @@
11
#!/bin/bash
22
# set -xe
33

4+
# Use the sudo command if the user is not root
5+
6+
project_name="ascii_video"
7+
author="cobyj33"
8+
version="0.4.0"
9+
github_url="https://www.github.com/cobyj33/ascii_video"
10+
git_repo="https://www.github.com/cobyj33/ascii_video.git"
11+
12+
libavcodec_min_version="59.42.100"
13+
libavformat_min_version="59.30.100"
14+
libavutil_min_version="57.32.101"
15+
libswresample_min_version="4.8.100"
16+
libswscale_min_version="6.8.102"
17+
18+
is_debian=$([[ -f "/etc/debian_version" ]])
19+
20+
if [[ ! $is_debian -eq 0 ]]; then
21+
echo "Cannot build ${project_name}. Project can only currently build \
22+
and is only currently tested to build on Debian-Linux systems. This is in place \
23+
to protect any errors that it would cause on untested architecture."
24+
exit 1
25+
fi
26+
27+
prompt_confirm() {
28+
while true; do
29+
read -r -n 1 -p "${1:-Continue?} [y/n]: " REPLY
30+
echo ""
31+
case $REPLY in
32+
[yY]) echo ; return 0 ;;
33+
[nN]) echo ; return 1 ;;
34+
*) printf " \033[31m %s \n\033[0m" "invalid input"
35+
esac
36+
done
37+
}
38+
39+
is_ncurses6_already_installed_globally() {
40+
[[ ! $(ldconfig -p | grep "libncurses.so.6\|libncursesw.so.6") = \"\" ]]
41+
return $?
42+
}
43+
44+
echo "Building ${project_name} by ${cobyj33}. Version ${version}. See source code at ${github_url}"
45+
446
SUDO=''
547
if (( $EUID != 0 )); then
648
SUDO='sudo'
749
fi
850

51+
# Basic dependencies needed to build software on Debian-Type distributions
52+
# These will be needed for ncurses and building ascii_video itself
53+
building_deps="git \
54+
autoconf \
55+
automake \
56+
build-essential \
57+
make \
58+
cmake \
59+
git \
60+
libtool \
61+
pkg-config"
62+
63+
ffmpeg_deps="meson \
64+
ninja-build \
65+
pkg-config \
66+
yasm \
67+
libva-dev \
68+
libvdpau-dev \
69+
libvorbis-dev \
70+
libxcb1-dev \
71+
libxcb-shm0-dev \
72+
libxcb-xfixes0-dev \
73+
libunistring-dev \
74+
libaom-dev \
75+
libdav1d-dev"
76+
77+
# Update current repository
78+
ncurses_apt="libncurses6"
79+
apt_deps_to_install="${building_deps} ${ncurses_apt}"
80+
81+
if [[ ! -d $(pwd)/lib/build/ffmpeg ]]
82+
then
83+
apt_deps_to_install="${apt_deps_to_install} ${ffmpeg_deps}"
84+
fi
85+
86+
if [[ ! apt_deps_to_install -eq "" ]]
87+
then
88+
$SUDO apt-get update
89+
$SUDO apt-get install ${apt_deps_to_install}
90+
fi
91+
992
project_root=$(pwd)
1093
project_lib_folder=${project_root}/lib
1194
lib_build=${project_lib_folder}/build
@@ -22,110 +105,67 @@ ffmpeg_build=${lib_build}/ffmpeg-6.0
22105

23106
ascii_video_build=${project_root}/build
24107

25-
if [ ! -d ${lib_build} ]
26-
then
27-
mkdir ${lib_build}
28-
fi
29-
30-
$SUDO apt-get update
108+
mkdir -p ${lib_build}
31109

32-
$SUDO apt-get install build-essential \
33-
cmake \
34-
make \
35-
autoconf \
36-
automake \
37-
libtool
110+
# Defaults to local ncurses build if that is found
111+
should_install_ncurses6_locally=false
38112

39-
if [ ! -d ${ncurses_build} ]
113+
if [[ $(is_ncurses6_already_installed_globally) -eq 0 ]]
40114
then
41-
if [ ! -d ${ncurses_src} ]
42-
then
43-
tar -xvf ${ncurses_tar} -C ${project_lib_folder}
44-
fi
115+
[[ ! -d ${ncurses_build} ]] && \
116+
echo "Found a working ncurses6 installation already on system." && \
117+
echo "Defaulting to link toward global ncurses6 installation"
118+
else
119+
echo "Could not find a working ncurses6 installation already on system"
120+
121+
if [[ is_debian -eq 0 ]] && [[ $(prompt_confirm "Would you like to install ncurses6 with apt installer" ) -eq 0 ]] \
122+
&& $SUDO apt-get install libncurses6 || should_install_ncurses6_locally=true
123+
fi
45124

46-
cd ${ncurses_src}
125+
if [[ should_install_ncurses6_locally = true ]]
126+
then
47127

48-
# mkdir ${project_lib_folder}/ncurses-6.4/build
49-
# mkdir ${project_lib_folder}/ncurses-6.4/build/data
50-
if [ ! -d ${ncurses_build} ]
128+
if [[ -d ${ncurses_build} ]]
51129
then
52-
mkdir ${ncurses_build}
53-
fi
54-
55-
if [ ! -d ${ncurses_datadir} ]
130+
echo "Found local ncurses6 build at ${ncurses_build}. Not recompiling ncurses6 library"
131+
elif [[ ! -d ${ncurses_build} ]]
56132
then
57-
mkdir ${ncurses_datadir}
133+
rm -rf ${ncurses_src}
134+
tar -xvf ${ncurses_tar} -C ${project_lib_folder}
135+
cd ${ncurses_src}
136+
mkdir -p ${ncurses_build}
137+
mkdir -p ${ncurses_datadir}
138+
139+
./configure \
140+
--prefix=${ncurses_build} \
141+
--datadir=${ncurses_datadir} \
142+
--without-tests \
143+
--without-manpages \
144+
--without-progs
145+
146+
147+
make -j4
148+
make install
149+
cd ${project_root}
150+
rm -rf ${ncurses_src}
58151
fi
59152

60-
./configure \
61-
--prefix=${ncurses_build} \
62-
--datadir=${ncurses_datadir} \
63-
--without-tests \
64-
--without-manpages \
65-
--without-progs
66-
67-
68-
make -j4
69-
make install
70-
cd ${project_root}
71-
rm -rf ${ncurses_src}
72153
fi
73154

74-
if [ ! -d ${ffmpeg_build} ]
75-
then
76155

77-
mkdir ${ffmpeg_build}
78-
if [ ! -d ${ffmpeg_src} ]
79-
then
80-
tar -xvf ${ffmpeg_tar} -C ${project_lib_folder}
81-
fi
156+
if [[ ! -d ${ffmpeg_build} ]]
157+
then
158+
mkdir -p ${ffmpeg_build}
159+
rm -rf ${ffmpeg_src}
160+
tar -xvf ${ffmpeg_tar} -C ${project_lib_folder}
82161
cd ${ffmpeg_src}
83162

84163
$SUDO apt-get update -qq
85-
86-
deps="autoconf \
87-
automake \
88-
build-essential \
89-
cmake \
90-
git \
91-
libtool \
92-
meson \
93-
ninja-build \
94-
pkg-config \
95-
yasm \
96-
libva-dev \
97-
libvdpau-dev \
98-
libvorbis-dev \
99-
libxcb1-dev \
100-
libxcb-shm0-dev \
101-
libxcb-xfixes0-dev \
102-
libunistring-dev \
103-
libaom-dev \
104-
libdav1d-dev"
105-
106-
$SUDO apt-get install -y \
107-
autoconf \
108-
automake \
109-
build-essential \
110-
cmake \
111-
git \
112-
libtool \
113-
meson \
114-
ninja-build \
115-
pkg-config \
116-
yasm \
117-
libva-dev \
118-
libvdpau-dev \
119-
libvorbis-dev \
120-
libxcb1-dev \
121-
libxcb-shm0-dev \
122-
libxcb-xfixes0-dev \
123-
libunistring-dev \
124-
libaom-dev \
125-
libdav1d-dev
164+
$SUDO apt-get install -y ${ffmpeg_deps}
126165

127166

128167
PKG_CONFIG_PATH="${ffmpeg_build}/lib/pkgconfig"
168+
129169
./configure \
130170
--prefix="${ffmpeg_build}" \
131171
--pkg-config-flags="--static" \
@@ -160,11 +200,7 @@ then
160200
cd ${project_root}
161201
fi
162202

163-
if [ -d ${ascii_video_build} ]
164-
then
165-
rm -rf ${ascii_video_build}
166-
fi
167-
203+
rm -rf ${ascii_video_build}
168204
mkdir ${ascii_video_build}
169205
cd ${ascii_video_build}
170206
cmake ../

0 commit comments

Comments
 (0)