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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
05-26-2018, 05:58 AM
|
#1
|
Member
Registered: Jul 2008
Location: Denmark
Distribution: Debian
Posts: 71
Rep:
|
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.
|
|
|
05-26-2018, 10:04 AM
|
#2
|
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
|
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.
|
|
|
05-26-2018, 10:46 AM
|
#3
|
Member
Registered: Jul 2008
Location: Denmark
Distribution: Debian
Posts: 71
Original Poster
Rep:
|
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
|
|
|
05-26-2018, 10:52 AM
|
#4
|
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
|
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.
|
|
|
05-29-2018, 04:59 PM
|
#5
|
Member
Registered: Apr 2016
Posts: 510
Rep: 
|
> 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
|
|
|
05-30-2018, 02:59 AM
|
#6
|
Member
Registered: Jul 2008
Location: Denmark
Distribution: Debian
Posts: 71
Original Poster
Rep:
|
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
|
|
|
05-31-2018, 05:11 PM
|
#7
|
Member
Registered: Jul 2008
Location: Denmark
Distribution: Debian
Posts: 71
Original Poster
Rep:
|
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
|
|
|
05-31-2018, 05:36 PM
|
#8
|
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
|
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.
|
|
|
05-31-2018, 05:58 PM
|
#9
|
Member
Registered: Jul 2008
Location: Denmark
Distribution: Debian
Posts: 71
Original Poster
Rep:
|
So the terminal install command would be:
# sudo pacman -Syu <package>
?
|
|
|
05-31-2018, 06:02 PM
|
#10
|
Member
Registered: Jul 2008
Location: Denmark
Distribution: Debian
Posts: 71
Original Poster
Rep:
|
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
|
|
|
06-01-2018, 12:09 AM
|
#11
|
Member
Registered: Jul 2008
Location: Denmark
Distribution: Debian
Posts: 71
Original Poster
Rep:
|
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
|
|
|
06-01-2018, 10:14 AM
|
#13
|
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
|
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.
|
|
|
All times are GMT -5. The time now is 02:50 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|