-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup_env.sh
executable file
·109 lines (97 loc) · 2.63 KB
/
setup_env.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
#!/usr/bin/bash
# Script that do initial setup for libzypp ng bindings development.
# To update git submodules use
# git submodule update --remote
#
# It needs TW as dev env. One of option is to use distrobox as shown:
# ```sh
# distrobox create --image tumbleweed --name zyppng
# distrobox enter zyppng # if stuck see https://github.com/89luca89/distrobox/issues/1530 and kill and run again
# # and now you are inside dev env where you run this script
# # to clean use distrobox stop zyppng and if no longer image is needed use distrobox rm zyppng
# ```
set -eu
BASEDIR=$(dirname "$0")
# Helper:
# Ensure root privileges for the installation.
# In a testing container, we are root but there is no sudo.
if [ $(id --user) != 0 ]; then
SUDO=sudo
if [ "$($SUDO id --user)" != 0 ]; then
echo "We are not root and cannot sudo, cannot continue."
exit 1
fi
else
SUDO=""
fi
$SUDO zypper --non-interactive rm rust\* || true
# install all required packages and only required as recommends are really huge
$SUDO zypper --non-interactive install --no-recommends \
git \
cmake \
openssl \
libudev1 \
libboost_headers-devel \
libboost_program_options-devel \
libboost_test-devel \
libboost_thread-devel \
dejagnu \
gcc-c++ \
gettext-devel \
graphviz \
libxml2-devel \
yaml-cpp-devel \
gobject-introspection-devel \
libproxy-devel \
pkg-config \
libsolv-devel \
libsolv-tools-base \
glib2-devel \
libsigc++2-devel \
readline-devel \
nginx \
vsftpd \
rpm \
rpm-devel \
libgpgme-devel \
FastCGI-devel \
libcurl-devel \
"rubygem(asciidoctor)" \
libzck-devel \
libzstd-devel \
libbz2-devel \
xz-devel \
rustup
cd "$BASEDIR"
# checkout submodules
git submodule init
git submodule update --checkout
# lets build libzypp
(
cd libzypp
mkdir -p build
cd build
# With /usr/local, we have to set a path: LD_LIBRARY_PATH=/usr/local/lib64 zypprs
# but the plus side is that the /usr zypper keeps working :)
#
# cmake -D CMAKE_INSTALL_PREFIX=/usr/local -D BUILD_GLIB_API=ON -D DISABLE_AUTODOCS=ON ..
cmake -D BUILD_GLIB_API=ON -D DISABLE_AUTODOCS=ON ..
make -j$(nproc)
$SUDO make install
)
# now lets make rust working
rustup install stable
# lets install gir
cd gir
# workaround for badly working exclude in cargo see https://github.com/rust-lang/cargo/issues/6745
if ! grep -q '\[workspace\]' Cargo.toml; then
printf '\n[workspace]' >> Cargo.toml
fi
cargo install --path .
cd -
# to use gir follow https://gtk-rs.org/gir/book/tutorial/sys_library.html
# install doc tool
cargo install rustdoc-stripper
cargo build
echo 'To test if everything works, run:'
echo LD_LIBRARY_PATH=/usr/local/lib64 ./target/debug/zypprs