Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 513158 - =dev-libs/geoip-1.6.0-r2 - /usr/share/GeoIP population and geoipupdate.sh woes
Summary: =dev-libs/geoip-1.6.0-r2 - /usr/share/GeoIP population and geoipupdate.sh woes
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Library (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo Netmon project
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-06-13 22:10 UTC by Alex Turbov
Modified: 2014-06-14 21:29 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments
fixes for geoip-1.6.0-r2.ebuild (geoip-1.6.0-r2-to-r3.patch,648 bytes, patch)
2014-06-13 22:12 UTC, Alex Turbov
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Alex Turbov 2014-06-13 22:10:48 UTC
The geoip-1.6.0-r2.ebuild is dramatically wrong!

First of all, doesn't create /usr/share/GeoIP/, so action in pkg_postinst() (attempt to download data files to that dir) just do nothing (siltently), cuz mentioned directory is not exists. It has been fixed in my ebuild (will be attached) w/ keepdir call.

The second flaw laid in pkg_postrm() action -- even if mentioned dir will be created before and filled w/ data files, it will be *unconditionally* removed here! It doesn't recognize if a package was reinstalled/upgraded or just completely removed (only in latter case it must (really?) remove data files!)

And finally -- provided ${FILESDIR}/geoipupdate-r3.sh do not respect ${ROOT}. Being running from pkg_postinst() action it may violate 9.1.11 of current PMS-5!


Reproducible: Always

Steps to Reproduce:
1. (re)install dev-libs/geoip
2. check presence of /usr/share/GeoIP/
Actual Results:  
the directory do not exist

Expected Results:  
directory w/ few *.dat files downloaded
Comment 1 Alex Turbov 2014-06-13 22:12:22 UTC
Created attachment 378834 [details, diff]
fixes for geoip-1.6.0-r2.ebuild
Comment 2 Jeroen Roovers (RETIRED) gentoo-dev 2014-06-14 00:17:26 UTC
Comment on attachment 378834 [details, diff]
fixes for geoip-1.6.0-r2.ebuild

>@@ -39,12 +39,16 @@
> 	prune_libtool_files
> 
> 	newsbin "${FILESDIR}"/geoipupdate-r3.sh geoipupdate.sh
>+	keepdir "${ROOT}/usr/share/GeoIP"

No need for ROOT there - keepdir should take care of that.

>-pkg_postrm() {
>-	rm -r "${ROOT}/usr/share/GeoIP/"
>+pkg_prerm() {
>+	# ATTENTION Check if this is uninstall action (i.e. not just a reinstall/upgrade)
>+	if [ -z "${REPLACED_BY_VERSION}" ]; then
>+	    rm -r "${ROOT}"/usr/share/GeoIP/*.dat
>+	fi
> }

Surely there must be an easier way.
Comment 3 Jeroen Roovers (RETIRED) gentoo-dev 2014-06-14 00:22:54 UTC
(In reply to Alex Turbov from comment #0)
> The geoip-1.6.0-r2.ebuild is dramatically wrong!

Dramatically! Could you keep this technical please?

> First of all, doesn't create /usr/share/GeoIP/

Fixed.

> it will be *unconditionally* removed here!

Fixed.

> And finally -- provided ${FILESDIR}/geoipupdate-r3.sh do not respect
> ${ROOT}. Being running from pkg_postinst() action it may violate 9.1.11 of
> current PMS-5!

You didn't show a patch for that one. What is the solution?
Comment 4 Alex Turbov 2014-06-14 00:25:22 UTC
(In reply to Jeroen Roovers from comment #2)
> >-pkg_postrm() {
> >-	rm -r "${ROOT}/usr/share/GeoIP/"
> >+pkg_prerm() {
> >+	# ATTENTION Check if this is uninstall action (i.e. not just a reinstall/upgrade)
> >+	if [ -z "${REPLACED_BY_VERSION}" ]; then
> >+	    rm -r "${ROOT}"/usr/share/GeoIP/*.dat
> >+	fi
> > }
> 
> Surely there must be an easier way.

what's "hard" in this way? REPLACED_BY_VERSION will be empty in case of "pure" uninstall… how one more `if` makes it "hard"?
Comment 5 Jeroen Roovers (RETIRED) gentoo-dev 2014-06-14 00:45:41 UTC
Comment on attachment 378834 [details, diff]
fixes for geoip-1.6.0-r2.ebuild

>+	if [ -z "${REPLACED_BY_VERSION}" ]; then
>+	    rm -r "${ROOT}"/usr/share/GeoIP/*.dat
>+	fi

For one thing, I don't see what the --recursive is for.
For another, it could be a oneliner [[ .. ]] && foo
Comment 6 Alex Turbov 2014-06-14 00:49:37 UTC
(In reply to Jeroen Roovers from comment #5)
> Comment on attachment 378834 [details, diff] [details, diff]
> fixes for geoip-1.6.0-r2.ebuild
> 
> >+	if [ -z "${REPLACED_BY_VERSION}" ]; then
> >+	    rm -r "${ROOT}"/usr/share/GeoIP/*.dat
> >+	fi
> 

I've thought you want to propose some different approach…

> For one thing, I don't see what the --recursive is for.

yep. I've just forgot to remove it after change the action from pkg_postrm() to pkg_prerm()…

> For another, it could be a oneliner [[ .. ]] && foo

as you wish, go on do it the way you like… as for me `if` is a little "readable" than oneliner…
Comment 7 Jeroen Roovers (RETIRED) gentoo-dev 2014-06-14 00:53:55 UTC
That still doesn't solve the issue of the script not using ROOT. It never actually did that before.
Comment 8 Alex Turbov 2014-06-14 00:54:17 UTC
(In reply to Jeroen Roovers from comment #3)
> 
> > And finally -- provided ${FILESDIR}/geoipupdate-r3.sh do not respect
> > ${ROOT}. Being running from pkg_postinst() action it may violate 9.1.11 of
> > current PMS-5!
> 
> You didn't show a patch for that one. What is the solution?

possible solution could be to pass a desired path as an argument and if omitted, set GEOIPDIR to default /usr/share/GeoIP. so being running from the ebuild it will respect $ROOT.
Comment 9 Jeroen Roovers (RETIRED) gentoo-dev 2014-06-14 01:02:47 UTC
The script in fact says "403 Forbidden / Rate limited exceeded, please try again in 24 hours." so I guess testing from this IP address is a problem for now.
Comment 10 Jeroen Roovers (RETIRED) gentoo-dev 2014-06-14 01:10:53 UTC
I might also address the issue of the Gentoo written script using wget, while net-misc/geoipupdate uses curl. The script should at least support both, if not $FETCHCOMMAND or something else entirely. I've seen examples of using only bash internals to do downloads... :)
Comment 11 Jeroen Roovers (RETIRED) gentoo-dev 2014-06-14 01:32:52 UTC
I have changed the way the geoipupdate.sh script is installed in -r3.
Comment 12 Alex Turbov 2014-06-14 20:18:46 UTC
(In reply to Jeroen Roovers from comment #11)
> I have changed the way the geoipupdate.sh script is installed in -r3.

as for me, it doesn't looks like a good idea to leave some files after a package gets removed... if I'm going to remove smth I want to remove all related files (and yes, I'm always review after such uninstalls what files/dirs wasn't removed from my system... and that's annoys me all the time). having such packages reminds me a Windows way... -- after half of the year, your system turns into dust-heap...

btw, maybe it makes some sense to talk (in ML?) about some option for package manager to "completely remove all files related" (i.e. even config protected! -- it is too often happened for me, if I decide to remove some package forever, I don't want to leave it's configuration files, but enforced to review uninstall messages and remove them manually...)
Comment 13 Jeroen Roovers (RETIRED) gentoo-dev 2014-06-14 21:28:30 UTC
(In reply to Alex Turbov from comment #12)
> (In reply to Jeroen Roovers from comment #11)
> > I have changed the way the geoipupdate.sh script is installed in -r3.
> 
> as for me, it doesn't looks like a good idea to leave some files after a
> package gets removed... if I'm going to remove smth I want to remove all
> related files

That wasn't disputed.

> btw, maybe it makes some sense to talk (in ML?) about some option for
> package manager to "completely remove all files related" (i.e. even config
> protected!

Generally, yes. But it's beyond the scope of this bug report. There are many problems with the package manager assuming that files are no longer needed because they are placed in directories owned by a package, and making the wrong assumption would certainly cause unwanted data loss.


Index: geoip-1.6.0-r3.ebuild
===================================================================
RCS file: /var/cvsroot/gentoo-x86/dev-libs/geoip/geoip-1.6.0-r3.ebuild,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -B -r1.1 -r1.2
--- geoip-1.6.0-r3.ebuild       14 Jun 2014 01:27:30 -0000      1.1
+++ geoip-1.6.0-r3.ebuild       14 Jun 2014 21:27:10 -0000      1.2
@@ -1,6 +1,6 @@
 # Copyright 1999-2014 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/dev-libs/geoip/geoip-1.6.0-r3.ebuild,v 1.1 2014/06/14 01:27:30 jer Exp $
+# $Header: /var/cvsroot/gentoo-x86/dev-libs/geoip/geoip-1.6.0-r3.ebuild,v 1.2 2014/06/14 21:27:10 jer Exp $

 EAPI=5
 inherit autotools eutils
@@ -47,3 +47,7 @@
 pkg_postinst() {
        "${ROOT}"/usr/sbin/geoipupdate.sh --force
 }
+
+pkg_prerm() {
+       [[ -z "${REPLACED_BY_VERSION}" ]] && rm -f "${ROOT}"/usr/share/GeoIP/*.dat
+}