Subject: [alpine-devel] mlocate 0.26 / package group

From: "Leslie P. Polzer | PORT ZERO" <[email-masked]>
Date: Fri, 18 Oct 2013 14:07:40 +0200

I've picked up the old mlocate package in testing, bumped
it to 0.26 and added subpackages and some more amendments.

For security reasons mlocate should use its own group for
its setgid binary "locate" and its datadir.

Putting chgrp calls into the post-install script is frowned
upon, but the intended group ("locate") does not exist at
build time. Other packages like bind seem to have their groups
defined in /etc/group in the base install.

How should this be handled? I did notice that there is a
group "slocate" in the default install. Should this be used?

  Leslie

-- 
Dipl.Ing.(BA) Leslie P. Polzer | CTO - PORT ZERO
UG (haftungsbeschränkt)
Softwareentwicklung & IT Engineering
Adalbertstraße 7/8
10999 Berlin
Tel.: +49 (0)30 - 69 200 907 - 0
Fax: +49 (0)30 - 69 200 907 - 9
http://www.port-zero.com

---
Unsubscribe:  [email-masked]
Help:         [email-masked]
---

---

From: Bartłomiej Piotrowski <[email-masked]>
Date: Fri, 18 Oct 2013 14:50:56 +0200

-- 
Bartłomiej Piotrowski
http://bpiotrowski.pl/

---

From: Natanael Copa <[email-masked]>
Date: Fri, 18 Oct 2013 15:34:01 +0200

On Fri, 18 Oct 2013 14:07:40 +0200

> group "slocate" in the default install. Should this be used?

I suppose we could rename slocate to 'locate' in the base install which
sounds like a more sensible group name.

In any case, since the group has not been there from before, the
pre-install script should try create the group and ignore errors if it
exists.

Since the dir should be created and set correct permissions by apk the
group needs to exist build time (so we can set permissions in tar
archive)

to do that, add this to the APKBUILD:

pkggroups="locate"

and during package:

package() {
	make install  DESTDIR="$pkgdir" blabla...
	chgrp locate "$pkgdir"/var/lib/the/databasedir
	chmod g+s (or something) "$pkgdir"/var/blah
}
	
The point is that you set ownership and permissions directly from
package().

Then you can verify that it was set correctly with:
  tar -ztvf mlocate-<version>.apk

Thanks!

-nc

---

---

From: "Leslie P. Polzer | PORT ZERO" <[email-masked]>
Date: Sun, 20 Oct 2013 19:20:00 +0200

Attached is the new testing/mlocate APKBUILD commit. I'd be grateful for
any feedback.

Thanks to both of you for the hint on pkggroups.

> sounds like a more sensible group name.

The package uses 'locate' now, as it did before. I agree it would be
sensible to do the rename in the base install.

libc-dev is hardly ever mentioned in makedepends in the aports tree.
Is it always assumed to be available?

The Wiki doesn't seem to mention a preferred indent style for build
files. I've found a mail from Natanael saying he prefers tabs 8 spaces
wide, so that's what I did in the mlocate APKBUILD.

mlocate -- and probably a lot of other packages -- require sed for
adjusting the build process. It is part of busybox in the base install,
but I'm not sure how to handle this properly with the current dependency
system. One possible solution would be having a makedepends on 'sed'
and then have busybox provide this *if* it is compiled with the sed
binary. Difficulties might arise if some sed functionality is required
that doesn't work with busybox sed. Has this topic been discussed before?

I've also learned from the Wiki that "abuild -r" is a very convenient command,
but the built-in help is quite cryptic on this parameter:

> -r  Install missing dependencies from system repository (using sudo)

Which is certainly part of what it does, but far from its full behavior.

Just from reading the documentation I still don't have a clear understanding
how the abuild switches relate to the execution of abuild commands.

  Leslie

>From b994c9d5cb56ff153807755c8005395911f95ce9 Mon Sep 17 00:00:00 2001
From: "Leslie P. Polzer" <[email-masked]>
Date: Sun, 20 Oct 2013 18:58:17 +0200
Subject: [PATCH] Update mlocate to 0.26 and amend its APKBUILD.

---
 testing/mlocate/APKBUILD | 67 ++++++++++++++++++++++++++++++++----------------
 1 file changed, 45 insertions(+), 22 deletions(-)

diff --git a/testing/mlocate/APKBUILD b/testing/mlocate/APKBUILD
index f23c465..af7ff0c 100644
--- a/testing/mlocate/APKBUILD
+++ b/testing/mlocate/APKBUILD
@@ -1,48 +1,71 @@
+# Contributor: Bart��omiej Piotrowski <[email-masked]>
+# Contributor: Leslie P. Polzer <[email-masked]>
 # Maintainer: Bart��omiej Piotrowski <[email-masked]>
 
 pkgname=mlocate
-pkgver=0.25
+pkgver=0.26
 pkgrel=0
-pkgdesc='An utility to index and quickly search for files by name'
+pkgdesc='A utility to index and quickly search for files by name'
 url='https://fedorahosted.org/mlocate/'
 arch='all'
 license='GPL'
+pkggroups='locate'
 install="$pkgname.pre-install"
-makedepends='uclibc-dev sed'
-subpackages="$pkgname-doc"
+makedepends='libc-dev'
+subpackages="$pkgname-doc $pkgname-lang"
 source="https://fedorahosted.org/releases/m/l/mlocate/mlocate-$pkgver.tar.xz
         updatedb.conf
         updatedb.cron.daily"
 
+_builddir="$srcdir"/$pkgname-$pkgver
+
+prepare() {
+	cd "$_builddir"
+	sed -i '/^groupname /s/mlocate/locate/' Makefile.in
+}
+
 build() {
-    cd $srcdir/$pkgname-$pkgver
+	cd "$_builddir"
+	./configure --prefix=/usr \
+                    --sysconfdir=/etc \
+                    --localstatedir=/var/lib
+	make || return 1
+}
 
-    sed -i '/^groupname /s/mlocate/locate/' Makefile.in
-    ./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var/lib
-    make
+doc() {
+	rm -rf "$subpkgdir"/usr/share/man
+	mkdir -p "$subpkgdir"/usr/share/man || return 1
+	mv "$pkgdir"/usr/share/man/man* "$subpkgdir"/usr/share/man/ \
+		|| return 1
+	rmdir "$pkgdir"/usr/share/man
 }
 
-check() {
-    cd $srcdir/$pkgname-$pkgver
-    make check
+lang() {
+	rm -rf "$subpkgdir"/usr/share/locale
+	mkdir -p "$subpkgdir"/usr/share/locale || return 1
+	mv "$pkgdir"/usr/share/locale/* "$subpkgdir"/usr/share/locale \
+		|| return 1
+	rmdir "$pkgdir"/usr/share/locale
 }
 
 package() {
-    cd $srcdir/$pkgname-$pkgver
+	cd "$_builddir"
 
-    make DESTDIR=$pkgdir install
+	make DESTDIR="$pkgdir" install
 
-    ln -s locate $pkgdir/usr/bin/slocate
-    chgrp locate $pkgdir/usr/bin/locate
-    chmod 2755 $pkgdir/usr/bin/locate
+	ln -s locate "$pkgdir"/usr/bin/slocate
 
-    install -dm755 $pkgdir/var/lib
-    install -dm750 -g locate $pkgdir/var/lib/locate
+	install -dm755 "$pkgdir"/var/lib
 
-    install -Dm644 ${srcdir}/updatedb.conf $pkgdir/etc/updatedb.conf
-    install -Dm744 ${srcdir}/updatedb.cron.daily $pkgdir/etc/cron.daily/updatedb
+	install -Dm644 "$srcdir"/updatedb.conf "$pkgdir"/etc/updatedb.conf
+	install -Dm744 "$srcdir"/updatedb.cron.daily "$pkgdir"/etc/periodic/daily/updatedb
 }
-
-md5sums="c6d043b170613b0e327a815b497f680a  mlocate-0.25.tar.xz
+md5sums="539e6f86bf387358aa2b14d5f880e49a  mlocate-0.26.tar.xz
 465315bfa3380a23fae9a383270cb2ec  updatedb.conf
 cde5da81bebad2de556ef2e43d895e13  updatedb.cron.daily"
+sha256sums="3063df79fe198fb9618e180c54baf3105b33d88fe602ff2d8570aaf944f1263e  mlocate-0.26.tar.xz
+2523ec44fc74eb112a21671aca7cd3f5967e349c6017f5c34591c82f85490e81  updatedb.conf
+fe70ce6b8771bc750d5200ab4cc5bd97b579eeec92f1939f5d777614a0736c3e  updatedb.cron.daily"
+sha512sums="b1207047e30a551cba39e70812439b554def567ebe9b8b81fed6f26435bb575beafe4875a21cd72876eadd85da4e7bfc942eb28b17c430b537c351690364837f  mlocate-0.26.tar.xz
+663ebf09348458a3c82ac83bf77de9d38a214bd91c73385b2ea7fb7eda5beaaa7ad1d7c66a8a017ef6a0d5295ff1778bedab9be60d9b3a5ac3fefe5f1593a5f5  updatedb.conf
+60551f1574a31650bc665901cac418366ba26dc8514fb82ca55c75d29a9617ce05bc77b2a14c724cd49c8375d8ad5c3e9ba4df4210ce1b6b37bb3a244dcdc84c  updatedb.cron.daily"
-- 
1.8.4

---

From: "Leslie P. Polzer | PORT ZERO" <[email-masked]>
Date: Tue, 22 Oct 2013 15:34:08 +0200

> how the abuild switches relate to the execution of abuild commands.

Never mind that, I was a bit confused about it.

  Leslie

---

---

From: "Leslie P. Polzer | PORT ZERO" <[email-masked]>
Date: Wed, 23 Oct 2013 21:18:57 +0200

> Attached is the new testing/mlocate APKBUILD commit. I'd be grateful for

I noticed a small omission in makedepends. Patch for this attached, designed
to go on top of the first one.

  Leslie

>From 10842c27f666463a68192d8e883038fd50715f84 Mon Sep 17 00:00:00 2001
From: "Leslie P. Polzer" <[email-masked]>
Date: Wed, 23 Oct 2013 21:15:35 +0200
Subject: [PATCH] testing/mlocate: add gettext-dev to makedepends.

mlocate-lang needs it to build.
---
 testing/mlocate/APKBUILD | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/testing/mlocate/APKBUILD b/testing/mlocate/APKBUILD
index af7ff0c..aca75ab 100644
--- a/testing/mlocate/APKBUILD
+++ b/testing/mlocate/APKBUILD
@@ -11,7 +11,7 @@ arch='all'
 license='GPL'
 pkggroups='locate'
 install="$pkgname.pre-install"
-makedepends='libc-dev'
+makedepends='libc-dev gettext-dev'
 subpackages="$pkgname-doc $pkgname-lang"
 source="https://fedorahosted.org/releases/m/l/mlocate/mlocate-$pkgver.tar.xz
         updatedb.conf
-- 
1.8.4.1

---

From: Natanael Copa <[email-masked]>
Date: Mon, 28 Oct 2013 21:20:18 +0100

On Wed, 23 Oct 2013 21:18:57 +0200

> to go on top of the first one.

i squashed it into the previous commit and did som cleanups.

I removed gettext-dev dep and -lang subpackage (so we dont pull in
gettext and save space)

I removed the doc() and lang() subpackages. abuild has defaults for
-doc, -dev and -lang subpackages.

I removed libc-dev dependency. Its a part of build-base and is assumed
to always be there. (same with gnu make, gcc, patch etc)

Thanks!

-nc

---

---

From: "Leslie P. Polzer | PORT ZERO" <[email-masked]>
Date: Tue, 29 Oct 2013 12:56:11 +0100

> i squashed it into the previous commit and did som cleanups.

Thanks, I appreciate it!

> I removed gettext-dev dep and -lang subpackage (so we dont pull in

I don't get this. How will the base package take up more space if
we generate a separate lang package?

> to always be there. (same with gnu make, gcc, patch etc)

Good to know. I will try to make these clearer in the Wiki.

   Leslie

---