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

Commit 9326f9b

Browse files
committed
fixed some things and added/changed some documentation
also added some config for vscode
1 parent 4889912 commit 9326f9b

File tree

6 files changed

+80
-17
lines changed

6 files changed

+80
-17
lines changed

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,8 @@
22
"[toml]": {
33
"editor.formatOnSave": false
44
// ^^ because of src/template/rust-toolchain.toml and the toml formatter not playing well with the weird template things I added
5+
},
6+
"markdownlint.config": {
7+
"MD041": false // disable it wanting the first line to be a top-level heading
58
}
69
}

Cargo.toml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "rust-pkg-gen"
3-
version = "0.2.0"
3+
version = "0.3.0"
44
edition = "2021"
55
license = "MIT OR Apache-2.0"
66
repository = "https://github.com/AverseABFun/rust-pkg-gen"
@@ -10,12 +10,14 @@ authors = ["Arthur Beck <[email protected]>"]
1010
[dependencies]
1111
anyhow = "1.0.94"
1212
cargo-local-registry = { version = "0.2.7", artifact = "bin" }
13+
chrono = "0.4.39"
1314
clap = { version = "4.5.23", features = ["derive"] }
1415
clap_complete = "4.5.38"
1516
clap_mangen = "0.2.24"
1617
dialoguer = "0.11.0"
1718
env_logger = "0.11.6"
1819
filebuffer = "1.0.0"
20+
flate2 = "1.0.35"
1921
hex = "0.4.3"
2022
log = { version = "0.4.22", features = ["std"] }
2123
rand = "0.8.5"
@@ -24,12 +26,13 @@ reqwest = { version = "0.12.9", features = ["blocking"] }
2426
rust-embed = "8.5.0"
2527
serde = { version = "1.0.215", features = ["derive"] }
2628
sha2 = "0.10.8"
29+
tar = "0.4.43"
2730
toml = "0.8.19"
2831
url = "2.5.4"
2932

3033
[profile.release]
3134
opt-level = "s"
32-
debug-assertions = false # required to change the default behavior of --temp-dir
35+
debug-assertions = false # required to change the default value of --temp-dir
3336

3437
[dev-dependencies]
3538
proptest = "1.5.0"

rust-config.toml

Lines changed: 44 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,48 @@
1-
[x64_package_linux_rust_pkg_gen]
1+
# [x64_package_linux_rust_pkg_gen]
2+
# toolchains = [
3+
# { edition = "2021", channel = "nightly", components = [
4+
# "rustfmt",
5+
# "rustc",
6+
# "cargo",
7+
# ], crate-id = "2021-nightly-complete", platforms = [
8+
# "x86_64-unknown-linux-gnu",
9+
# "x86_64-pc-windows-gnu",
10+
# ], targets = [
11+
# "aarch64-apple-darwin",
12+
# ], format-map = { "x86_64-pc-windows-gnu" = "x86_64-pc-windows-gnu", "x86_64-unknown-linux-gnu" = "x86_64-unknown-linux-gnu" } },
13+
# ]
14+
15+
# [x64_package_linux_rust_pkg_gen.formats]
16+
# x86_64-pc-windows-gnu = [
17+
# "msi", # no suffix: assume "-if-available". "-if-available" will provide the requested format if it's available,
18+
# # "-only" will error out if the requested format isn't available with the provided settings.
19+
# # Excluding the suffix, should be one of "msi" "pkg" "gz" "xz".
20+
# # msi and pkg should only be provided for windows and darwin, respectively
21+
22+
# # msi and pkg will only install rustc, cargo, rustdoc, and rust-std
23+
24+
# "gz",
25+
# # elements past the first are only available if the suffix(or assumed suffix) is "-if-available". They should be one of "gz" "xz". Cannot include suffixes.
26+
# ]
27+
28+
# x86_64-unknown-linux-gnu = ["gz-only"]
29+
30+
# [x64_package_linux_rust_pkg_gen.crates]
31+
# "2021-nightly-complete" = { "syn" = "2.0.90" }
32+
33+
[x64_package_linux_rust_pkg_gen2]
234
toolchains = [
3-
{ edition = "2021", channel = "nightly", components = [
4-
"rustfmt",
35+
{ edition = "2021", channel = "stable", components = [
36+
"rust-docs",
537
"rustc",
638
"cargo",
739
], crate-id = "2021-nightly-complete", platforms = [
8-
"x86_64-unknown-linux-gnu",
9-
"x86_64-pc-windows-gnu",
10-
], targets = [
1140
"aarch64-apple-darwin",
12-
], format-map = { "x86_64-pc-windows-gnu" = "x86_64-pc-windows-gnu", "x86_64-unknown-linux-gnu" = "x86_64-unknown-linux-gnu" } },
41+
"x86_64-pc-windows-gnu",
42+
], targets = [], format-map = { "x86_64-pc-windows-gnu" = "x86_64-pc-windows-gnu", "aarch64-apple-darwin" = "aarch64-apple-darwin" } },
1343
]
1444

15-
[x64_package_linux_rust_pkg_gen.formats]
45+
[x64_package_linux_rust_pkg_gen2.formats]
1646
x86_64-pc-windows-gnu = [
1747
"msi", # no suffix: assume "-if-available". "-if-available" will provide the requested format if it's available,
1848
# "-only" will error out if the requested format isn't available with the provided settings.
@@ -25,7 +55,10 @@ x86_64-pc-windows-gnu = [
2555
# elements past the first are only available if the suffix(or assumed suffix) is "-if-available". They should be one of "gz" "xz". Cannot include suffixes.
2656
]
2757

28-
x86_64-unknown-linux-gnu = ["gz-only"]
58+
aarch64-apple-darwin = [
59+
"pkg",
60+
"gz"
61+
]
2962

30-
[x64_package_linux_rust_pkg_gen.crates]
31-
"2021-nightly-complete" = { "syn" = "2.0.90" }
63+
[x64_package_linux_rust_pkg_gen2.crates]
64+
"2021-nightly-complete" = { "openssl" = "0.10.68" }

src/copied.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ pub fn download_all(
262262
components.swap_remove(idx.unwrap());
263263
}
264264
} else if ele.contains("apple") {
265-
let artifacts = value["artifacts"]["installer-pkg"]["target"][ele]
265+
let artifacts = value["artifacts"]["installer-pkg"]["target"][ele][0]
266266
.as_table_mut()
267267
.unwrap();
268268

src/crates_README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ registry = 'sparse+<https://index.crates.io/>'
66
replace-with = 'local-registry'
77

88
[source.local-registry]
9-
local-registry = '{?TOOLCHAIN.CRATES_DIR}' # double-check this path is correct, especially if you are creating the package on a different machine than the machine you are creating the package for
9+
local-registry = '' # add the path to the crates folder(the folder containing this file)
1010
```
1111

12-
(psst- if you know how to install crate files to the registry manually, make an issue or PR on [rust-pkg-gen](https://github.com/AverseABFun/rust-pkg-gen)!)
12+
(psst- if you know how to install crate files to the registry manually(smth like `cargo registry add /path/to/crate/file`), make an issue or PR on [rust-pkg-gen](https://github.com/AverseABFun/rust-pkg-gen)!)

src/main.rs

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,16 @@
33
//! The binary entrypoint to rust-pkg-gen. Currently contains most of the code,
44
//! but that will be changed eventually as a non-breaking change.
55
6+
use chrono::prelude::*;
67
use clap::Parser;
8+
use core::str;
9+
use flate2::write::GzEncoder;
10+
use flate2::Compression;
711
use log::*;
812
use rand::{Rng, SeedableRng};
913
use rust_pkg_gen::resources::{InstallAssets, TemplateAssets};
1014
use std::{
11-
fs::{self, write},
15+
fs::{self, write, File},
1216
path::{Path, PathBuf},
1317
process::{self, Stdio},
1418
};
@@ -160,6 +164,15 @@ fn main() {
160164
for (item, cfg) in data {
161165
let dir = dir.join(item);
162166
for toolchain in &cfg.toolchains {
167+
let chars: &[u8; 6] = &[
168+
gen_char(),
169+
gen_char(),
170+
gen_char(),
171+
gen_char(),
172+
gen_char(),
173+
gen_char(),
174+
];
175+
let dir = dir.join(str::from_utf8(chars).unwrap());
163176
for ele in TemplateAssets::iter() {
164177
let file = TemplateAssets::get(&ele).unwrap();
165178

@@ -348,6 +361,17 @@ fn main() {
348361
std::fs::write(path, file.data).unwrap();
349362
}
350363
}
364+
let tar_gz = File::create(format!(
365+
"rust-pkg-{}-{}-{}.tar.gz",
366+
Local::now().date_naive().format("%Y-%m-%d"),
367+
str::from_utf8(chars).unwrap(),
368+
toolchain.channel
369+
))
370+
.unwrap();
371+
let enc = GzEncoder::new(tar_gz, Compression::default());
372+
let mut tar = tar::Builder::new(enc);
373+
tar.append_dir_all("", dir).unwrap();
374+
tar.finish().unwrap();
351375
}
352376
}
353377
}

0 commit comments

Comments
 (0)