summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 40b5c7047c02a1add2d7c38495c765c606b9ca02 (plain)
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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
# Contributor: JulioJu  < juanes  0890  at google mail dot com >
# Maintainer : JulioJu  < juanes  0890  at google mail dot com >

# Inspirated from :
# http://bazaar.launchpad.net/~marionnet-drivers/marionnet/trunk/view/head:/useful-scripts/marionnet_from_scratch
# Copyright (C) 2010 2011 2012 2013  Jean-Vincent Loddo Copyright (C) 2010
# 2011 2012 2013  Université Paris 13 
# (LGPL)

pkgname=('marionnet-trunk')
pkgver=1
pkgrel=3
pkgdesc="Educational software. It is a virtual network laboratory: it allows
users to define, configure and run complex computer networks without any need
for physical setup. Trunk version (with UML kernel Debian Wheezy)."
arch=('i686' 'x86_64')
url="https://www.marionnet.org/"
makedepends=('wget' 'bc' 'optipng')
license=('LGPL')
depends=('xorg-server' 'xorg-xinit' 'xorg-server-utils' 'gtksourceview2' 'libglademm' 'graphviz' 'xterm' 'vde2' 'uml_utilities' 'net-tools' 'bridge-utils')
if test "$CARCH" == x86_64; then
  depends+=('lib32-glibc')
fi
# Not depends of camlp4 and ocaml-findlib.
conflicts=('marionnet')
source=("http://caml.inria.fr/pub/distrib/ocaml-3.12/ocaml-3.12.1.tar.gz"
        'http://wwwfun.kurims.kyoto-u.ac.jp/soft/lsl/dist/lablgtk-2.14.2.tar.gz'
        "https://raw.githubusercontent.com/JulioJu/Marionnet_ArchLinux_Installer/master/Makefile-trunk.patch"
        "https://raw.githubusercontent.com/JulioJu/Marionnet_ArchLinux_Installer/master/marionnet_from_scratch-Downloader"
)
sha256sums=('4f81ab86258be0eea1507dd5338c8670490f8616249821e731f8ac1c64caa4a7'
            '4981abedabdc462303f345104042c88af227ccd50fd30a9bf48fd353ab02d0ba'
            'efb09389cc67a88b16509dec3ca3fb32f1da1f4c5808b8f2e7e2f050376bf691'
            'f0f93f30424da231357c3d7698229ba1fbdaa41737c954b71ede44d5e57cd50a')
install=marionnet-trunk.install

prepare () {
    # Not in sources, because tar file 433 and 475 (gzip format) have not always same sha256.
    # Probably, they compressed by launchpad for every download.
    wget 'http://bazaar.launchpad.net/~marionnet-drivers/ocamlbricks/trunk/tarball/433'
    wget 'http://bazaar.launchpad.net/~marionnet-drivers/marionnet/trunk/tarball/475'
    tar -xvzf 433
    tar -xvzf 475
    mv '~marionnet-drivers/ocamlbricks/trunk' ocamlbricks
    mv '~marionnet-drivers/marionnet/trunk' marionnet
    rmdir '~marionnet-drivers/ocamlbricks'
    rmdir '~marionnet-drivers/marionnet'
    rmdir '~marionnet-drivers'
}

# ################
# MAKEDEPENDS : CREATED DURING COMPILATION but not keep
# pkgname=ocaml
# pkgver=3.12.1
# Do not use older package (see :
# https://bugs.launchpad.net/marionnet/+bug/1580349 )
# pkgdesc="A functional language with OO extensions"
# license=('LGPL2.1' 'custom: QPL-1.0')
# url="http://caml.inria.fr/"
#
# pkgname=lablgtk2
# It seems we can use older package.
# pkgdesc="An Objective Caml interface to gtk2"
# license=('LGPL')
# url="http://lablgtk.forge.ocamlcore.org/"
# license=('GPL')
#
# pkgname=ocamlbricks
# pkgver=0.90.3
# pkgdesc="Miscellaneous utility functions in OCaml for Marionnet"
# conflicts=('ocamlbricks_trunk')
# url="https://launchpad.net/ocamlbricks/"
# license=('GPL')

build () {
    OUR_MIRROR="https://www.marionnet.org/download/marionnet_from_scratch/mirror/"
    PREFIX="${srcdir}/usr/local"
    mkdir -p "${PREFIX}/usr/local"
    OCAML_DIR="${srcdir}/ocaml-3.12.1"
    LABLGTK2_DIR="${srcdir}/lablgtk-2.14.2"
    MARIONNET_DIR="${srcdir}/marionnet"
    OCAMLBRICK_DIR="${srcdir}/ocamlbricks"
    export PATH="${PREFIX}/bin:${PATH}"
    LIB_OCAML="${PREFIX}/lib/ocaml/"

    ### OCAML ###

    cd "${OCAML_DIR}"

    ./configure -prefix "${PREFIX}" -no-curses -no-tk
    make world.opt &&
    make install

    make -C tools/ objinfo

    if [[ ! -e "${PREFIX}/bin/ocamlobjinfo" ]]; then
        cp tools/objinfo ${PREFIX}/bin/ &&
            [[ -e ${PREFIX}/bin/ocamlobjinfo ]] || ln -s objinfo \
        ${PREFIX}/bin/ocamlobjinfo
    fi

    # #### Liblgtk2 ###
    cd "${LABLGTK2_DIR}"
    ./configure --prefix="${PREFIX}" \
    --with-glade --without-gl --without-rsvg --without-gnomecanvas --without-gnomeui \
    --without-panel --without-gtkspell --without-gtksourceview --with-gtksourceview2 \
    --without-quartz &&
    make &&
    make opt &&
    make install


    #### OCAMLBRICKS ##########
    cd "${OCAMLBRICK_DIR}"
cat > CONFIGME <<EOF
ocaml_libraryprefix="${LIB_OCAML}"
libraryprefix="${LIB_OCAML}"
prefix="${PREFIX}"
configurationprefix="\${prefix}/etc"
documentationprefix="\${prefix}/share/doc"
localeprefix="\${prefix}/share/locale"
ocaml_sources="${LIB_OCAML}/caml"
ocaml_version=`ocamlc -version`
EOF

    make clean &&
    make &&
    make install
    ############ MARIONNET ###########


    cd "${MARIONNET_DIR}"

    # Makefile patch 

    patch Makefile < ../Makefile-trunk.patch

    # Configure CONFIGME
cat > CONFIGME <<EOF
ocaml_libraryprefix="${LIB_OCAML}"
libraryprefix="${LIB_OCAML}"
prefix="/usr"
prefixInstall="${pkgdir}/usr"
configurationprefix="${pkgdir}/etc"
documentationprefix="\${prefixInstall}/share/doc"
localeprefix="\${prefixInstall}/share/locale"
ocaml_sources="${LIB_OCAML}/caml"
ocaml_version=`ocamlc -version`
EOF

    make clean native
}


package() {

    # Fakeroot, so redifine them.
    PREFIX="${srcdir}/usr/local"
    MARIONNET_DIR="${srcdir}/marionnet"
    export PATH="${PREFIX}/bin:${PATH}"

    cd ${MARIONNET_DIR}
    make install

    # Sanitize files

    mv "${pkgdir}/usr/sbin/"* "${pkgdir}/usr/bin"
    rmdir "${pkgdir}/usr/sbin/"

    rm -f "${pkgdir}/usr/bin/marionnet.byte"
    rm -f "${pkgdir}/usr/bin/marionnet-daemon.byte"
    mv "${pkgdir}/usr/bin/marionnet.native" "${pkgdir}/usr/bin/marionnet"

    # Build ${pkgdir}/etc/marionnet/marionnet.conf
    echo "* Generating ${pkgdir}/etc/marionnet/marionnet.conf"

    MARIONNET_DOT_CONF=${pkgdir}/etc/marionnet/marionnet.conf

    function first_installed_binary_of_list {
    local i
    for i in "$@"; do
        if type -t $i &>/dev/null; then
            echo $i
            return 0
        fi
    done
    # otherwise return the first:
    echo $1
    }

    MARIONNET_KEYBOARD_LAYOUT=$(echo $LANG | grep -o '^[a-z]*')
    MARIONNET_KEYBOARD_LAYOUT=${MARIONNET_KEYBOARD_LAYOUT=:-us}
    MARIONNET_PDF_READER=$(first_installed_binary_of_list evince okular kpdf xpdf gv)
    MARIONNET_POSTSCRIPT_READER=$MARIONNET_PDF_READER
    MARIONNET_DVI_READER=$MARIONNET_PDF_READER
    MARIONNET_HTML_READER=$(first_installed_binary_of_list firefox epiphany galeon konqueror rekonq chromium opera)
    MARIONNET_TEXT_EDITOR=$(first_installed_binary_of_list emacs gedit kate kwrite xemacs)

    for i in MARIONNET_{PDF,POSTSCRIPT,DVI,HTML}_READER MARIONNET_TEXT_EDITOR MARIONNET_KEYBOARD_LAYOUT; do
        v=$(eval echo \$$i);
        sed -i -e "s/$i=\(.*\)/$i=$v/" $MARIONNET_DOT_CONF
    done

    #### Generate Daemon ####

    mkdir -p "${pkgdir}/usr/lib/systemd/system/"
    cd "${pkgdir}/usr/lib/systemd/system/"

cat > marionnetdaemon.service <<EOF
# Generating by makepkg from PKGBUILD
# (LGPL)
[UNIT]
Description="Marionnet daemon for graphics on virtual machines and host sockets"

[Service]
Type=simple
ExecStart=/usr/bin/marionnet-daemon.native
KillMode=process
Restart=on-failure

[Install]
WantedBy=graphical.target
EOF

    ### Fix bug https://bugs.launchpad.net/marionnet/+bug/1580349 ###

    optipng -quiet -fix ${pkgdir}/usr/share/marionnet/images/launcher-icons/marionnet-launcher.png
    optipng -quiet -fix ${pkgdir}/usr/share/marionnet/images/ico.cable-serial.small.png
    optipng -quiet -fix ${pkgdir}/usr/share/marionnet/images/ico.script-analyse-3.med.png
    optipng -quiet -fix ${pkgdir}/usr/share/marionnet/images/marionnet-launcher.png
    optipng -quiet -fix ${pkgdir}/usr/share/marionnet/images/ico.cable-serial-left-right.small.png
    optipng -quiet -fix ${pkgdir}/usr/share/marionnet/images/ico.uml-gray.small.png
    optipng -quiet -fix ${pkgdir}/usr/share/marionnet/images/ico.dado.24.png
    optipng -quiet -fix ${pkgdir}/usr/share/marionnet/images/ico.resource-2.med.png
    optipng -quiet -fix ${pkgdir}/usr/share/marionnet/images/ico.dado-no.24.png
    optipng -quiet -fix ${pkgdir}/usr/share/marionnet/images/ico.xml-16.inv.png
    optipng -quiet -fix ${pkgdir}/usr/share/marionnet/images/ico.script-finish.med.png
    optipng -quiet -fix ${pkgdir}/usr/share/marionnet/images/ico.software-gray.small.png
    optipng -quiet -fix ${pkgdir}/usr/share/marionnet/images/ico.script-start-2.med.png
    optipng -quiet -fix ${pkgdir}/usr/share/marionnet/images/ico.cable-serial.xxl.png
    optipng -quiet -fix ${pkgdir}/usr/share/marionnet/images/ico.diffuser.orig.png
    optipng -quiet -fix ${pkgdir}/usr/share/marionnet/images/ico.hardware-gray.small.png
    optipng -quiet -fix ${pkgdir}/usr/share/marionnet/images/ico.cable-serial-left-right.large.png

    chmod u+x "${srcdir}/marionnet_from_scratch-Downloader"
    cp -L "${srcdir}/marionnet_from_scratch-Downloader" "${pkgdir}/usr/share/marionnet"
    echo -e "0\ntrunk" > "${pkgdir}/usr/share/marionnet/numberOfStepsPassedForDownloadMarionnetFilesystems.tmp"

}

# vim: ft=sh: