diff --git a/.circleci/config.yml b/.circleci/config.yml index f9babff0..ea0d7eef 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -12,14 +12,14 @@ jobs: - run: name: install_required_packages no_output_timeout: 20m - command: perl src/fastnetmon_install.pl --install_dependency_packages_only + command: perl src/fastnetmon_install.pl --install_dependency_packages_only --source_build - restore_cache: keys: - "{{ .Environment.CIRCLE_JOB }}_dependencies_26_05_2020" - run: name: install_dependencies no_output_timeout: 40m - command: perl src/fastnetmon_install.pl --use-git-master --api --gobgp + command: perl src/fastnetmon_install.pl --use-git-master --api --gobgp --source_build - run: name: collect_debug command: cat /tmp/fastnetmon_install.log @@ -46,14 +46,14 @@ jobs: - run: name: install_required_packages no_output_timeout: 20m - command: perl src/fastnetmon_install.pl --install_dependency_packages_only + command: perl src/fastnetmon_install.pl --install_dependency_packages_only --source_build - restore_cache: keys: - "{{ .Environment.CIRCLE_JOB }}_dependencies_10_06_2020" - run: name: install_dependencies no_output_timeout: 40m - command: perl src/fastnetmon_install.pl --use-git-master --api --gobgp --boost --do-not-use-mirror + command: perl src/fastnetmon_install.pl --use-git-master --api --gobgp --boost --do-not-use-mirror --source_build - run: name: collect_debug command: cat /tmp/fastnetmon_install.log @@ -86,14 +86,14 @@ jobs: - run: name: install_required_packages no_output_timeout: 20m - command: perl src/fastnetmon_install.pl --install_dependency_packages_only + command: perl src/fastnetmon_install.pl --install_dependency_packages_only --source_build - restore_cache: keys: - "{{ .Environment.CIRCLE_JOB }}_dependencies_26_05_2020" - run: name: install_dependencies no_output_timeout: 40m - command: perl src/fastnetmon_install.pl --use-git-master --api --gobgp + command: perl src/fastnetmon_install.pl --use-git-master --api --gobgp --source_build - run: name: collect_debug command: cat /tmp/fastnetmon_install.log @@ -120,14 +120,14 @@ jobs: - run: name: install_required_packages no_output_timeout: 20m - command: perl src/fastnetmon_install.pl --install_dependency_packages_only + command: perl src/fastnetmon_install.pl --install_dependency_packages_only --source_build - restore_cache: keys: - "{{ .Environment.CIRCLE_JOB }}_dependencies_10_06_2020" - run: name: install_dependencies no_output_timeout: 40m - command: perl src/fastnetmon_install.pl --use-git-master --api --gobgp --boost --do-not-use-mirror + command: perl src/fastnetmon_install.pl --use-git-master --api --gobgp --boost --do-not-use-mirror --source_build - run: name: collect_debug command: cat /tmp/fastnetmon_install.log @@ -160,14 +160,14 @@ jobs: - run: name: install_required_packages no_output_timeout: 20m - command: perl src/fastnetmon_install.pl --install_dependency_packages_only + command: perl src/fastnetmon_install.pl --install_dependency_packages_only --source_build - restore_cache: keys: - "{{ .Environment.CIRCLE_JOB }}_dependencies_26_05_2020" - run: name: install_dependencies no_output_timeout: 40m - command: perl src/fastnetmon_install.pl --use-git-master --api --gobgp + command: perl src/fastnetmon_install.pl --use-git-master --api --gobgp --source_build - run: name: collect_debug command: cat /tmp/fastnetmon_install.log @@ -194,14 +194,14 @@ jobs: - run: name: install_required_packages no_output_timeout: 20m - command: perl src/fastnetmon_install.pl --install_dependency_packages_only + command: perl src/fastnetmon_install.pl --install_dependency_packages_only --source_build - restore_cache: keys: - "{{ .Environment.CIRCLE_JOB }}_dependencies_10_06_2020" - run: name: install_dependencies no_output_timeout: 40m - command: perl src/fastnetmon_install.pl --use-git-master --api --gobgp --boost --do-not-use-mirror + command: perl src/fastnetmon_install.pl --use-git-master --api --gobgp --boost --do-not-use-mirror --source_build - run: name: collect_debug command: cat /tmp/fastnetmon_install.log @@ -234,14 +234,14 @@ jobs: - run: name: install_required_packages no_output_timeout: 20m - command: perl src/fastnetmon_install.pl --install_dependency_packages_only + command: perl src/fastnetmon_install.pl --install_dependency_packages_only --source_build - restore_cache: keys: - "{{ .Environment.CIRCLE_JOB }}_dependencies_26_05_2020" - run: name: install_dependencies no_output_timeout: 40m - command: perl src/fastnetmon_install.pl --use-git-master --api --gobgp + command: perl src/fastnetmon_install.pl --use-git-master --api --gobgp --source_build - run: name: collect_debug command: cat /tmp/fastnetmon_install.log @@ -268,14 +268,14 @@ jobs: - run: name: install_required_packages no_output_timeout: 20m - command: perl src/fastnetmon_install.pl --install_dependency_packages_only + command: perl src/fastnetmon_install.pl --install_dependency_packages_only --source_build - restore_cache: keys: - "{{ .Environment.CIRCLE_JOB }}_dependencies_10_06_2020" - run: name: install_dependencies no_output_timeout: 40m - command: perl src/fastnetmon_install.pl --use-git-master --api --gobgp --boost --do-not-use-mirror + command: perl src/fastnetmon_install.pl --use-git-master --api --gobgp --boost --do-not-use-mirror --source_build - run: name: collect_debug command: cat /tmp/fastnetmon_install.log @@ -308,14 +308,14 @@ jobs: - run: name: install_required_packages no_output_timeout: 35m - command: perl src/fastnetmon_install.pl --install_dependency_packages_only + command: perl src/fastnetmon_install.pl --install_dependency_packages_only --source_build - restore_cache: keys: - "{{ .Environment.CIRCLE_JOB }}_dependencies_26_05_2020" - run: name: install_dependencies no_output_timeout: 40m - command: perl src/fastnetmon_install.pl --use-git-master --api --gobgp + command: perl src/fastnetmon_install.pl --use-git-master --api --gobgp --source_build - run: name: collect_debug command: cat /tmp/fastnetmon_install.log @@ -342,14 +342,14 @@ jobs: - run: name: install_required_packages no_output_timeout: 20m - command: perl src/fastnetmon_install.pl --install_dependency_packages_only + command: perl src/fastnetmon_install.pl --install_dependency_packages_only --source_build - restore_cache: keys: - "{{ .Environment.CIRCLE_JOB }}_dependencies_26_05_2020" - run: name: install_dependencies no_output_timeout: 40m - command: perl src/fastnetmon_install.pl --use-git-master --api --gobgp --boost --do-not-use-mirror + command: perl src/fastnetmon_install.pl --use-git-master --api --gobgp --boost --do-not-use-mirror --source_build - run: name: collect_debug command: cat /tmp/fastnetmon_install.log @@ -382,14 +382,14 @@ jobs: - run: name: install_required_packages no_output_timeout: 35m - command: perl src/fastnetmon_install.pl --install_dependency_packages_only + command: perl src/fastnetmon_install.pl --install_dependency_packages_only --source_build - restore_cache: keys: - "{{ .Environment.CIRCLE_JOB }}_dependencies_26_05_2020" - run: name: install_dependencies no_output_timeout: 40m - command: perl src/fastnetmon_install.pl --use-git-master --api --gobgp + command: perl src/fastnetmon_install.pl --use-git-master --api --gobgp --source_build - run: name: collect_debug command: cat /tmp/fastnetmon_install.log @@ -416,14 +416,14 @@ jobs: - run: name: install_required_packages no_output_timeout: 20m - command: perl src/fastnetmon_install.pl --install_dependency_packages_only + command: perl src/fastnetmon_install.pl --install_dependency_packages_only --source_build - restore_cache: keys: - "{{ .Environment.CIRCLE_JOB }}_dependencies_26_05_2020" - run: name: install_dependencies no_output_timeout: 40m - command: perl src/fastnetmon_install.pl --use-git-master --api --gobgp --boost --do-not-use-mirror + command: perl src/fastnetmon_install.pl --use-git-master --api --gobgp --boost --do-not-use-mirror --source_build - run: name: collect_debug command: cat /tmp/fastnetmon_install.log @@ -456,14 +456,14 @@ jobs: - run: name: install_required_packages no_output_timeout: 20m - command: perl src/fastnetmon_install.pl --install_dependency_packages_only + command: perl src/fastnetmon_install.pl --install_dependency_packages_only --source_build - restore_cache: keys: - "{{ .Environment.CIRCLE_JOB }}_dependencies_26_05_2020" - run: name: install_dependencies no_output_timeout: 40m - command: perl src/fastnetmon_install.pl --use-git-master --api --gobgp + command: perl src/fastnetmon_install.pl --use-git-master --api --gobgp --source_build - run: name: collect_debug command: cat /tmp/fastnetmon_install.log @@ -490,14 +490,14 @@ jobs: - run: name: install_required_packages no_output_timeout: 20m - command: perl src/fastnetmon_install.pl --install_dependency_packages_only + command: perl src/fastnetmon_install.pl --install_dependency_packages_only --source_build - restore_cache: keys: - "{{ .Environment.CIRCLE_JOB }}_dependencies_26_05_2020" - run: name: install_dependencies no_output_timeout: 40m - command: perl src/fastnetmon_install.pl --use-git-master --api --gobgp --boost --do-not-use-mirror + command: perl src/fastnetmon_install.pl --use-git-master --api --gobgp --boost --do-not-use-mirror --source_build - run: name: collect_debug command: cat /tmp/fastnetmon_install.log @@ -529,14 +529,14 @@ jobs: - run: name: install_required_packages no_output_timeout: 20m - command: perl src/fastnetmon_install.pl --install_dependency_packages_only + command: perl src/fastnetmon_install.pl --install_dependency_packages_only --source_build - restore_cache: keys: - "{{ .Environment.CIRCLE_JOB }}_dependencies_27_05_2020" - run: name: install_dependencies no_output_timeout: 40m - command: perl src/fastnetmon_install.pl --use-git-master + command: perl src/fastnetmon_install.pl --use-git-master --source_build - run: name: collect_debug command: cat /tmp/fastnetmon_install.log @@ -564,7 +564,7 @@ jobs: - run: name: install_required_packages no_output_timeout: 20m - command: perl src/fastnetmon_install.pl --install_dependency_packages_only + command: perl src/fastnetmon_install.pl --install_dependency_packages_only --source_build - restore_cache: keys: - "{{ .Environment.CIRCLE_JOB }}_dependencies_12_06_2020" @@ -574,7 +574,7 @@ jobs: - run: name: install_gcc no_output_timeout: 80m - command: perl src/fastnetmon_install.pl --build_gcc_only --do-not-use-mirror + command: perl src/fastnetmon_install.pl --build_gcc_only --do-not-use-mirror --source_build - save_cache: key: "{{ .Environment.CIRCLE_JOB }}_gcc_27_05_2020" paths: @@ -582,7 +582,7 @@ jobs: - run: name: install_dependencies no_output_timeout: 40m - command: perl src/fastnetmon_install.pl --use-git-master --api --gobgp --boost --do-not-use-mirror + command: perl src/fastnetmon_install.pl --use-git-master --api --gobgp --boost --do-not-use-mirror --source_build - run: name: collect_debug command: cat /tmp/fastnetmon_install.log @@ -614,14 +614,14 @@ jobs: - run: name: install_required_packages no_output_timeout: 20m - command: perl src/fastnetmon_install.pl --install_dependency_packages_only + command: perl src/fastnetmon_install.pl --install_dependency_packages_only --source_build - restore_cache: keys: - "{{ .Environment.CIRCLE_JOB }}_dependencies_26_05_2020" - run: name: install_dependencies no_output_timeout: 40m - command: perl src/fastnetmon_install.pl --use-git-master --api --gobgp + command: perl src/fastnetmon_install.pl --use-git-master --api --gobgp --source_build - run: name: collect_debug command: cat /tmp/fastnetmon_install.log @@ -647,14 +647,14 @@ jobs: - run: name: install_required_packages no_output_timeout: 20m - command: perl src/fastnetmon_install.pl --install_dependency_packages_only + command: perl src/fastnetmon_install.pl --install_dependency_packages_only --source_build - restore_cache: keys: - "{{ .Environment.CIRCLE_JOB }}_dependencies_27_05_2020" - run: name: install_dependencies no_output_timeout: 40m - command: perl src/fastnetmon_install.pl --use-git-master --api --gobgp --boost --do-not-use-mirror + command: perl src/fastnetmon_install.pl --use-git-master --api --gobgp --boost --do-not-use-mirror --source_build - run: name: collect_debug command: cat /tmp/fastnetmon_install.log @@ -687,7 +687,7 @@ jobs: - run: name: install_required_packages no_output_timeout: 20m - command: perl src/fastnetmon_install.pl --install_dependency_packages_only + command: perl src/fastnetmon_install.pl --install_dependency_packages_only --source_build - run: name: collect_debug command: cat /tmp/fastnetmon_install.log @@ -698,7 +698,7 @@ jobs: - run: name: install_dependencies no_output_timeout: 40m - command: perl src/fastnetmon_install.pl --use-git-master --api --gobgp + command: perl src/fastnetmon_install.pl --use-git-master --api --gobgp --source_build - save_cache: key: "{{ .Environment.CIRCLE_JOB }}_dependencies_26_05_2020" paths: @@ -720,14 +720,14 @@ jobs: - run: name: install_required_packages no_output_timeout: 20m - command: perl src/fastnetmon_install.pl --install_dependency_packages_only + command: perl src/fastnetmon_install.pl --install_dependency_packages_only --source_build - restore_cache: keys: - "{{ .Environment.CIRCLE_JOB }}_dependencies_27_05_2020" - run: name: install_dependencies no_output_timeout: 40m - command: perl src/fastnetmon_install.pl --use-git-master --api --gobgp --boost --do-not-use-mirror + command: perl src/fastnetmon_install.pl --use-git-master --api --gobgp --boost --do-not-use-mirror --source_build - run: name: collect_debug command: cat /tmp/fastnetmon_install.log diff --git a/src/fastnetmon_install.pl b/src/fastnetmon_install.pl index d3c0baa3..efceb354 100755 --- a/src/fastnetmon_install.pl +++ b/src/fastnetmon_install.pl @@ -139,6 +139,8 @@ my $do_not_build_fastnetmon = ''; my $build_gcc_only = ''; +my $source_build = ''; + # Get options from command line GetOptions( 'use-git-master' => \$we_use_code_from_master, @@ -152,6 +154,7 @@ GetOptions( 'help' => \$show_help, 'install_dependency_packages_only' => \$install_dependency_packages_only, 'build_gcc_only' => \$build_gcc_only, + 'source_build' => \$source_build, ); # Export all meaningful customer facing flags to Sentry for better failure tracking @@ -163,7 +166,7 @@ $ENV{'api'} = $enable_api; $ENV{'boost'} = $build_boost; if ($show_help) { - print "We have following options:\n--use-git-master\n--do-not-use-mirror\n--do-not-track-me\n--use-modern-pf-ring\n--gobgp\n--api\n--install_dependency_packages_only\n--boost\ndo-not-build-fastnetmon\n--build_gcc_only\n--help\n"; + print "We have following options:\n--use-git-master\n--do-not-use-mirror\n--do-not-track-me\n--use-modern-pf-ring\n--gobgp\n--api\n--install_dependency_packages_only\n--boost\ndo-not-build-fastnetmon\n--build_gcc_only\n--help\n--source_build\n"; exit (0); } @@ -390,6 +393,106 @@ sub main { install_sentry(); + my $download_path = "https://community-downloads.fastnetmon.com/releases/1.1.6"; + + # Unless we're in compile mode we will use binary packages if we can + # We've enabled this logic only for Ubuntu + if (!$source_build && $distro_type eq 'ubuntu') { + print "We will install FastNetMon using official binary packages\n"; + send_tracking_information('started'); + + + if ($os_type eq 'freebsd') { + fast_die("I'm sorry but we do not support FreeBSD in official builds but we offer official FreeBSD port, please check it instead"); + } elsif ($os_type eq 'macosx') { + fast_die("I'm sorry but we do not support macos in current version, please raise GitHub issue if you want support for it: https://github.com/pavel-odintsov/fastnetmon"); + } elsif ($os_type eq 'linux') { + if ($distro_type eq 'ubuntu') { + my $ubuntu_package_name = "fastnetmon_1.1.6_amd64.deb"; + + if ($distro_version =~ m/^14\.04/) { + print "Install dependencies\n"; + exec_command("apt-get update"); + exec_command("apt-get install -y curl libpcap0.8 libatomic1"); + + my $curl_res = system("curl $download_path/ubuntu/14.04/$ubuntu_package_name -o$ubuntu_package_name"); + + if ($curl_res != 0) { + fast_die("Cannot download FastNetMon package"); + } + + my $res = system("dpkg -i $ubuntu_package_name"); + + if ($res != 0) { + fast_die("Cannot install FastNetMon package with error code $res"); + } + } elsif ($distro_version =~ m/^16\.04/) { + print "Install dependencies\n"; + exec_command("apt-get update"); + exec_command("apt-get install -y curl"); + + my $curl_res = system("curl $download_path/ubuntu/16.04/$ubuntu_package_name -o$ubuntu_package_name"); + + if ($curl_res != 0) { + fast_die("Cannot download FastNetMon package"); + } + + my $install_res = system("apt install -y ./$ubuntu_package_name"); + + if ($install_res != 0) { + fast_die("Cannot install FastNetMon"); + } + } elsif ($distro_version =~ m/^18\.04/) { + print "Install dependencies\n"; + exec_command("apt-get update"); + exec_command("apt-get install -y curl"); + + my $curl_res = system("curl $download_path/ubuntu/18.04/$ubuntu_package_name -o$ubuntu_package_name"); + + if ($curl_res != 0) { + fast_die("Cannot download FastNetMon package"); + } + + my $install_res = system("apt install -y ./$ubuntu_package_name"); + + if ($install_res != 0) { + fast_die("Cannot install FastNetMon"); + } + + } elsif ($distro_version =~ m/^20\.04/) { + print "Install dependencies\n"; + exec_command("apt-get update"); + exec_command("apt-get install -y curl"); + + my $curl_res = system("curl $download_path/ubuntu/20.04/$ubuntu_package_name -o$ubuntu_package_name"); + + if ($curl_res != 0) { + fast_die("Cannot download FastNetMon package"); + } + + my $install_res = system("apt install -y ./$ubuntu_package_name"); + + if ($install_res != 0) { + fast_die("Cannot install FastNetMon"); + } + + } else { + fast_die("I'm sorry but we do not support Ubuntu $distro_version in current version, please check that you use LTS and stable distribution"); + } + } elsif ($distro_type eq 'debian') { + my $debian_package_name = "fastnetmon_1.1.6_amd64.deb"; + } elsif ($distro_type eq 'centos') { + + } else { + fast_die("I'm sorry but we do not support your Linux distribution $distro_type. Please raise GitHub issue if you want support for it: https://github.com/pavel-odintsov/fastnetmon"); + } + } else { + fast_die("I'm sorry but we do not support your operating system $os_type. Please raise GitHub issue if you want support for it: https://github.com/pavel-odintsov/fastnetmon"); + } + + exit(0); + } + $cpus_number = get_logical_cpus_number(); if (defined($ENV{'CIRCLECI'}) && $ENV{'CIRCLECI'}) {