Skip to content
This repository was archived by the owner on Mar 6, 2025. It is now read-only.

Commit 2d14871

Browse files
committed
Initial commit
0 parents  commit 2d14871

File tree

8 files changed

+337
-0
lines changed

8 files changed

+337
-0
lines changed

.github/workflows/release.yml

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
permissions:
9+
contents: write
10+
packages: write
11+
12+
env:
13+
CARGO_TERM_COLOR: always
14+
15+
jobs:
16+
Fedora-Freedom_build:
17+
runs-on: ubuntu-latest
18+
19+
steps:
20+
- uses: actions/checkout@v4
21+
22+
- name: Install musl-tools
23+
run: sudo apt-get update && sudo apt-get install musl-tools
24+
25+
- name: Cache Cargo registry
26+
uses: actions/cache@v4
27+
with:
28+
path: ~/.cargo/registry
29+
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
30+
restore-keys: ${{ runner.os }}-cargo-registry-
31+
32+
- name: Cache Cargo index
33+
uses: actions/cache@v4
34+
with:
35+
path: ~/.cargo/git
36+
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
37+
restore-keys: ${{ runner.os }}-cargo-index-
38+
39+
- name: Install Rust
40+
uses: dtolnay/rust-toolchain@stable
41+
with:
42+
targets: x86_64-unknown-linux-musl
43+
44+
- name: Install cross-rs for cross-compilation
45+
run: cargo install cross
46+
47+
- name: Build x86_64 binary
48+
run: cargo build --target-dir=build --release --verbose --target=x86_64-unknown-linux-musl --all-features
49+
50+
- name: Create and Upload Release
51+
id: create_release
52+
uses: softprops/action-gh-release@v2
53+
with:
54+
tag_name: ${{ github.ref_name }}
55+
name: Release ${{ github.ref_name }}
56+
files: |
57+
build/x86_64-unknown-linux-musl/release/Fedora-Freedom
58+
env:
59+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/target
2+
Cargo.lock

Cargo.toml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[package]
2+
name = "Fedora-Freedom"
3+
version = "0.1.0"
4+
edition = "2021"
5+
description = "Fedora setup wizard written in Rust"
6+
license = "MIT"
7+
authors = ["Angaddeep Singh <[email protected]>"]
8+
repository = "https://github.com/Angxddeep/Fedora-Freedom"
9+
10+
[dependencies]
11+
dialoguer = "0.11.0"
12+
colored = "2.0"

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 Angaddeep Singh
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Fedora-Freedom
2+
3+
As you know, Fedora only comes with support for free software by default. So this Project gives you the freedom to install non-free software. By downloading this script, you can install things like important multimedia codecs for video decoding and even proprietary drivers for NVIDIA GPUs and much more.
4+
5+
6+
# 💡 Usage
7+
8+
```
9+
bash -c "$(curl -fsSL "https://raw.githubusercontent.com/Angxddeep/Fedora-Freedom/main/run.sh")"
10+
```
11+
12+
13+
14+
15+

dnf.conf

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# see `man dnf.conf` for defaults and possible options
2+
3+
[main]
4+
gpgcheck=1
5+
installonly_limit=3
6+
clean_requirements_on_remove=True
7+
best=True
8+
skip_if_unavailable=False
9+
max_parallel_downloads=15
10+
defaultyes=True

run.sh

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/bin/sh -e
2+
3+
# Prevent execution if this script was only partially downloaded
4+
{
5+
rc='\033[0m'
6+
red='\033[0;31m'
7+
8+
check() {
9+
exit_code=$1
10+
message=$2
11+
12+
if [ "$exit_code" -ne 0 ]; then
13+
printf '%sERROR: %s%s\n' "$red" "$message" "$rc"
14+
exit 1
15+
fi
16+
17+
unset exit_code
18+
unset message
19+
}
20+
21+
findArch() {
22+
case "$(uname -m)" in
23+
x86_64|amd64) arch="x86_64" ;;
24+
*) check 1 "Unsupported architecture. Only x86_64 is supported."
25+
esac
26+
}
27+
28+
getUrl() {
29+
echo "https://github.com/Angxddeep/Fedora-Freedom/releases/latest/download/Fedora-Freedom"
30+
}
31+
32+
findArch
33+
temp_file=$(mktemp)
34+
check $? "Creating the temporary file"
35+
36+
curl -fsL "$(getUrl)" -o "$temp_file"
37+
check $? "Downloading linutil"
38+
39+
chmod +x "$temp_file"
40+
check $? "Making linutil executable"
41+
42+
"$temp_file" "$@"
43+
check $? "Executing linutil"
44+
45+
rm -f "$temp_file"
46+
check $? "Deleting the temporary file"
47+
} # End of wrapping

src/main.rs

+171
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
use std::process::{Command, Stdio};
2+
use std::io;
3+
use dialoguer::{Select, Confirm};
4+
use colored::*;
5+
6+
// Color-coded output
7+
fn color_echo(color: &str, text: &str) {
8+
match color {
9+
"red" => println!("{}", text.red()),
10+
"green" => println!("{}", text.green()),
11+
"yellow" => println!("{}", text.yellow()),
12+
"blue" => println!("{}", text.blue()),
13+
_ => println!("{}", text),
14+
}
15+
}
16+
17+
fn add_flathub() {
18+
color_echo("yellow", "Adding Flathub...");
19+
let status = Command::new("flatpak")
20+
.args(&["remote-add", "--if-not-exists", "flathub", "https://dl.flathub.org/repo/flathub.flatpakrepo"])
21+
.stdout(Stdio::inherit())
22+
.stderr(Stdio::inherit())
23+
.status()
24+
.expect("Failed to add Flathub");
25+
26+
if status.success() {
27+
color_echo("green", "Flathub added");
28+
}
29+
}
30+
31+
fn install_rpm_fusion() {
32+
println!("Installing RPM Fusion...");
33+
34+
let status = Command::new("sudo")
35+
.args(&[
36+
"dnf",
37+
"install",
38+
"-y",
39+
"rpmfusion-free-release",
40+
"rpmfusion-nonfree-release",
41+
])
42+
.stdout(Stdio::inherit())
43+
.stderr(Stdio::inherit())
44+
.status()
45+
.expect("Failed to install RPM Fusion");
46+
47+
if status.success() {
48+
println!("RPM Fusion installed successfully");
49+
} else {
50+
eprintln!("Failed to install RPM Fusion");
51+
}
52+
}
53+
54+
fn install_ffmpeg() {
55+
color_echo("yellow", "Installing FFmpeg...");
56+
let status = Command::new("sudo")
57+
.args(&["dnf", "swap", "ffmpeg-free", "ffmpeg", "--allowerasing", "-y"])
58+
.stdout(Stdio::inherit())
59+
.stderr(Stdio::inherit())
60+
.status()
61+
.expect("Failed to install FFmpeg");
62+
63+
if status.success() {
64+
color_echo("green", "FFmpeg installed");
65+
} else {
66+
color_echo("red", "Failed to install FFmpeg");
67+
}
68+
}
69+
70+
fn get_user_choice(prompt: &str, choices: &[&str]) -> usize {
71+
Select::new()
72+
.with_prompt(prompt)
73+
.items(choices)
74+
.default(0)
75+
.interact()
76+
.expect("Failed to read user input")
77+
}
78+
79+
fn install_drivers(cpu_info: &str, gpu_info: &str) {
80+
if cpu_info == "INTEL" || gpu_info == "INTEL" {
81+
Command::new("sudo")
82+
.args(&["dnf", "install", "intel-media-driver", "-y"])
83+
.status()
84+
.expect("Failed to install Intel drivers");
85+
}
86+
87+
if cpu_info == "AMD" || gpu_info == "AMD" {
88+
Command::new("sudo")
89+
.args(&["dnf", "swap", "mesa-va-drivers", "mesa-va-drivers-freeworld", "-y"])
90+
.status()
91+
.expect("Failed to install AMD drivers");
92+
Command::new("sudo")
93+
.args(&["dnf", "swap", "mesa-vdpau-drivers", "mesa-vdpau-drivers-freeworld", "-y"])
94+
.status()
95+
.expect("Failed to install AMD drivers");
96+
}
97+
98+
if gpu_info == "NVIDIA" {
99+
color_echo("red", "Make sure you are on the latest kernel version!");
100+
color_echo("red", "Make sure secure boot is off.");
101+
Command::new("sudo")
102+
.args(&["dnf", "install", "akmod-nvidia", "xorg-x11-drv-nvidia-cuda", "-y"])
103+
.status()
104+
.expect("Failed to install NVIDIA drivers");
105+
color_echo("blue", "Wait for 5 minutes for the kernel modules to build or check the status using:");
106+
color_echo("blue", "modinfo -F version nvidia");
107+
}
108+
}
109+
110+
fn configure_dnf() {
111+
if Confirm::new()
112+
.with_prompt("Do you want to do some tweaks to DNF (Recommended)?")
113+
.interact()
114+
.unwrap()
115+
{
116+
let status = Command::new("curl")
117+
.args(&["-o", "/tmp/dnf.conf", "https://raw.githubusercontent.com/Angxddeep/Fedora-Freedom/refs/heads/main/dnf.conf"])
118+
.status()
119+
.expect("Failed to download DNF configuration");
120+
121+
if status.success() {
122+
Command::new("sudo")
123+
.args(&["cp", "/tmp/dnf.conf", "/etc/dnf/dnf.conf"])
124+
.status()
125+
.expect("Failed to update DNF configuration");
126+
color_echo("green", "DNF configuration updated.");
127+
} else {
128+
color_echo("red", "Failed to download DNF configuration.");
129+
}
130+
} else {
131+
color_echo("yellow", "No changes made to DNF configuration.");
132+
}
133+
}
134+
135+
fn main() {
136+
color_echo("blue", "Fedora Setup Wizard");
137+
138+
if Confirm::new()
139+
.with_prompt("Add Flathub?")
140+
.interact()
141+
.unwrap()
142+
{
143+
add_flathub();
144+
}
145+
146+
if Confirm::new()
147+
.with_prompt("Install RPM Fusion?")
148+
.interact()
149+
.unwrap()
150+
{
151+
install_rpm_fusion();
152+
}
153+
154+
install_ffmpeg();
155+
156+
let cpu_choices = ["INTEL", "AMD"];
157+
let cpu_choice = get_user_choice("Select your CPU manufacturer:", &cpu_choices);
158+
let cpu_info = cpu_choices[cpu_choice];
159+
160+
let gpu_choices = ["INTEL", "AMD", "NVIDIA"];
161+
let gpu_choice = get_user_choice("Select your GPU manufacturer:", &gpu_choices);
162+
let gpu_info = gpu_choices[gpu_choice];
163+
164+
color_echo("yellow", "You have provided the following:");
165+
color_echo("red", &format!("CPU: {}", cpu_info));
166+
color_echo("red", &format!("GPU: {}", gpu_info));
167+
168+
install_drivers(cpu_info, gpu_info);
169+
170+
configure_dnf();
171+
}

0 commit comments

Comments
 (0)