HowTo OSCam Debian Pakete erstellen

Dieses Thema im Forum "CS Allgemein" wurde erstellt von VDR Experimental, 4. Juni 2013.

  1. VDR Experimental
    Offline

    VDR Experimental Newbie

    Registriert:
    26. Januar 2013
    Beiträge:
    1
    Zustimmungen:
    0
    Punkte für Erfolge:
    1
    Mit folgendem Script kann man die OSCam als Debian Source- und Binarypaket erstellen:

    #!/bin/bash

    VERSION="1.20-unstable"
    DEBEMAIL="VDR User <no@mail.ad>"

    print()
    {
    X=$(echo $1 | wc -c)
    Y=3
    dialog --stdout --infobox "$1" $Y $((X+3))
    [ -z "$2" ] || exit $2
    }

    check-svn()
    {
    if [ ! -e oscam-svn/.svn/all-wcprops ]
    then
    print "oscam-svn not found" 1
    fi
    REVISION=$(grep "trunk$" oscam-svn/.svn/all-wcprops | sed "s/.*ver\///;s/\/trunk//")
    SOURCE=$(ls -1 oscam_$VERSION-$REVISION-svn.dsc)
    SRCDIR="$(echo $SOURCE | sed "s/-svn.dsc//;s/oscam_/oscam-/")"
    }

    build-src()
    {
    print "Building source package"
    if ! dpkg-buildpackage -S -us -uc -tc &>/dev/null
    then
    print "Building source package failed" 1
    fi
    }

    SUDO=""
    [ "$UID" = "0" ] || SUDO=sudo

    echo "Install build dependencies for OSCam"
    $SUDO apt-get install -y dialog \
    fakeroot \
    subversion \
    build-essential \
    diff \
    dpkg-dev \
    devscripts \
    debhelper \
    cdbs \
    cmake \
    libssl-dev \
    libpcsclite-dev \
    libusb-1.0-0-dev \
    wget \
    &>/dev/null

    ARGS=`dialog --stdout --title "*** OSCam ***" \
    --checklist "Select option(s)" 0 40 6 \
    "GetSource" "" on \
    "AddPatches" "" off \
    "ConfigureOSCam" "" on \
    "BuildBinaryPackage" "" on \
    "InstallBinary" "" on`

    for RESULT in $ARGS; do
    {
    case $RESULT in
    # Get Source
    '"GetSource"')
    if [ -e oscam-svn/.svn/all-wcprops ]
    then
    print "oscam-svn exist"
    sleep 2
    else
    # Enter '-r <REVISION> URL' for a special revision
    SVN_URL=`dialog --stdout --inputbox "OSCam URL" 0 0 "http://www.streamboard.tv/svn/oscam/trunk"`
    clear
    print "Getting source..."
    svn checkout $SVN_URL oscam-svn &>/dev/null
    fi
    check-svn
    print "OSCam Revision: $REVISION"
    sleep 2
    print "Building source tarball"
    cd oscam-svn
    tar --exclude=.svn* --exclude=.git* -cjf ../oscam_$VERSION-$REVISION.orig.tar.bz2 .
    cd ..

    # Create Debian source package
    print "Unpacking source tarball"
    rm -rf oscam-$VERSION-$REVISION
    mkdir oscam-$VERSION-$REVISION
    cd oscam-$VERSION-$REVISION
    tar -xjf ../oscam_$VERSION-$REVISION.orig.tar.bz2
    print "Building source package"
    mkdir -p debian/source

    # debian/source
    echo "3.0 (quilt)" >debian/source/format
    echo "compression=bzip2" >debian/source/options

    # debian/changelog
    cat << EOF >debian/changelog
    oscam ($VERSION-$REVISION-svn) unstable; urgency=low

    * Actual svn checkout rev. $REVISION

    -- VDR User <no@mail.ad> $(date -R --date='TZ="Europe/Berlin" now')
    EOF

    # debian/compat
    echo "7" >debian/compat

    # debian/control
    cat << EOF >debian/control
    Source: oscam
    Section: video
    Priority: extra
    Maintainer: VDR User <no@mail.ad>
    Build-Depends: debhelper (>= 7.0.50~), cdbs, cmake, libssl-dev (>= 0.9.8), libpcsclite-dev, libusb-1.0-0-dev
    Standards-Version: 3.8.4
    Homepage:

    Dieser Link ist nur für Mitglieder!!! Jetzt kostenlos Registrieren ?



    Package: oscam
    Architecture: any
    Depends: \${shlibs:Depends}, \${misc:Depends}, openssl (>= 0.9.8), libpcsclite1
    Recommends: vdr-plugin-dvbapi (>= 1.0.0~git20120209)
    Description: OSCam - Open Source Conditional Access Module
    OSCam is an Open Source Conditional Access Module software, based on the very good MpCS version 0.9d created by dukat.
    EOF

    # debian/copyright
    cat << EOF >debian/copyright
    This work was packaged for Debian by:

    VDR User <no@mail.ad> $(date -R --date='TZ="Europe/Berlin" now')

    It was downloaded from:

    Dieser Link ist nur für Mitglieder!!! Jetzt kostenlos Registrieren ?



    Upstream Author(s):

    VDR User <no@mail.ad>

    Copyright:

    Copyright (C) 2012 VDR User

    License:

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This package is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program. If not, see <http://www.gnu.org/licenses/>.

    On Debian systems, the complete text of the GNU General
    Public License version 3 can be found in "/usr/share/common-licenses/GPL-3".

    The Debian packaging is:

    Copyright (C) 2012 VDR User <no@mail.ad>
    EOF

    # debian/oscam.default
    cat << EOF >debian/oscam.default
    # /etc/default/oscam

    # start cam daemon?
    START_OSCAM=yes

    # be verbose?
    VERBOSE=yes

    # oscam arguments
    DAEMON_ARGS="-d 128 -s -r 2 -u -c /etc/oscam"

    # camd socket (use none to disable socket)
    SOCKET=/tmp/camd.socket
    EOF

    # debian/oscam.dirs
    echo "var/log/oscam/cw" >debian/oscam.dirs
    echo "var/log/oscam/emm" >>debian/oscam.dirs

    # debian/oscam.docs
    echo "README" >debian/oscam.docs
    echo "Distribution/doc/example" >>debian/oscam.docs
    echo "Distribution/doc/html" >>debian/oscam.docs

    # debian/oscam.init
    cat << EOF >debian/oscam.init
    #! /bin/sh
    ### BEGIN INIT INFO
    # Provides: oscam
    # Required-Start: \$remote_fs \$network \$syslog \$tmpfs
    # Required-Stop:
    # Default-Start: 2 3 4 5
    # Default-Stop: 0 1 6
    # Short-Description: OSCam Server
    # Description: Open source software CAM
    ### END INIT INFO

    # Author: VDR User <no@mail.ad>
    PATH=/bin:/sbin:/usr/bin:/usr/sbin
    NAME=oscam
    DESC="OSCam Server"

    DAEMON=/usr/bin/\$NAME
    DAEMON_ARGS="-d 128 -s -r 2 -c /etc/oscam"
    DEFAULT=/etc/default/\$NAME
    PIDFILE=/var/run/\$NAME.pid
    SOCKET=/tmp/camd.socket

    . /lib/init/vars.sh
    . /lib/lsb/init-functions

    test -x "\$DAEMON" || exit 0
    test -r \$DEFAULT && . \$DEFAULT

    do_start()
    {
    if [ "\$START_OSCAM" = "yes" ]
    then
    # only start oscam if there is no other instance running
    if start-stop-daemon --start --quiet --exec \$DAEMON --test --name \$NAME --pidfile \$PIDFILE >/dev/null
    then
    if ([ -e "\$SOCKET" ] || [ "\$SOCKET" = "none" ])
    then
    start-stop-daemon --start --quiet --exec \$DAEMON --background --name \$NAME --pidfile \$PIDFILE --make-pidfile -- \$DAEMON_ARGS >/dev/null
    sleep 2
    logger "OSCam started"
    return 0
    else
    log_daemon_msg "No socket: \$SOCKET"
    return 2
    fi
    else
    [ "\$VERBOSE" = "yes" ] && log_daemon_msg "\$NAME seems to be running already"
    return 1
    fi
    else
    [ "\$VERBOSE" = "yes" ] && log_daemon_msg "Aborted (to enable the daemon edit /etc/default/\$NAME)"
    return 2
    fi
    }

    do_stop()
    {
    if start-stop-daemon --start --quiet --exec \$DAEMON --test --name \$NAME --pidfile \$PIDFILE >/dev/null
    then
    [ "\$VERBOSE" = "yes" ] && log_daemon_msg "\$NAME seems not to be running"
    return 1
    else
    start-stop-daemon --stop --signal KILL --name \$NAME --pidfile \$PIDFILE >/dev/null
    while [ ! -z "\$(pidof \$NAME)" ]
    do
    sleep 1
    done
    rm -f \$PIDFILE
    logger "OSCam stopped"
    fi
    return 0
    }

    do_reload() {
    start-stop-daemon --stop --signal 1 --quiet
    return 0
    }

    case "\$1" in
    start)
    [ "\$VERBOSE" = "yes" ] && log_daemon_msg "Starting \$DESC" "\$NAME "
    do_start
    case "\$?" in
    0|1) [ "\$VERBOSE" = "yes" ] && log_end_msg 0 ;;
    2) [ "\$VERBOSE" = "yes" ] && log_end_msg 1 ;;
    esac
    ;;

    stop)
    [ "\$VERBOSE" = "yes" ] && log_daemon_msg "Stopping \$DESC" "\$NAME "
    do_stop
    case "\$?" in
    0|1) [ "\$VERBOSE" = "yes" ] && log_end_msg 0 ;;
    2) [ "\$VERBOSE" = "yes" ] && log_end_msg 1 ;;
    esac
    ;;

    status)
    if [ -z "\$(pidof \$NAME)" ]
    then
    echo "\$DESC is NOT running."
    else
    echo "\$DESC is running."
    fi
    ;;

    reload|restart|force-reload)
    [ "\$VERBOSE" = "yes" ] && log_daemon_msg "Restarting \$DESC" "\$NAME "
    do_stop
    case "\$?" in
    0|1)
    do_start
    case "\$?" in
    0) [ "\$VERBOSE" = "yes" ] && log_end_msg 0 ;;
    1) [ "\$VERBOSE" = "yes" ] && log_end_msg 1 ;; # Old process is still running
    *) [ "\$VERBOSE" = "yes" ] && log_end_msg 1 # Failed to start
    ;;
    esac
    ;;
    *)
    # Failed to stop
    [ "\$VERBOSE" = "yes" ] && log_end_msg 1
    ;;
    esac
    ;;

    *)
    echo "Usage: \$SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
    exit 3
    ;;
    esac

    exit 0
    EOF

    # debian/oscam.manpage
    cat << EOF >debian/oscam.manpage
    Distribution/doc/man/list_smargo.1
    Distribution/doc/man/oscam.1
    Distribution/doc/man/oscam.ac.5
    Distribution/doc/man/oscam.cert.5
    Distribution/doc/man/oscam.conf.5
    Distribution/doc/man/oscam.dvbapi.5
    Distribution/doc/man/oscam.guess.5
    Distribution/doc/man/oscam.ird.5
    Distribution/doc/man/oscam.provid.5
    Distribution/doc/man/oscam.server.5
    Distribution/doc/man/oscam.services.5
    Distribution/doc/man/oscam.srvid.5
    Distribution/doc/man/oscam.tiers.5
    Distribution/doc/man/oscam.user.5
    Distribution/doc/man/oscam.whitelist.5
    EOF

    # debian/oscam.postinst
    cat << EOF >debian/oscam.postinst
    #!/bin/sh
    #
    # postinst script for oscam
    #
    # see dh_installdeb(1)

    set -e

    case \$1 in

    configure|reconfigure)
    [ ! -e /usr/bin/get_oscam.sh ] || mv -f /usr/bin/get_oscam.sh /usr/bin/get_oscam
    if [ ! -e "/etc/init/oscam.conf" ]; then
    update-rc.d oscam defaults >/dev/null
    fi
    invoke-rc.d oscam start || true
    ;;

    abort-upgrade|abort-remove|abort-deconfigure)
    ;;

    *)
    echo "postinst called with unknown argument \\\`\$1'" >&2
    exit 1
    ;;

    esac

    exit 0
    EOF

    # debian/oscam.postrm
    cat << EOF >debian/oscam.postrm
    #!/bin/sh
    #
    # postrm script for oscamd
    #
    # see dh_install(1)

    set -e

    remove_rc_d()
    {
    if [ ! -e "/etc/init/oscam.conf" ]; then
    update-rc.d -f oscam remove >/dev/null
    fi
    }

    case \$1 in

    remove|upgrade|deconfigure)
    remove_rc_d
    ;;

    purge)
    remove_rc_d
    rm -rf /etc/oscam
    rm -rf /var/log/oscam
    ;;

    failed-upgrade)
    ;;

    *)
    echo "postrm called with unknown argument \\\`\$1'" >&2
    exit 1
    ;;

    esac

    exit 0
    EOF

    # debian/oscam.prerm
    cat << EOF >debian/oscam.prerm
    #!/bin/sh
    #
    # prerm script for oscamd
    #
    # see dh_install(1)

    set -e

    case \$1 in

    remove|upgrade)
    [ ! -e /var/run/oscam.pid ] || echo "oscam daemon is still running..."
    ;;

    *)
    echo "prerm called with unknown argument \\\`\$1'" >&2
    exit 1
    ;;

    esac

    exit 0
    EOF

    # debian/rules
    cat << EOF >debian/rules
    #!/usr/bin/make -f

    # Uncomment this to turn on verbose mode.
    #export DH_VERBOSE=1

    DEB_CMAKE_INSTALL_PREFIX := /usr
    DEB_CMAKE_NORMAL_ARGS := \
    -DCMAKE_INSTALL_PREFIX="\$(DEB_CMAKE_INSTALL_PREFIX)" \\
    -DCMAKE_C_COMPILER:FILEPATH="\$(CC)" \\
    -DCMAKE_CXX_COMPILER:FILEPATH="\$(CXX)" \\
    -DCMAKE_C_FLAGS="\$(CFLAGS)" \\
    -DCMAKE_CXX_FLAGS="\$(CXXFLAGS)" \\
    -DCMAKE_SKIP_RPATH=ON \\
    -DCMAKE_BUILD_TYPE=Release \\
    -DCMAKE_VERBOSE_MAKEFILE=OFF \\
    -DHAVE_PCSC=0 \\
    -DHAVE_LIBUSB=0

    include /usr/share/cdbs/1/rules/debhelper.mk
    include /usr/share/cdbs/1/class/cmake.mk

    clean::
    @rm -f webif/pages_gen
    @rm -f webif/pages.bin
    @rm -f webif/pages.bin.compressed
    @rm -f webif/pages.dep
    @rm -f webif/pages.c
    @rm -f webif/pages.h
    EOF
    chmod +x debian/rules

    # debian/oscam.install
    if [ -d /etc/oscam ]
    then
    mkdir -p debian/conf/oscam
    cp /etc/oscam/oscam.* debian/conf/oscam
    else
    mkdir -p debian/conf/oscam
    cp Distribution/doc/example/oscam.* debian/conf/oscam
    fi
    echo "debian/conf/oscam etc" >debian/oscam.install

    if [ -d /etc/camd3 ]
    then
    [ -e debian/conf ] || mkdir -p debian/conf
    cp -R /etc/camd3 debian/conf
    echo "debian/conf/camd3 usr/share/doc/oscam" >>debian/oscam.install
    elif [ -e /var/keys/camd3.config ]
    then
    [ -e debian/conf/camd3 ] || mkdir -p debian/conf/camd3
    cp /var/keys/camd3.* debian/conf/camd3
    echo "debian/conf/camd3 usr/share/doc/oscam" >>debian/oscam.install
    fi

    if [ -e /usr/bin/get_oscam ]
    then
    cp /usr/bin/get_oscam debian
    mv debian/get_oscam debian/get_oscam.sh
    echo "debian/get_oscam.sh usr/bin" >>debian/oscam.install
    fi

    build-src
    cd ..
    rm -rf $SRCDIR
    ;;

    # Add Patches
    '"AddPatches"')
    PATCHDIR=`dialog --stdout --inputbox "OSCam Patches" 0 0 "/usr/share/doc/oscam/patches"`
    if [ -d "$PATCHDIR" ]
    then
    print "Adding patches from \"$PATCHDIR\""
    check-svn
    rm -rf $SRCDIR
    dpkg-source -x $SOURCE &>/dev/null
    cd $SRCDIR/debian
    mkdir patches
    find $PATCHDIR -name "*" -type f -exec cp -f {} patches ";"
    ls -1 patches | sed "s/*.\///;s/series//;/^\s$/d;/^$/d" | sort -u >patches/series
    PATCH_DIR=$(echo $PATCHDIR | sed s/^.//)
    for PATCH in patches/*
    do
    echo "debian/$PATCH $PATCH_DIR/$REVISION" >>oscam.install
    done
    dch -a "Added patches from $PATCHDIR"
    cd ..
    build-src
    cd ..
    rm -rf $SRCDIR
    else
    print "Patchdir ($PATCHDIR) not found"
    sleep 2
    fi
    ;;

    # Configure OSCam
    '"ConfigureOSCam"')
    check-svn
    if [ ! -e $SOURCE ]
    then
    print "Source not found" 1
    else
    DIR=$(pwd)
    rm -rf $SRCDIR
    dpkg-source -x $SOURCE &>/dev/null
    cd $SRCDIR
    if [ -e debian/patches/01_config.patch ]
    then
    print "01_config.patch exist"
    sleep 2
    else
    cd $SRCDIR
    ./config.sh -g
    cd /tmp
    rm -rf a b
    mkdir a
    cd a
    ARCHIVE=$(ls $DIR/oscam_*.orig.tar.bz2)
    tar -xjf $ARCHIVE
    cd ..
    mkdir b
    cp -R $DIR/$SRCDIR/* b/
    rm -rf b/debian
    [ -e $DIR/$SRCDIR/debian/patches ] || mkdir $DIR/$SRCDIR/debian/patches
    diff -Naur a b >$DIR/$SRCDIR/debian/patches/01_config.patch
    rm -rf a b
    cd $DIR/$SRCDIR/debian
    if [ -e patches/01_config.patch ]
    then
    ls -1 patches | sed "s/series//;/^\s$/d;/^$/d" >patches/series
    echo "debian/patches/01_config.patch usr/share/doc/oscam/patches/$REVISION" >>oscam.install
    echo "debian/patches/series usr/share/doc/oscam/patches/$REVISION" >>oscam.install
    dch -a "Added configuration patch"
    fi
    cd ..
    build-src
    fi
    cd ..
    rm -rf $SRCDIR
    fi
    ;;

    ## Build Binary Package
    '"BuildBinaryPackage"')
    check-svn
    if [ ! -e $SOURCE ]
    then
    print "Source not found" 1
    else
    print "Extracting source"
    rm -rf $SRCDIR
    dpkg-source -x $SOURCE &>/dev/null
    print "Building binary package"
    cd $SRCDIR
    dpkg-buildpackage -rfakeroot -us -uc -tc &>/dev/null
    cd ..
    fi
    ;;

    # Install Binary
    '"InstallBinary"')
    check-svn
    PACKAGE="$(ls -1 oscam_$VERSION-$REVISION-svn_*.deb)"
    if [ -z "$PACKAGE" ]
    then
    print "Binary not found" 1
    else
    clear
    echo "Install oscam..."
    $SUDO dpkg -i $PACKAGE
    fi
    ;;
    esac
    }; done

    exit 0
     
    #1

Diese Seite empfehlen

OK Mehr information

Diese Seite verwendet Cookies. Mit Ihrem Klick auf OK stimmen Sie der Verwendung von Cookies zu. Andernfalls ist die Funktionalität dieser Website beschränkt.