#718: Crear paquete de instalación de OGAgent para macOS.

git-svn-id: https://opengnsys.es/svn/branches/version1.1@5210 a21b9725-9963-47de-94b9-378ad31fedc9
remotes/github/oglive
ramon 2017-02-21 13:04:52 +00:00
parent e1af5ca334
commit 2bc61be407
7 changed files with 113 additions and 90 deletions

View File

@ -10,6 +10,7 @@ Sisitema operativo GNU/Linux con los siguientes paquetes instalados:
- Wine (32 bits), Wine Gecko, Wine Mono, Samba Winbind, Cabextrct
- Creación de paquetes Deb (debhelper, dpkg-dev)
- Creación de paquetes RPM (rpm-build)
- Creación de paquetes Pkg (xar, bomutils)
Crear instaladores de OGAgent
@ -29,6 +30,11 @@ Crear instaladores de OGAgent
./build-windows.sh
cd ..
- Crear paquetes Deb y RPM para distribuciones GNU/Linux (requiere permisos de "root"):
cd macos
./build-pkg.sh
cd ..
- Subir los nuevos ficheros .deb, .rpm y .exe generados en el directorio
/opt/opengnsys/www/descargas del servidor OpenGnsys.
@ -69,6 +75,9 @@ Instalar OGAgent en cliente modelo
- Iniciar el servicio (se iniciará automáticamente en el proceso de arranque):
NET START OGAgent
- macOS:
(en preparación)
Postconfiguración para clientes clonados
----------------------------------------

View File

@ -1,73 +0,0 @@
#!/usr/bin/make -f
# -*- makefile -*-
# Directories
SOURCEDIR := ../src
DESTDIR := /usr/local
LIBDIR := $(DESTDIR)/share/OGAgent
BINDIR := $(DESTDIR)/bin
SBINDIR = $(DESTDIR)/sbin
#APPSDIR := $(DESTDIR)/usr/share/applications
CFGDIR := $(DESTDIR)/etc/ogagent
INITDIR := /Library/LaunchDaemons
#XDGAUTOSTARTDIR := $(DESTDIR)/etc/xdg/autostart
#KDEAUTOSTARTDIR := $(DESTDIR)/usr/share/autostart
PYC := $(shell find $(SOURCEDIR) -name '*.py[co]')
CACHES := $(shell find $(SOURCEDIR) -name '__pycache__')
clean:
rm -rf $(PYC) $(CACHES)
install:
dependencies
install-ogagent
dependencies:
easy_install pip # Si no existe pip.
# comprobar versión de six, descargar e instalar con easy_install.
easy_install netifaces
install-ogagent:
mkdir -p $(LIBDIR)
mkdir -p $(BINDIR)
mkdir -p $(SBINDIR)
mkdir -p $(CFGDIR)
mkdir -p $(LIBDIR)/img
# Cleans up .pyc and cache folders
rm -f $(PYC) $(CACHES)
cp -r $(SOURCEDIR)/opengnsys $(LIBDIR)/opengnsys
cp -r $(SOURCEDIR)/cfg $(LIBDIR)/cfg
cp $(SOURCEDIR)/img/oga.png $(LIBDIR)/img
cp $(SOURCEDIR)/OGAgentUser.py $(LIBDIR)
# QT Dialogs & resources
#cp $(SOURCEDIR)/*_ui.py $(LIBDIR)
#cp $(SOURCEDIR)/OGAgent_rc.py $(LIBDIR)
# Autostart elements for gnome/kde
#cp desktop/OGAgentTool.desktop $(XDGAUTOSTARTDIR)
#cp desktop/OGAgentTool.desktop $(KDEAUTOSTARTDIR)
# scripts
cp scripts/ogagent $(BINDIR)
cp scripts/OGAgentTool-startup $(BINDIR)
cp scripts/OGAgentTool $(BINDIR)
cp scripts/es.opengnsys.ogagent.plist $(INITDIR)
# Fix permissions
chmod 755 $(BINDIR)/ogagent
chmod 755 $(BINDIR)/OGAgentTool-startup
chmod 755 $(LIBDIR)/OGAgentUser.py
chmod 600 $(LIBDIR)/cfg/ogagent.cfg
ln -fs $(LIBDIR)/cfg/ogagent.cfg $(CFGDIR)
ln -fs $(LIBDIR)/cfg/ogclient.cfg $(CFGDIR)
uninstall:
rm -rf $(LIBDIR)
rm -f $(BINDIR)/ogagent $(BINDIR)/OGAgent-Tool*
rm -rf $(CFGDIR)

84
macos/build-pkg.sh 100755
View File

@ -0,0 +1,84 @@
#!/bin/bash
# Create macOS installation packages.
# Based on bomutils tutorail: http://bomutils.dyndns.org/tutorial.html
VERSION=1.1.0
AUTHOR="OpenGnsys Project"
# Create directories.
mkdir build && cd build
mkdir -p flat/base.pkg flat/Resources/en.lproj
mkdir -p root/Applications
# Copy application and script files.
cp -r ../../src root/Applications/OGAgent.app
cp -r ../scripts .
# Create plist file.
cat << EOT > root/Applications/OGAgent.app/OGAgent.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>BuildAliasOf</key>
<string>OGAgent</string>
<key>BuildVersion</key>
<value>$VERSION</value>
<author>$AUTHOR</author>
</dict>
</plist>
EOT
# Add files in the base package.
( cd root && find . | cpio -o --format odc --owner 0:80 | gzip -c ) > flat/base.pkg/Payload
# Create PackageInfo file.
cat << EOT > flat/base.pkg/PackageInfo
<pkg-info format-version="2" identifier="es.opengnsys.ogagent.base.pkg" version="$VERSION" install-location="/" auth="root">
<payload installKBytes="$(du -k -s root)" numberOfFiles="$(find root | wc -l)"/>
<scripts>
<postinstall file="./postinstall"/>
</scripts>
<bundle-version>
<bundle id="es.opengnsys.ogagent" CFBundleIdentifier="es.opengnsys.ogagent" path="./Applications/OGAgent.app" CFBundleVersion="$VERSION"/>
</bundle-version>
</pkg-info>
EOT
# Compress the scripts folder.
( cd scripts && find . | cpio -o --format odc --owner 0:80 | gzip -c ) > flat/base.pkg/Scripts
# Create BOM file.
mkbom -u 0 -g 80 root flat/base.pkg/Bom
# Create Distribution file.
cat << EOT > flat/Distribution
<?xml version="1.0" encoding="utf-8"?>
<installer-script minSpecVersion="1.000000" authoringTool="com.apple.PackageMaker" authoringToolVersion="3.0.3" authoringToolBuild="174">
<title>OGAgent 1.1.0</title>
<options customize="never" allow-external-scripts="no"/>
<domains enable_anywhere="true"/>
<installation-check script="pm_install_check();"/>
<script>function pm_install_check() {
if(!(system.compareVersions(system.version.ProductVersion,'10.5') >= 0)) {
my.result.title = 'Failure';
my.result.message = 'You need at least Mac OS X 10.5 to install OGAgent.';
my.result.type = 'Fatal';
return false;
}
return true;
}
</script>
<choices-outline>
<line choice="choice1"/>
</choices-outline>
<choice id="choice1" title="base">
<pkg-ref id="es.opengnsys.ogagent.base.pkg"/>
</choice>
<pkg-ref id="es.opengnsys.ogagent.base.pkg" installKBytes="$(du -k -s root)" version="$VERSION" auth="Root">#base.pkg</pkg-ref>
</installer-script>
EOT
# Create Xar application archive.
( cd flat && xar --compression none -cf "../../../OGAgent-$VERSION Installer.pkg" * )

View File

@ -1,6 +0,0 @@
#!/bin/sh
FOLDER=/usr/local/share/OGAgent
cd $FOLDER
python OGAgentUser.py $@

View File

@ -1,10 +0,0 @@
#!/bin/sh
# Simple hack to wait for systray to be present
# Exec tool if not already runned by session manager
ps -ef | grep "$USER" | grep -v grep | grep -v OGAgentTool-startup | grep 'OGAgentTool' -q
# If not already running
if [ $? -eq 1 ]; then
sleep 5
exec /usr/local/bin/OGAgentTool
fi

2
macos/scripts/ogagent 100644 → 100755
View File

@ -1,6 +1,6 @@
#!/bin/sh
FOLDER=/usr/local/share/OGAgent
FOLDER=/Applications/OGAgent.app
cd $FOLDER
python -m opengnsys.linux.OGAgentService $@

View File

@ -0,0 +1,19 @@
#!/usr/bin/env sh
# Directories
SRCDIR=$(dirname "$0")
BINDIR=/usr/local/bin
INITDIR=/Library/LaunchDaemons
# Dependencies:
#easy_install pip # Si no existe pip.
# comprobar versión de six, descargar e instalar con easy_install.
#easy_install netifaces
# Copi files.
cp $SRCDIR/ogagent $BINDIR
cp $SRCDIR/es.opengnsys.ogagent.plist $INITDIR
# Show post-install message.
osascript -e 'display notification "You must update Python Six from sourece and install netifaces module." with title "OGAgent Installer'