summaryrefslogblamecommitdiffstats
path: root/builder/dnbd3-rootfs/scripts/build.sh
blob: 1aa835ab8511cfe9731c49d20edbfdf3733e855c (plain) (tree)
1
2
3
4
5
6


                                                      

                                            
     







































                                                                                 
















                                                                          
                         
                                                    

                                                 


                                                                               

                                         




                     



                                 
                                                  








                                                 
                   



                                         
                                                







                                 
                       



                                   
                                                      


                                  
              



              
                     



                                             
                                                    





                                      
                                                 



                                
                                                                              




              
                                               



                                        
                                                                            




              
source "$(dirname "${BASH_SOURCE[0]}")/rebash/core.sh"
core.import logging

build_compile_qemu_xmount() {
    # Downloads and compiles qemu libxmount.
    #
    # Provides the following file:
    # "$1/libxmount_input_qemu.so"

    pushd "$1"
    ./configure --enable-xmount-input --extra-cflags=-fPIC \
        --python=$(which python2)
    make libxmount_input_qemu.so
    local ret=$?
    popd
    return $ret
}
build_clean_qemu_xmount() {
    pushd "$1"
    make clean
    popd
    return $?
}
build_compile_xmount() {
    # Downloads and compiles xmount
    #
    # Provides the following files:
    # "$1/trunk/build/libxmount_input/libxmount_input_raw/libxmount_input_raw.so"
    # "$1/trunk/build/src/xmount"
    pushd "$1"
    mkdir -p trunk/build
    cd trunk/build
    cmake -DCMAKE_BUILD_TYPE=Release ..
    make
    local ret=$?
    popd
    return $ret
}
build_clean_xmount() {
    rm -rf "$1/trunk/build"
}
build_clean_qemu_nbd() {
    pushd "$1"
    make clean
    popd
    return $?
}
build_compile_qemu_nbd() {
    # Downloads and compiles qemu-nbd.
    #
    # Examples:
    #
    # >>> build_compile_qemu_nbd path/to/nbd/directory/
    # ...
    # Provides the following file:
    # "$1/qemu-nbd"
    logging.info 'Compiling static qemu-nbd binary. This takes a while,' \
        'grab a cup of coffee...'
    # TODO check if need all, after disabling features
    # TODO check dependencies
    #su -s /bin/bash nobody
    #yaourt --noconfirm -S glib2-static glibc-static pcre-static
    #exit
    pushd "$(dirname $1)"
    # TODO check what other features can be disabled
    # --static
    ./configure --target-list=x86_64-linux-user \
        --python=$(which python2) --disable-docs --disable-gtk --disable-vnc \
        --disable-kvm --disable-libssh2 --enable-user --disable-system \
        --disable-fdt --disable-libnfs --disable-glusterfs --disable-libiscsi \
        --disable-gcrypt --disable-nettle
    make qemu-nbd
    local ret=$?
    popd
    return $ret
}
build_compile_nbd() {
    # Downloads and compiles nbd.
    #
    # Examples:
    #
    # >>> build_compile_nbd path/to/nbd/directory/
    # ...
    # Provides the following file:
    # "$1/nbd.ko"
    pushd "$1"
    logging.info 'Compile the nbd kernel module.'
    make
    popd
    return $?
}
build_clean_nbd() {
    # Cleans nbd specific generated files
    #
    # Examples:
    #
    # >>> build_clean_nbd path/to/nbd/directory/
    # ...
    # Removes the following file:
    # "$1/nbd.ko"
    pushd "$1"
    make clean
    popd
    return $?
}
build_compile_dnbd3() {
    # Downloads and compiles dnbd3.
    #
    # Examples:
    #
    # >>> build_compile_dnbd3 path/to/dnbd3/directory/
    # ...
    # Provides the following file:
    # "$1/build/dnbd3.ko"
    pushd "$1"
    ./build.sh
    popd
    return $?
}
build_clean_dnbd3() {
    # Removes generated dnbd3 specific files.
    #
    # Examples:
    #
    # >>> build_clean_dnbd3 path/to/dnbd3/directory/
    # ...
    # Removes the following directory:
    # "$1/build"
    rm --recursive --force "$1/build"
    return $?
}
build_compile_systemd_preserve_process_marker() {
    # Compiles simple c program.
    #
    # Examples:
    #
    # >>> build_compile_systemd_preserve_process_marker path/to/program/folder
    pushd "$1"
    make
    popd
    return $?
}
build_clean_systemd_preserve_process_marker() {
    # Removes compiled simple c program.
    #
    # Examples:
    #
    # >>> build_clean_systemd_preserve_process_marker path/to/program/folder
    pushd "$1"
    make clean
    popd
    return $?
}