Skip to content
This repository has been archived by the owner on Jul 14, 2022. It is now read-only.

Commit

Permalink
Fix curl dependency (closes #17)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sven Geggus committed Jun 11, 2019
1 parent 0060ef7 commit 057f3db
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Maintainer: Sven Geggus <[email protected]>
Build-Depends: debhelper (>= 8.0.0), libicu-dev,
postgresql-server-dev-all,
postgresql-server-dev-9.4 | postgresql-server-dev-9.5 | postgresql-server-dev-10 | postgresql-server-dev-11,
wget, libkakasi2-dev, libutf8proc-dev, pandoc
curl, libkakasi2-dev, libutf8proc-dev, pandoc
Standards-Version: 3.9.2

Package: postgresql-11-osml10n
Expand Down
2 changes: 1 addition & 1 deletion debian/control.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Maintainer: Sven Geggus <[email protected]>
Build-Depends: debhelper (>= 8.0.0), libicu-dev,
postgresql-server-dev-all,
postgresql-server-dev-9.4 | postgresql-server-dev-9.5 | postgresql-server-dev-10 | postgresql-server-dev-11,
wget, libkakasi2-dev, libutf8proc-dev, pandoc
curl, libkakasi2-dev, libutf8proc-dev, pandoc
Standards-Version: 3.9.2

Package: postgresql-PGVERSION-osml10n
Expand Down
8 changes: 8 additions & 0 deletions gen_osml10n_extension.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ if [ $# -ne 2 ]; then
exit 1
fi

# check if commands we need are available
for cmd in curl sed basename; do
if ! command -v $cmd >/dev/null; then
echo "ERROR: command >>$cmd<< not found, please install!" >&2
exit 1
fi
done

if ! [ -f country_osm_grid.sql ]; then
echo -n "Trying to download country_grid.sql.gz from nominatim.org... "
curl -s http://www.nominatim.org/data/country_grid.sql.gz |gzip -d >country_osm_grid.sql

This comment has been minimized.

Copy link
@otbutz

otbutz Jun 11, 2019

The download might still fail (server down, corporate proxy, etc) and generate an empty country_osm_grid.sql file

Suggestion:

  echo -n "Trying to download country_grid.sql.gz from nominatim.org... "
  curl -f -sS http://www.nominatim.org/data/country_grid.sql.gz | gzip -d >country_osm_grid.sql
  if [ $? -ne 0 ]; then
    echo "ERROR: failed to download and decompress country_osm_grid.sql" >&2
    # Delete the broken download
    rm country_osm_grid.sql
    exit 1
  fi
Expand Down

2 comments on commit 057f3db

@giggls
Copy link
Owner

@giggls giggls commented on 057f3db Jun 11, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIK yout code will capture the exit status of the gzip rather than the one from curl. My intension was to check for the existence of country_osm_grid.sql (as download may not be possible at all) rather than checking if the download succeeded. This worked at some stage but broke after I added the command pipeline which will always produce the SQL file.

Thus I just replaced -f by -s

@otbutz
Copy link

@otbutz otbutz commented on 057f3db Jun 12, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIK yout code will capture the exit status of the gzip rather than the one from curl

That was intended. gzip will fail for broken downloads and corrupt archives.

But yes, your solution achieves the same thing 👍

Please sign in to comment.