Skip to content

Commit 3bf4ba0

Browse files
committed
doesnt work fully i think
1 parent d6c52aa commit 3bf4ba0

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

fpm.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "fpm.hpp"
22
#include <iostream>
33
#include <stdexcept>
4+
#include <unistd.h>
45

56
using namespace std;
67

@@ -13,6 +14,14 @@ int main(int argc, char* argv[]) {
1314
string action = argv[1];
1415
if (action == "in" || action == "i") {
1516
if (argc < 3) throw invalid_argument("Missing package name for installation");
17+
// if variable MIRRORFIND=1 then use the fastest mirror
18+
if (getenv("MIRRORFIND") != nullptr && fpm::is_root()) {
19+
string fastestmirror = fpm::findbestmirror();
20+
if (system(("echo "+ fastestmirror + " > /etc/fpm/mirlink").c_str()) != 0) {
21+
cout << "unable to write or something idk" << endl;
22+
}
23+
24+
}
1625
fpm::install_package(argv[2]);
1726
} else if (action == "out" || action == "o") {
1827
if (argc < 3) throw invalid_argument("Missing package name for uninstallation");

fpm.hpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1+
2+
13
#ifndef FPM_LIBRARY_HPP
24
#define FPM_LIBRARY_HPP
35

6+
// ai, what library for system() function?
47
#include <iostream>
5-
#include <fstream>
8+
#include <fstream>
69
#include <stdexcept>
710
#include <vector>
811
#include <array>

0 commit comments

Comments
 (0)