summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFredy <aluque@soleta.eu>2018-05-22 13:26:12 +0200
committerFredy <aluque@soleta.eu>2018-05-22 13:26:12 +0200
commitbe8d5c33fe87491842b10c7dafb364d6ac85f452 (patch)
treea70f834de58ff8de272f18354b5c0777b3d5f53c
parentebe6b721bb8fc249434091fb1a682cfbe05c0f00 (diff)
#837 adapting pkg generator to git
-rwxr-xr-xinstaller/pkg-generator/genpkg.sh72
1 files changed, 66 insertions, 6 deletions
diff --git a/installer/pkg-generator/genpkg.sh b/installer/pkg-generator/genpkg.sh
index 4dd626b5..5f488336 100755
--- a/installer/pkg-generator/genpkg.sh
+++ b/installer/pkg-generator/genpkg.sh
@@ -17,6 +17,18 @@ PKG_GEN_PATH=/root/debian-pkg
#DESTDIR=$ROOTDIR/opt/opengnsys
TMPDIR=/tmp/opengnsys_installer
+# Registro de incidencias.
+OGLOGFILE=$TMPDIR/log/${PROGRAMNAME%.sh}.log
+LOG_FILE=/tmp/$(basename $OGLOGFILE)
+
+BRANCH="master"
+CODE_URL="https://codeload.github.com/opengnsys/OpenGnsys/zip/$BRANCH"
+API_URL="https://api.github.com/repos/opengnsys/OpenGnsys/branches/$BRANCH"
+RAW_URL="https://raw.githubusercontent.com/opengnsys/OpenGnsys/$BRANCH"
+
+DEV_BRANCH="debian-pkg"
+
+
function help()
{
read -r -d '' HELP <<- EOM
@@ -33,6 +45,26 @@ EOM
echo "$HELP"
}
+function getDateTime()
+{
+ date "+%Y%m%d-%H%M%S"
+}
+
+# Escribe a fichero y muestra por pantalla
+function echoAndLog()
+{
+ echo $1
+ DATETIME=`getDateTime`
+ echo "$DATETIME;$SSH_CLIENT;$1" >> $LOG_FILE
+}
+
+function errorAndLog()
+{
+ echo "ERROR: $1"
+ DATETIME=`getDateTime`
+ echo "$DATETIME;$SSH_CLIENT;ERROR: $1" >> $LOG_FILE
+}
+
function createControlFile()
{
cat > $ROOTDIR/DEBIAN/control << EOF
@@ -48,33 +80,61 @@ Homepage: https://opengnsys.es
EOF
}
+function downloadCode()
+{
+ if [ $# -ne 1 ]; then
+ errorAndLog "${FUNCNAME}(): invalid number of parameters"
+ exit 1
+ fi
+
+ local url="$1"
+
+ echoAndLog "${FUNCNAME}(): downloading code..."
+
+ curl "${url}" -o opengnsys.zip && unzip opengnsys.zip && mv "OpenGnsys-$BRANCH" opengnsys
+ if [ $? -ne 0 ]; then
+ errorAndLog "${FUNCNAME}(): error getting code from ${url}, verify your user and password"
+ return 1
+ fi
+ rm -f opengnsys.zip
+ echoAndLog "${FUNCNAME}(): code was downloaded"
+ return 0
+}
+
function createFullPackage()
{
PKG_NAME="opengnsys-full"
ROOTDIR=$PKG_GEN_PATH/$PKG_NAME
mkdir -p $DESTDIR $TMPDIR $ROOTDIR
-svn export --force $SVNURL $TMPDIR
+#downloadCode $CODE_URL
+# for testing and development:
+git clone gituser@opengnsys.es:/git/opengnsys -b $DEV_BRANCH $TMPDIR
mkdir -p $ROOTDIR/DEBIAN $ROOTDIR/tmp
ln -s $TMPDIR/ $TMPDIR/opengnsys
DEPENDS="Depends: subversion, apache2, php, php-ldap, libapache2-mod-php, isc-dhcp-server, bittorrent, tftp-hpa, tftpd-hpa, xinetd, build-essential, g++-multilib, libmysqlclient-dev, wget, curl, doxygen, graphviz, bittornado, ctorrent, samba, rsync, unzip, netpipes, debootstrap, schroot, squashfs-tools, btrfs-tools, procps, arp-scan, realpath, php-curl, gettext ,moreutils, jq, wakeonlan, mysql-server, php-mysql, udpcast"
-createControlFile
+
# Copy installer to postinst
-cp $TMPDIR/installer/opengnsys_installer.sh $ROOTDIR/DEBIAN/postinst
+#cp $TMPDIR/installer/opengnsys_git_installer.sh $ROOTDIR/DEBIAN/postinst
+cp -a $TMPDIR/installer/pkg-generator/DEBIAN $ROOTDIR/
+
+createControlFile
# Ejemplo de modificacion del postinst al vuelo
# sed -i 's/wget --spider -q/wget --spider -q --no-check-certificate/g' $ROOTDIR/DEBIAN/postinst
# deactivate svn function
-sed -i '/function svnExportCode/{N;s/$/\nreturn 0/}' $ROOTDIR/DEBIAN/postinst
+#sed -i '/function svnExportCode/{N;s/$/\nreturn 0/}' $ROOTDIR/DEBIAN/postinst
-# copy svn repo structure inside .deb package
-cp -a $TMPDIR $ROOTDIR/tmp
+# copy repo structure inside .deb package and delete .git dir
+cp -r $TMPDIR $ROOTDIR/tmp
+rm -Rf $ROOTDIR/tmp/opengnsys_installer/.git
# Finally Generate package
cd $PKG_GEN_PATH
dpkg --build $PKG_NAME .
}
+
function createClientPackage()
{
PKG_NAME="opengnsys-client"