piątek, 28 grudnia 2012

Paczkowanie LMS'a - część pierwsza


LMS od dłuższego czasu nie ma żadnego stabilnego wydania. Postanowiłem wypełnić tą lukę poprzz zapakowanie kodu w paczkę i dołączenie ją do repozytorium Debiana. Plan jest długofalowy, bo targetem jest kolejna po wheezy dystrybucja. Zobaczymy czy wystarczy mi czasu i chęci.

Przygotowanie źródeł do budowania:

1. Przygotowanie źródeł
wget https://github.com/lmsgit/lms/archive/master.zip
unzip master.zip
mv lms-master lms-1.11~git20121227
tar -cvf lms.tar.gz ./lms-1.11~git20121227
dh_make -f ../lms.tar.gz --copyright gpl2

2. Wstępnie przygotowany plik debian/control.

Source: lms
Section: admin
Priority: optional
Maintainer: Rafal Ramocki <rafal@ramocki.pl>
Build-Depends: cdbs, debhelper (>= 7.0.50~)
Standards-Version: 3.8.4
Homepage: http://lms.org.pl/
#Vcs-Git: git://git.debian.org/collab-maint/lms.git
#Vcs-Browser: http://git.debian.org/?p=collab-maint/lms.git;a=summary

Package: lms
Architecture: any
Depends: ${shlibs:Depends}, ${misc:Depends}
Description: Lan Management System siutable for ISP
 "LMS" (LAN Management System) is the integrated system of networks management
 designed for various size internet providers (ISP).
 .
 That software writed in PHP, Perl and C, works with variuos database systems.
 It consists a friendly web user interface (frontend) and programs installed
 on servers (backend). The main features of LMS are:
 .
 - internet access administration (e.g. traffic control and stats)
 - finances with invoicing (automatic billing),
 - database of customers and network devices (network map),
 - serial mailing and administration messages to customers,
 - hosting and accounts management,
 - bug tracking system (helpdesk),
 - any services management,
 - time organizer (timetable),
 - customer web panel.

3. Przygotowany plik debian/copyright. Tutaj pomocny okazał się listy debian-devel z 2006 roku. https://lists.debian.org/debian-devel-announce/2006/03/msg00023.html.

4. Podczas przygotowywania pliku debian/rules odpowiedzialnego za budowanie pojawiła się seria problemów. Chcę budować demona - co wydaje się być oczywiste. Niestety okazuje się, że plik configure używany do wyprodukowania plików Makefile jest napisany z palca i nie akceptuje domyślnych parametrów automake. W pierwszej kolejności chciałem pominąć te parametry. Użyłem do tego dyrektywy DEB_CONFIGURE_NORMAL_ARGS, która nadpisuje wszystkie argumenty z autotools.mk. Mniej - więcej przeszło. Ale chcę też budować wersję dla postgresa i dla mysql. Tutaj niestety ściana. Skrypt konfiguracyjny zakłada, że będzie wykonywany podczas gdy użytkownik będzie w katalogu bieżącym. Niestety podczas budowy z różnymi parametrami narzędzie debianowe wykonują go nie będąc tam. Jedyne sensowne rozwiązanie jakie przychodzi mi do głowy, to poprawa pliku configure tak, by był zgodny z ogólnie przyjętymi standardami. Ponieważ mam dostęp do repozytorium LMS, to może - po konsultacjach z chiłkiem i alecem zaktualizuje globalnie, tak by w przyszłości nie było problemu. Na chwilę obecną szybka konwersja do automake (bez parametrów opcjonalnych) wygląda tak jak poniżej. Poleciałem zgodnie z http://www.galassi.org/mark/mydocs/autoconf_tutorial_2.html:

for i in `find ./ -name Makefile ` ; do echo `dirname $i` ; cd `dirname $i` ; cp Makefile Makefile.orig ; mv Makefile Makefile.in ; autoheader ; cd ~/lms_packaging/work1_temp1/lms-1.11~git20121227/daemon ; done

autoscan
mv configure.scan configure.in
autoheader
autoconf

To wyprodukowało mi potrzebną konfigurację. ./configure pokazało, że jeszcze brakuje pliku install-sh. Na chwilę obecną nie wiem do czego on ma służyć. Najmniejszą linią oporu będzie:

touch install-sh

Lecąc dalej musiałem przygotować odpowiednią wersję configure.in. Sprawa okazała się czasochłonna. O 01:46 w nocy uzyskałem działającą i implementującą wszystkie funkcje ze starego systemu konfiguracji wersję plików configure.in oraz Makefile.in. Ku potomności przedstawiam.

configure.in:
#                                               -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.

AC_PREREQ([2.67])
AC_INIT([FULL-PACKAGE-NAME], [VERSION], [BUG-REPORT-ADDRESS])
AC_CONFIG_SRCDIR([lmsd.c])
AC_CONFIG_HEADERS([config.h])

# Checks for programs.
AC_PROG_YACC
AC_PROG_CXX
AC_PROG_CC
AC_PROG_LEX
AC_PROG_INSTALL

# Checks for libraries.
# FIXME: Replace `main' with a function in `-ldl':
AC_CHECK_LIB([dl], [main])
# FIXME: Replace `main' with a function in `-lfl':
AC_CHECK_LIB([fl], [main])
# FIXME: Replace `main' with a function in `-lgadu':
AC_CHECK_LIB([gadu], [main])
# FIXME: Replace `main' with a function in `-liberty':
AC_CHECK_LIB([iberty], [main])
# FIXME: Replace `main' with a function in `-lm':
AC_CHECK_LIB([m], [main])
AC_CHECK_LIB([pq], [PQconnectdb],
  [have_pgsql=yes
   LIBS="-lpq $LIBS"])
# FIXME: Replace `main' with a function in `-lrxspencer':
AC_CHECK_LIB([rxspencer], [main])
#AC_CHECK_LIB([mysqlclient], [mysql_fetch_row], )
AC_CHECK_LIB([mysqlclient], [mysql_fetch_row],
  [have_mysql=yes
   LIBS="-lmysqlclient $LIBS"])

# Checks for header files.
AC_CHECK_HEADERS([arpa/inet.h fcntl.h limits.h locale.h netinet/in.h stdlib.h string.h sys/ioctl.h sys/socket.h sys/time.h syslog.h unistd.h])

# Checks for typedefs, structures, and compiler characteristics.
AC_HEADER_STDBOOL
AC_TYPE_SIZE_T
AC_TYPE_SSIZE_T

# Checks for library functions.
AC_FUNC_FORK
AC_FUNC_MALLOC
AC_FUNC_MKTIME
AC_FUNC_REALLOC
AC_CHECK_FUNCS([getdelim gethostname gettimeofday inet_ntoa memset pow regcomp select setlocale socket strchr strdup strerror strstr strtol strtoul])

AC_CONFIG_FILES([Makefile
                 modules/Makefile
                 modules/cutoff/Makefile
                 modules/dhcp/Makefile
                 modules/dns/Makefile
                 modules/ethers/Makefile
                 modules/ewx-pt/Makefile
                 modules/ewx-stm-channels/Makefile
                 modules/ewx-stm/Makefile
                 modules/ggnotify/Makefile
                 modules/hostfile/Makefile
                 modules/notify/Makefile
                 modules/oident/Makefile
                 modules/parser/Makefile
                 modules/parser/extensions/Makefile
                 modules/parser/lib/Makefile
                 modules/payments/Makefile
                 modules/pinger/Makefile
                 modules/system/Makefile
                 modules/tc-new/Makefile
                 modules/tc/Makefile
                 modules/traffic/Makefile])

AC_ARG_ENABLE([debug0],
    AS_HELP_STRING([--enable-debug0], [SQL query logging (disabled)]))
AC_ARG_ENABLE([debug1],
    AS_HELP_STRING([--enable-debug1], [events logging (disabled)]))
AC_ARG_WITH([mysql],
    AS_HELP_STRING([--with-mysql], [enables use of MySQL database (enabled)]))
AC_ARG_WITH([pgsql],
    AS_HELP_STRING([--with-pgsql], [enables use of PostgreSQL database (disabled)]))
AC_ARG_WITH(lmslibdir,
    [AC_HELP_STRING([--with-lmslibdir=DIR], [sets location of target LMS modules (PREFIX/lms/lib)])],
    lmslibdir="$withval",
    lmslibdir=$ac_default_prefix/lib/lms
)
AC_SUBST(lmslibdir)

# User can't choos to drivers during one build
AS_IF([test "x$with_mysql" = "xyes" && test "x$with_pgsql" = "xyes"],
     [AC_MSG_ERROR([can't build with mysql and pgsql simultanously])])

# User didn't choos SQL library? Whe chosse mysql if it's available.
# And if not we choose pgsql if its available.
AS_IF([test "x$with_mysql" = "x" && test "x$with_pgsql" = "x"],
    [AS_IF([test "x$have_mysql" = "xyes"], [with_mysql="yes"])],
    [AS_IF([test "x$have_pgsql" = "xyes"], [with_pgsql="yes"])])

# User didn't choose SQL library or we don't have any available
AS_IF([test "x$with_mysql" = "xno" && test "x$with_pgsql" = "xno"],
     [AC_MSG_ERROR([You need postgres or mysql client library])])

# User choose PGSQL library, but it isn't available
AS_IF([test "x$have_pgsql" != "xyes" && test "x$with_pgsql" = "xyes"],
     [AC_MSG_ERROR([pgsql requested but library is missing])])

# User choose MySQL library, but it isn't available
AS_IF([test "x$have_mysql" != "xyes" && test "x$with_mysql" = "xyes"],
     [AC_MSG_ERROR([mysql requested but library is missing])])

AS_IF([test "x$with_pgsql" = "xyes"],
     [AC_SUBST([DBDRIVER], [pgsql])
      CFLAGS="$CFLAGS -DUSE_PGSQL"])

AS_IF([test "x$with_mysql" = "xyes"],
     [AC_SUBST([DBDRIVER], [mysql])
      CFLAGS="$CFLAGS -DUSE_MYSQL"])

AC_OUTPUT

Makefile.in (sam początek, który musiałem dostosować)
INSTALLDIR = @INSTALL@
MODULESDIR = @lmslibdir@
LIBS = @LIBS@
LDFLAGS = @LDFLAGS@
CFLAGS = $(CPPFLAGS) @CFLAGS@ -DLMS_LIB_DIR=\"@lmslibdir@\"
DBDRIVER = @DBDRIVER@
OUT = lms
OS = $OS

Brak komentarzy:

Prześlij komentarz