LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions
User Name
Password
Linux - Distributions This forum is for Distribution specific questions.
Red Hat, Slackware, Debian, Novell, LFS, Mandriva, Ubuntu, Fedora - the list goes on and on... Note: An (*) indicates there is no official participation from that distribution here at LQ.

Notices


Reply
  Search this Thread
Old 05-26-2018, 05:58 AM   #1
dsl_
Member
 
Registered: Jul 2008
Location: Denmark
Distribution: Debian
Posts: 71

Rep: Reputation: 0
Autotools m4 macro install package cross-distro


Hi!

Is there an autotools macro or something similar that will let me install a package consistently across multiple distros? It seems such a basic requirement that I'm surprised the answer doesn't jump out at me.

Perhaps it's not possible, I don't know.

If not, how do people accomplish this? With a script that identifies the host and issue the appropriate install commands?

Seems like a cumbersome approach to me..

Anyone?

Tia,
Soren

Last edited by dsl_; 05-26-2018 at 06:57 AM.
 
Old 05-26-2018, 10:04 AM   #2
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (15 current), Slack15, Ubuntu studio, MX Linux, FreeBSD 13.1, WIn10
Posts: 10,342

Rep: Reputation: 2243Reputation: 2243Reputation: 2243Reputation: 2243Reputation: 2243Reputation: 2243Reputation: 2243Reputation: 2243Reputation: 2243Reputation: 2243Reputation: 2243
I've have not delt with it, but I've seen make files and such with directives for multi platform as this one here
Code:
case $os in
	-sun*os*)
		# Prevent following clause from handling this invalid input.
		;;
	-dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \
	-att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \
	-unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \
	-convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\
	-c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \
	-harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \
	-apple | -axis | -knuth | -cray | -microblaze*)
		os=
		basic_machine=$1
		;;
	-bluegene*)
		os=-cnk
		;;
	-sim | -cisco | -oki | -wec | -winbond)
		os=
		basic_machine=$1
		;;
	-scout)
		;;
	-wrs)
		os=-vxworks
		basic_machine=$1
		;;
	-chorusos*)
		os=-chorusos
		basic_machine=$1
		;;
	-chorusrdb)
		os=-chorusrdb
		basic_machine=$1
		;;
	-hiux*)
		os=-hiuxwe2
		;;
	-sco6)
.... no and on it goes for different OS'es ...
found in a dockapp here
https://github.com/tarjanm-movidius/wmbatteries
file is called
config.sub

you could rummage through the files and get a real world idea on how to set it up.
 
Old 05-26-2018, 10:46 AM   #3
dsl_
Member
 
Registered: Jul 2008
Location: Denmark
Distribution: Debian
Posts: 71

Original Poster
Rep: Reputation: 0
This looks useful. Thank you.

I'm surprised that there aren't a macro for this. I can't be the only one having had this problem. I guess it's almost worth it's own source forge project. A cross-distro package installer...

Regards,
Soren
 
Old 05-26-2018, 10:52 AM   #4
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (15 current), Slack15, Ubuntu studio, MX Linux, FreeBSD 13.1, WIn10
Posts: 10,342

Rep: Reputation: 2243Reputation: 2243Reputation: 2243Reputation: 2243Reputation: 2243Reputation: 2243Reputation: 2243Reputation: 2243Reputation: 2243Reputation: 2243Reputation: 2243
there has to be some kind of documentation on it somewhere for others to know how to do that. Here, I found another one I was looking for in how they did this. This one uses a makefile, whereas the other one used configure.

https://github.com/bbidulock/dockapp...blemon-dockapp

too, I believe that one when they write there code that put the defines in to separate the OS'es then when the makefile compiles the c or cpp files. The defines take care of the rest when it is compiling. that seems logical to me as well.

Its just a matter of having it ( it being what/whichever file) check to see what platform it is on before compiling the code.

Last edited by BW-userx; 05-26-2018 at 11:00 AM.
 
Old 05-29-2018, 04:59 PM   #5
X-LFS-2010
Member
 
Registered: Apr 2016
Posts: 510

Rep: Reputation: 58
> found in a dockapp here

that may be PROPRIETARY. you should check the license before using it

considerations:

you may not be required to use m4, m4 is not the "only thing" when building using make(1). most platforms are "required" to have perl (which depends)

You could use the GNU automake facility and allow who compiles the app to decide where it goes instead of trying to decide this for them

for example - sites that want certain apps in "local" tend to have scripts that tell GNU/automake to do this

all you have to do is is NOT IGNORE the ./configure arguments that the person compiling chose
 
Old 05-30-2018, 02:59 AM   #6
dsl_
Member
 
Registered: Jul 2008
Location: Denmark
Distribution: Debian
Posts: 71

Original Poster
Rep: Reputation: 0
Don't worry. I'm not going to copy/paste anything. I basically just wanted an example of distinguishing between distros, not OSs as in the example he provided.

I would be able to set something up using /etc/os-release, as in:

Code:
soren@pauline:~$ cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 9 (stretch)"
NAME="Debian GNU/Linux"
VERSION_ID="9"
VERSION="9 (stretch)"
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
soren@pauline:~$
The ID in there would help me select the appropiate commands for installing packages cross-distro. That is the idea, at least.

Regards,
Soren
 
Old 05-31-2018, 05:11 PM   #7
dsl_
Member
 
Registered: Jul 2008
Location: Denmark
Distribution: Debian
Posts: 71

Original Poster
Rep: Reputation: 0
Now I just need to find out what the ID will say for all major distros. Red Hat is "rhel" right? And the package manager is yum?

I could use people's data for all sorts of mainstream and obscure distros...

I'll be thankful for anyone posting their

# cat/etc/os-release


Regards,
Soren
 
Old 05-31-2018, 05:36 PM   #8
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (15 current), Slack15, Ubuntu studio, MX Linux, FreeBSD 13.1, WIn10
Posts: 10,342

Rep: Reputation: 2243Reputation: 2243Reputation: 2243Reputation: 2243Reputation: 2243Reputation: 2243Reputation: 2243Reputation: 2243Reputation: 2243Reputation: 2243Reputation: 2243
Code:
$ cat /etc/os-release
NAME="Manjaro Linux"
ID=manjaro
PRETTY_NAME="Manjaro Linux"
ANSI_COLOR="1;32"
HOME_URL="https://www.manjaro.org/"
SUPPORT_URL="https://www.manjaro.org/"
BUG_REPORT_URL="https://bugs.manjaro.org/"
the one I am on at the moment.
 
Old 05-31-2018, 05:58 PM   #9
dsl_
Member
 
Registered: Jul 2008
Location: Denmark
Distribution: Debian
Posts: 71

Original Poster
Rep: Reputation: 0
So the terminal install command would be:

# sudo pacman -Syu <package>

?
 
Old 05-31-2018, 06:02 PM   #10
dsl_
Member
 
Registered: Jul 2008
Location: Denmark
Distribution: Debian
Posts: 71

Original Poster
Rep: Reputation: 0
Code:
#!/usr/bin/perl

use strict;
use warnings;
use autodie;

use Switch;

my $USAGE = "\n\n\t$0\t{install | remove} pkg\n\n";


my %switches;
my @arguments;
my $command = "";


# parse command line
foreach(@ARGV) {
    if(/^-/) {
	$switches{$_} = "undef";
	next;
    }
    push(@arguments, $_);
}

# get the distro name
my $distro_output=`cat /etc/os-release`;
my $distro ="";
    
my @tokens = split(/\n/, "$distro_output");

foreach(@tokens) {
    if(/^ID=(.*)$/) {
	$distro = $1;
	last;
    }
}

print "DISTRO: $distro\n";

# check for a valid commnand
foreach($arguments[0]) {
    switch($_) {
	case (/^install$/i)   { print "installing...\n"; last;}
	case (/^remove$/i)    { print "removing...\n"; last;}
	else                  { print $USAGE; exit; }
    }
}


switch ($distro) {
    case (/^debian$/i)    { $command = shift @arguments; $command = "apt install "; last; }
    case (/^rhel$/i)      { $command = shift @arguments; $command = "yum install "; last; }
    case (/^manjaro$/i)   { $command = shift @arguments; $command = "pacman -Syu "; last; }
    else                  { print "$distro not supported.\n"; }
}



# debug output switches
foreach my $key (keys %switches) {
    printf "key: $key -> $switches{$key}\n";
}


my $install_command = $command . join(' ', @arguments);

print "INSTALL COMMAND: [$install_command]\n";


my $output = `$install_command`;

print "$output\n";
I'm sure someone will tell me this is a bad idea. But why?

And it's basically just half-functioning pseudode so far. The idea is pretty clear though.


Regards,
Soren

Last edited by dsl_; 05-31-2018 at 06:05 PM. Reason: Typo
 
Old 06-01-2018, 12:09 AM   #11
dsl_
Member
 
Registered: Jul 2008
Location: Denmark
Distribution: Debian
Posts: 71

Original Poster
Rep: Reputation: 0
Maybe lsb_release is a more secure way of testing. Also, I found this:

Code:
# Fact: operatingsystem
#
# Purpose: Return the name of the operating system.
#
# Resolution:
#   If the kernel is a Linux kernel, check for the existence of a selection of
#   files in /etc/ to find the specific flavour.
#   On SunOS based kernels, return Solaris.
#   On systems other than Linux, use the kernel value.
#
# Caveats:
#
 
Facter.add(:operatingsystem) do
  confine :kernel => :sunos
  setcode do
    if FileTest.exists?("/etc/debian_version")
      "Nexenta"
    else
      "Solaris"
    end
  end
end
 
Facter.add(:operatingsystem) do
  confine :kernel => :linux
  setcode do
    if Facter.value(:lsbdistid) == "Ubuntu"
       "Ubuntu"
    elsif FileTest.exists?("/etc/debian_version")
      "Debian"
    elsif FileTest.exists?("/etc/gentoo-release")
      "Gentoo"
    elsif FileTest.exists?("/etc/fedora-release")
      "Fedora"
    elsif FileTest.exists?("/etc/mandriva-release")
      "Mandriva"
    elsif FileTest.exists?("/etc/mandrake-release")
      "Mandrake"
    elsif FileTest.exists?("/etc/meego-release")
      "MeeGo"
    elsif FileTest.exists?("/etc/arch-release")
      "Archlinux"
    elsif FileTest.exists?("/etc/oracle-release")
      "OracleLinux"
    elsif FileTest.exists?("/etc/enterprise-release")
      if FileTest.exists?("/etc/ovs-release")
        "OVS"
      else
        "OEL"
      end
    elsif FileTest.exists?("/etc/vmware-release")
      "VMWareESX"
    elsif FileTest.exists?("/etc/redhat-release")
      txt = File.read("/etc/redhat-release")
      if txt =~ /centos/i
        "CentOS"
      elsif txt =~ /CERN/
        "SLC"
      elsif txt =~ /scientific/i
        "Scientific"
      elsif txt =~ /^cloudlinux/i
        "CloudLinux"
      elsif txt =~ /^Parallels Server Bare Metal/i
        "PSBM"
      elsif txt =~ /Ascendos/i
        "Ascendos"
      else
        "RedHat"
      end
    elsif FileTest.exists?("/etc/SuSE-release")
      txt = File.read("/etc/SuSE-release")
      if txt =~ /^SUSE LINUX Enterprise Server/i
        "SLES"
      elsif txt =~ /^SUSE LINUX Enterprise Desktop/i
        "SLED"
      elsif txt =~ /^openSUSE/i
        "OpenSuSE"
      else
        "SuSE"
      end
    elsif FileTest.exists?("/etc/bluewhite64-version")
      "Bluewhite64"
    elsif FileTest.exists?("/etc/slamd64-version")
      "Slamd64"
    elsif FileTest.exists?("/etc/slackware-version")
      "Slackware"
    elsif FileTest.exists?("/etc/alpine-release")
      "Alpine"
    elsif FileTest.exists?("/etc/system-release")
      "Amazon"
    end
  end
end
 
Facter.add(:operatingsystem) do
  confine :kernel => "VMkernel"
  setcode do
    "ESXi"
  end
end
 
Facter.add(:operatingsystem) do
  # Default to just returning the kernel as the operating system
  setcode do Facter[:kernel].value end
end
-- https://pastebin.com/EDFJsNdj


Which seems to imply this is not so easy after all.

Regards,
Soren
 
Old 06-01-2018, 12:58 AM   #12
dsl_
Member
 
Registered: Jul 2008
Location: Denmark
Distribution: Debian
Posts: 71

Original Poster
Rep: Reputation: 0
I've put it on SF till someone tells me it'll explode in my face....

https://sourceforge.net/projects/cro...ckage-manager/

Regards,
Soren
 
Old 06-01-2018, 10:14 AM   #13
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (15 current), Slack15, Ubuntu studio, MX Linux, FreeBSD 13.1, WIn10
Posts: 10,342

Rep: Reputation: 2243Reputation: 2243Reputation: 2243Reputation: 2243Reputation: 2243Reputation: 2243Reputation: 2243Reputation: 2243Reputation: 2243Reputation: 2243Reputation: 2243
I think the best way to find out about how and what your code is doing is to install v box or alike then install the distributions. You’re going to be porting to, then test it on each one. Yep that’s the fun part, the testing. J/k

Last edited by BW-userx; 06-01-2018 at 10:58 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Ubuntu - How to install package from older distro's ppa ddenial Linux - Newbie 5 01-23-2017 03:19 AM
Autotools n00b: How to install the directory? CoderMan Programming 4 12-12-2009 08:48 PM
how to install package s from Fedora 9 distro dvd? linbux Fedora 11 07-04-2008 05:18 PM
RPMdrake cannot install package from distro CD NeilGL Mandriva 4 05-14-2006 07:15 PM
Error Installing Package during distro install PensJunkie Fedora 6 04-12-2005 06:30 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions

All times are GMT -5. The time now is 02:50 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration