For discussion of Alpine Linux development and developer support

3 3

[alpine-devel] [PATCH] testing/bcfg2 new package

Cameron Banta
Details
Message ID
<1288805368-2382-1-git-send-email-cbanta@gmail.com>
Sender timestamp
1288805368
DKIM signature
missing
Download raw message
Patch: +121 -0
---
 testing/bcfg2/APK.py             |   58 ++++++++++++++++++++++++++++++++++++++
 testing/bcfg2/APKBUILD           |   40 ++++++++++++++++++++++++++
 testing/bcfg2/bcfg2-server.initd |   23 +++++++++++++++
 3 files changed, 121 insertions(+), 0 deletions(-)
 create mode 100644 testing/bcfg2/APK.py
 create mode 100644 testing/bcfg2/APKBUILD
 create mode 100644 testing/bcfg2/bcfg2-server.initd

diff --git a/testing/bcfg2/APK.py b/testing/bcfg2/APK.py
new file mode 100644
index 0000000..9b28d52
--- /dev/null
+++ b/testing/bcfg2/APK.py
@@ -0,0 +1,58 @@
+"""This provides Bcfg2 support for alpinelinux APK packages."""
+__revision__ = '$Revision$'
+
+import Bcfg2.Client.Tools
+
+class APK(Bcfg2.Client.Tools.PkgTool):
+    """apk package support."""
+    name = 'APK'
+    __execs__ = ["/sbin/apk"]
+    __handles__ = [('Package', 'apk')]
+    __req__ = {'Package': ['name', 'version']}
+    pkgtype = 'apk'
+    pkgtool = ("/sbin/apk add %s", ("%s", ["name"]))
+
+    def __init__(self, logger, setup, config):
+        Bcfg2.Client.Tools.PkgTool.__init__(self, logger, setup, config)
+        self.installed = {}
+        self.RefreshPackages()
+
+    def RefreshPackages(self):
+        """Refresh memory hashes of packages."""
+        names = self.cmd.run("/sbin/apk info")[1]
+        nameversions = self.cmd.run("/sbin/apk info -v")[1]
+        for pkg in zip(names, nameversions):
+                pkgname = pkg[0]
+                version = pkg[1][len(pkgname)+1:]
+                self.logger.debug(" pkgname: %s\n version: %s" % (pkgname, version))
+                self.installed[pkgname] = version
+
+    def VerifyPackage(self, entry, modlist):
+        """Verify Package status for entry."""
+        if not 'version' in entry.attrib:
+            self.logger.info("Cannot verify unversioned package %s" %
+               (entry.attrib['name']))
+            return False
+
+        if entry.attrib['name'] in self.installed:
+            if entry.attrib['version'] == 'auto' or self.installed[entry.attrib['name']] == entry.attrib['version']:
+                #if not self.setup['quick'] and \
+                #                entry.get('verify', 'true') == 'true':
+                #FIXME: We should be able to check this once
+                #       http://trac.macports.org/ticket/15709 is implemented
+                return True
+            else:
+		self.loggger.info( " pkg %s at version %s, not %s" % (entry.attrib['name'],self.installed[entry.attrib['name']],entry.attrib['version']) )
+                entry.set('current_version', self.installed[entry.get('name')])
+                return False
+        entry.set('current_exists', 'false')
+        return False
+
+    def RemovePackages(self, packages):
+        """Remove extra packages."""
+        names = [pkg.get('name') for pkg in packages]
+        self.logger.info("Removing packages: %s" % " ".join(names))
+        self.cmd.run("/sbin/apk del %s" % \
+                     " ".join(names))
+        self.RefreshPackages()
+        self.extra = self.FindExtraPackages()
diff --git a/testing/bcfg2/APKBUILD b/testing/bcfg2/APKBUILD
new file mode 100644
index 0000000..7f45976
--- /dev/null
+++ b/testing/bcfg2/APKBUILD
@@ -0,0 +1,40 @@
+# Contributor: Cameron Banta <cbanta@gmail.com>
+# Maintainer: Cameron Banta <cbanta@gmail.com>
+pkgname=bcfg2
+pkgver=1.1.1
+pkgrel=0
+pkgdesc="configuration management tool"
+url="trac.mcs.anl.gov/project/bcfg2"
+license="Custom"
+depends="python"
+makedepends="python-dev"
+install=
+subpackages="$pkgname-doc $pkgname-server"
+source="ftp://ftp.mcs.anl.gov/pub/bcfg/$pkgname-$pkgver.tar.gz
+	bcfg2-server.initd
+	APK.py"
+
+#no build needed - pure python
+
+package() {
+	cd "$srcdir"/$pkgname-$pkgver
+	cp "$srcdir"/APK.py src/lib/Client/Tools/
+	python setup.py bdist_dumb --keep-temp --bdist-dir "$pkgdir"
+
+	install -m644 -D COPYRIGHT "$pkgdir"/usr/share/licenses/$pkgname/COPYRIGHT
+}
+
+server() {
+	depends="python bcfg2 py-lxml openssl"
+
+	mkdir -p "$subpkgdir"/usr/bin
+	mv "$pkgdir"/usr/bin/bcfg2-* "$subpkgdir"/usr/bin/
+	mkdir -p "$subpkgdir"/usr/share
+	mv "$pkgdir"/usr/share/bcfg2 "$subpkgdir"/usr/share/
+	install -m755 -D bcfg2-server.initd "$subpkgdir"/etc/init.d/$subpkgname
+}
+
+
+md5sums="f8889d629245ecf67994469ed78fbfeb  bcfg2-1.1.1.tar.gz
+9a13baa6f40267ff9dbec574967c5068  bcfg2-server.initd
+2acc7c5a8a031a3cb25ab3955d8d1fde  APK.py"
diff --git a/testing/bcfg2/bcfg2-server.initd b/testing/bcfg2/bcfg2-server.initd
new file mode 100644
index 0000000..5168f75
--- /dev/null
+++ b/testing/bcfg2/bcfg2-server.initd
@@ -0,0 +1,23 @@
+#!/sbin/runscript
+#
+# bcfgd - bcfg configuration daemon
+#
+# 
+
+depend () {
+	need net
+}
+
+start () {
+	ebegin "Starting bcfg2-server"
+	start-stop-daemon --start --quiet --pidfile /var/run/bcfg2-server.pid \
+		--startas /usr/bin/bcfg2-server -- -D /var/run/bcfg2-server.pid
+	eend $? "Failed to start bcfg2-server"
+}
+
+stop () {
+	ebegin "Stopping bcfg2-server"
+	start-stop-daemon --stop --quiet --pidfile /var/run/bcfg2-server.pid \
+		--signal INT
+	eend $? "Failed to stop bcfg2-server"
+}
-- 
1.7.3.2



---
Unsubscribe:  alpine-devel+unsubscribe@lists.alpinelinux.org
Help:         alpine-devel+help@lists.alpinelinux.org
---
Nathan Angelacos
Details
Message ID
<4CE41A38.3080704@nothome.org>
In-Reply-To
<AANLkTinUDRtgaJ=1sm1SXxx+f3tee7VxCVUrQLBwQQAQ@mail.gmail.com> (view parent)
Sender timestamp
1290017336
DKIM signature
missing
Download raw message
Hey qnx4ever,

On 11/17/10 09:53, qnx4ever wrote:
> Hello Everyone !
> I would like to be in the loop of the latest developments and trends
> with Alpine Linux, but I do not use those daily patches being
> distributed. Is there any way we can have a separate distribution
> group for compiling mosters ;) Or should I move to alpine-lamers
> distribution list ;) ?

We are moving our list server to new hardware soon, we'll set up a 
Alpine-Users mailing list when we do.  Nobody who uses alpine is a lamer. :)

ETA is likely 3 weeks.


Thanks!



---
Unsubscribe:  alpine-devel+unsubscribe@lists.alpinelinux.org
Help:         alpine-devel+help@lists.alpinelinux.org
---
Natanael Copa
Details
Message ID
<20101117191633.4857e628@alpinelinux.org>
In-Reply-To
<1288805368-2382-1-git-send-email-cbanta@gmail.com> (view parent)
Sender timestamp
1290021393
DKIM signature
missing
Download raw message
On Wed,  3 Nov 2010 17:29:28 +0000
Cameron Banta <cbanta@gmail.com> wrote:

> ---
>  testing/bcfg2/APK.py             |   58
> ++++++++++++++++++++++++++++++++++++++
> testing/bcfg2/APKBUILD           |   40 ++++++++++++++++++++++++++
> testing/bcfg2/bcfg2-server.initd |   23 +++++++++++++++ 3 files
> changed, 121 insertions(+), 0 deletions(-) create mode 100644
> testing/bcfg2/APK.py create mode 100644 testing/bcfg2/APKBUILD
>  create mode 100644 testing/bcfg2/bcfg2-server.initd
...
> +pkgdesc="configuration management tool"
> +url="trac.mcs.anl.gov/project/bcfg2"

I updated the url above to something that works and applied.

Thanks!

-nc


---
Unsubscribe:  alpine-devel+unsubscribe@lists.alpinelinux.org
Help:         alpine-devel+help@lists.alpinelinux.org
---
qnx4ever
Details
Message ID
<AANLkTinUDRtgaJ=1sm1SXxx+f3tee7VxCVUrQLBwQQAQ@mail.gmail.com>
In-Reply-To
<1288805368-2382-1-git-send-email-cbanta@gmail.com> (view parent)
Sender timestamp
1290016409
DKIM signature
missing
Download raw message
Hello Everyone !
I would like to be in the loop of the latest developments and trends
with Alpine Linux, but I do not use those daily patches being
distributed. Is there any way we can have a separate distribution
group for compiling mosters ;) Or should I move to alpine-lamers
distribution list ;) ?

On Wed, Nov 3, 2010 at 8:29 PM, Cameron Banta <cbanta@gmail.com> wrote:
> ---
>  testing/bcfg2/APK.py             |   58 ++++++++++++++++++++++++++++++++++++++
>  testing/bcfg2/APKBUILD           |   40 ++++++++++++++++++++++++++
>  testing/bcfg2/bcfg2-server.initd |   23 +++++++++++++++
>  3 files changed, 121 insertions(+), 0 deletions(-)
>  create mode 100644 testing/bcfg2/APK.py
>  create mode 100644 testing/bcfg2/APKBUILD
>  create mode 100644 testing/bcfg2/bcfg2-server.initd
>
> diff --git a/testing/bcfg2/APK.py b/testing/bcfg2/APK.py
> new file mode 100644
> index 0000000..9b28d52
> --- /dev/null
> +++ b/testing/bcfg2/APK.py
> @@ -0,0 +1,58 @@
> +"""This provides Bcfg2 support for alpinelinux APK packages."""
> +__revision__ = '$Revision$'
> +
> +import Bcfg2.Client.Tools
> +
> +class APK(Bcfg2.Client.Tools.PkgTool):
> +    """apk package support."""
> +    name = 'APK'
> +    __execs__ = ["/sbin/apk"]
> +    __handles__ = [('Package', 'apk')]
> +    __req__ = {'Package': ['name', 'version']}
> +    pkgtype = 'apk'
> +    pkgtool = ("/sbin/apk add %s", ("%s", ["name"]))
> +
> +    def __init__(self, logger, setup, config):
> +        Bcfg2.Client.Tools.PkgTool.__init__(self, logger, setup, config)
> +        self.installed = {}
> +        self.RefreshPackages()
> +
> +    def RefreshPackages(self):
> +        """Refresh memory hashes of packages."""
> +        names = self.cmd.run("/sbin/apk info")[1]
> +        nameversions = self.cmd.run("/sbin/apk info -v")[1]
> +        for pkg in zip(names, nameversions):
> +                pkgname = pkg[0]
> +                version = pkg[1][len(pkgname)+1:]
> +                self.logger.debug(" pkgname: %s\n version: %s" % (pkgname, version))
> +                self.installed[pkgname] = version
> +
> +    def VerifyPackage(self, entry, modlist):
> +        """Verify Package status for entry."""
> +        if not 'version' in entry.attrib:
> +            self.logger.info("Cannot verify unversioned package %s" %
> +               (entry.attrib['name']))
> +            return False
> +
> +        if entry.attrib['name'] in self.installed:
> +            if entry.attrib['version'] == 'auto' or self.installed[entry.attrib['name']] == entry.attrib['version']:
> +                #if not self.setup['quick'] and \
> +                #                entry.get('verify', 'true') == 'true':
> +                #FIXME: We should be able to check this once
> +                #       http://trac.macports.org/ticket/15709 is implemented
> +                return True
> +            else:
> +               self.loggger.info( " pkg %s at version %s, not %s" % (entry.attrib['name'],self.installed[entry.attrib['name']],entry.attrib['version']) )
> +                entry.set('current_version', self.installed[entry.get('name')])
> +                return False
> +        entry.set('current_exists', 'false')
> +        return False
> +
> +    def RemovePackages(self, packages):
> +        """Remove extra packages."""
> +        names = [pkg.get('name') for pkg in packages]
> +        self.logger.info("Removing packages: %s" % " ".join(names))
> +        self.cmd.run("/sbin/apk del %s" % \
> +                     " ".join(names))
> +        self.RefreshPackages()
> +        self.extra = self.FindExtraPackages()
> diff --git a/testing/bcfg2/APKBUILD b/testing/bcfg2/APKBUILD
> new file mode 100644
> index 0000000..7f45976
> --- /dev/null
> +++ b/testing/bcfg2/APKBUILD
> @@ -0,0 +1,40 @@
> +# Contributor: Cameron Banta <cbanta@gmail.com>
> +# Maintainer: Cameron Banta <cbanta@gmail.com>
> +pkgname=bcfg2
> +pkgver=1.1.1
> +pkgrel=0
> +pkgdesc="configuration management tool"
> +url="trac.mcs.anl.gov/project/bcfg2"
> +license="Custom"
> +depends="python"
> +makedepends="python-dev"
> +install=
> +subpackages="$pkgname-doc $pkgname-server"
> +source="ftp://ftp.mcs.anl.gov/pub/bcfg/$pkgname-$pkgver.tar.gz
> +       bcfg2-server.initd
> +       APK.py"
> +
> +#no build needed - pure python
> +
> +package() {
> +       cd "$srcdir"/$pkgname-$pkgver
> +       cp "$srcdir"/APK.py src/lib/Client/Tools/
> +       python setup.py bdist_dumb --keep-temp --bdist-dir "$pkgdir"
> +
> +       install -m644 -D COPYRIGHT "$pkgdir"/usr/share/licenses/$pkgname/COPYRIGHT
> +}
> +
> +server() {
> +       depends="python bcfg2 py-lxml openssl"
> +
> +       mkdir -p "$subpkgdir"/usr/bin
> +       mv "$pkgdir"/usr/bin/bcfg2-* "$subpkgdir"/usr/bin/
> +       mkdir -p "$subpkgdir"/usr/share
> +       mv "$pkgdir"/usr/share/bcfg2 "$subpkgdir"/usr/share/
> +       install -m755 -D bcfg2-server.initd "$subpkgdir"/etc/init.d/$subpkgname
> +}
> +
> +
> +md5sums="f8889d629245ecf67994469ed78fbfeb  bcfg2-1.1.1.tar.gz
> +9a13baa6f40267ff9dbec574967c5068  bcfg2-server.initd
> +2acc7c5a8a031a3cb25ab3955d8d1fde  APK.py"
> diff --git a/testing/bcfg2/bcfg2-server.initd b/testing/bcfg2/bcfg2-server.initd
> new file mode 100644
> index 0000000..5168f75
> --- /dev/null
> +++ b/testing/bcfg2/bcfg2-server.initd
> @@ -0,0 +1,23 @@
> +#!/sbin/runscript
> +#
> +# bcfgd - bcfg configuration daemon
> +#
> +#
> +
> +depend () {
> +       need net
> +}
> +
> +start () {
> +       ebegin "Starting bcfg2-server"
> +       start-stop-daemon --start --quiet --pidfile /var/run/bcfg2-server.pid \
> +               --startas /usr/bin/bcfg2-server -- -D /var/run/bcfg2-server.pid
> +       eend $? "Failed to start bcfg2-server"
> +}
> +
> +stop () {
> +       ebegin "Stopping bcfg2-server"
> +       start-stop-daemon --stop --quiet --pidfile /var/run/bcfg2-server.pid \
> +               --signal INT
> +       eend $? "Failed to stop bcfg2-server"
> +}
> --
> 1.7.3.2
>
>
>
> ---
> Unsubscribe:  alpine-devel+unsubscribe@lists.alpinelinux.org
> Help:         alpine-devel+help@lists.alpinelinux.org
> ---
>
>


---
Unsubscribe:  alpine-devel+unsubscribe@lists.alpinelinux.org
Help:         alpine-devel+help@lists.alpinelinux.org
---