Skip to content

Commit

Permalink
common: Remove the runtime dependency on lsb_release
Browse files Browse the repository at this point in the history
With modern releases we should be able to make do with the call to
os_release_parse only which uses /etc/os-release which should be available on
most (all?) releases we currently support. this then allows us to remove the
runtime dependency which pulls in several other packages and would be nice to
avoid.

Fixes: http://tracker.ceph.com/issues/17425
Signed-off-by: Brad Hubbard <[email protected]>
  • Loading branch information
badone committed Oct 7, 2016
1 parent 928c3c3 commit 8b1a57f
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 34 deletions.
4 changes: 0 additions & 4 deletions ceph.spec.in
Original file line number Diff line number Diff line change
Expand Up @@ -230,12 +230,8 @@ Requires: cryptsetup
Requires: findutils
Requires: which
%if 0%{?suse_version}
Requires: lsb-release
Recommends: ntp-daemon
%endif
%if 0%{?fedora} || 0%{?rhel}
Requires: redhat-lsb-core
%endif
%if 0%{with xio}
Requires: libxio
%endif
Expand Down
1 change: 0 additions & 1 deletion debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ Depends: binutils,
gdisk,
grep,
logrotate,
lsb-release,
${python:Depends},
xfsprogs,
${misc:Depends},
Expand Down
31 changes: 2 additions & 29 deletions src/common/util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -150,33 +150,6 @@ static void file_values_parse(const map<string, string>& kvm, FILE *fp, map<stri
}
}

static bool lsb_release_parse(map<string, string> *m, CephContext *cct)
{
static const map<string, string> kvm = {
{ "distro", "Distributor ID:" },
{ "distro_description", "Description:" },
{ "distro_codename", "Codename:", },
{ "distro_version", "Release:" }
};

FILE *fp = popen("lsb_release -idrc", "r");
if (!fp) {
int ret = -errno;
lderr(cct) << "lsb_release_parse - failed to call lsb_release binary with error: " << cpp_strerror(ret) << dendl;
return false;
}

file_values_parse(kvm, fp, m, cct);

if (pclose(fp)) {
int ret = -errno;
lderr(cct) << "lsb_release_parse - pclose failed: " << cpp_strerror(ret) << dendl;
return false;
}

return true;
}

static bool os_release_parse(map<string, string> *m, CephContext *cct)
{
static const map<string, string> kvm = {
Expand All @@ -201,8 +174,8 @@ static bool os_release_parse(map<string, string> *m, CephContext *cct)

static void distro_detect(map<string, string> *m, CephContext *cct)
{
if (!lsb_release_parse(m, cct) && !os_release_parse(m, cct)) {
lderr(cct) << "distro_detect - lsb_release or /etc/os-release is required" << dendl;
if (!os_release_parse(m, cct)) {
lderr(cct) << "distro_detect - /etc/os-release is required" << dendl;
}

for (const char* rk: {"distro", "distro_version"}) {
Expand Down

0 comments on commit 8b1a57f

Please sign in to comment.