This repository has been archived by the owner on May 2, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 0
WIP Pacbuild Parser #94
Draft
wizard-28
wants to merge
3
commits into
oxidation
Choose a base branch
from
feat/pacbuild-parser
base: oxidation
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,9 +3,9 @@ name = "libpacstall" | |
version = "0.1.0" | ||
edition = "2021" | ||
authors = [ | ||
"Sourajyoti Basak <[email protected]>", | ||
"David Brochero <[email protected]>", | ||
"Paul Cosma <[email protected]>" | ||
"Sourajyoti Basak <[email protected]>", | ||
"David Brochero <[email protected]>", | ||
"Paul Cosma <[email protected]>", | ||
] | ||
description = "Backend API library for Pacstall" | ||
repository = "https://github.com/pacstall/libpacstall" | ||
|
@@ -14,9 +14,28 @@ keywords = ["aur", "pacstall", "package-manager", "linux", "apt"] | |
categories = ["caching", "config", "parsing", "os::linux-apis"] | ||
|
||
[dependencies] | ||
figment = { version = "0.10.6", features = ["env", "test", "toml" ] } | ||
figment = { version = "0.10.6", features = ["env", "test", "toml"] } | ||
miette = "5.5.0" | ||
num_cpus = "1.13.1" | ||
regex = "1.7.0" | ||
semver = "1.0.14" | ||
serde = { version = "1.0.144", features = ["derive"] } | ||
spdx = "0.10.0" | ||
strum = { version = "0.24.1", features = ["derive"] } | ||
thiserror = "1.0.37" | ||
tree-sitter = "0.19" | ||
tree-sitter-bash = "0.19.0" | ||
|
||
[dev-dependencies] | ||
rstest = "0.15.0" | ||
miette = { version = "5.5.0", features = ["fancy"] } | ||
criterion = { version = "0.4.0", features = ["html_reports"] } | ||
rstest = "0.16.0" | ||
proptest = "1.0.0" | ||
|
||
|
||
[[example]] | ||
name = "parser" | ||
|
||
[[bench]] | ||
name = "parser" | ||
harness = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
use criterion::{black_box, criterion_group, criterion_main, Criterion}; | ||
use libpacstall::parser::pacbuild::PacBuild; | ||
|
||
pub fn criterion_benchmark(c: &mut Criterion) { | ||
c.bench_function("parser", |b| b.iter(|| PacBuild::from_source(black_box(r#"pkgname='potato' # can also be an array, probably shouldn't be though | ||
pkgver='1.0.0' # this is the variable pkgver, can also be a function that will return dynamic version | ||
epoch='0' # force package to be seen as newer no matter what | ||
pkgdesc='Pretty obvious' | ||
url='https://potato.com' | ||
license="Apache-2.0 OR MIT" | ||
arch=('any' 'x86_64') | ||
maintainer=('Henryws <[email protected]>' 'Wizard-28 <[email protected]> <[email protected]>') | ||
repology=("project: $pkgname") | ||
source=( | ||
"https://potato.com/$pkgver.tar.gz" | ||
"potato.tar.gz::https://potato.com/$pkgver.tar.gz" # with a forced download name | ||
"$pkgname::git+https://github.com/pacstall/pacstall" # git repo | ||
"$pkgname::https://github.com/pacstall/pacstall/releases/download/2.0.1/pacstall-2.0.1.deb::repology" # use changelog with repology | ||
"$pkgname::git+https://github.com/pacstall/pacstall#branch=master" # git repo with branch | ||
"$pkgname::git+file://home/henry/pacstall/pacstall" # local git repo | ||
"magnet://xt=urn:btih:c4769d7000244e4cae9c054a83e38f168bf4f69f&dn=archlinux-2022.09.03-x86_64.iso" # magnet link | ||
"ftp://ftp.gnu.org/gnu/$pkgname/$pkgname-$pkgver.tar.xz" # ftp | ||
"patch-me-harder.patch::https://potato.com/patch-me.patch" | ||
) # also source_x86_64=(), source_i386=() | ||
|
||
noextract=( | ||
"$pkgver.tar.gz" | ||
) | ||
|
||
sha256sums=( | ||
'e69fcf51c211772d4f193f3dc59b1e91607bea7e53999f1d5e03ba401e5da969' | ||
'SKIP' | ||
'SKIP' | ||
'etc' | ||
) # can also do sha256sums_x86_64=(), repeat for sha384, sha512, and b2 | ||
|
||
optdepends=( | ||
'same as pacstall: yes' | ||
) # rince and repeat optdepends_$arch=() | ||
|
||
depends=( | ||
'hashbrowns>=1.8.0' | ||
'mashed-potatos<=1.9.0' | ||
'gravy=2.3.0' | ||
'applesauce>3.0.0' | ||
'chicken<2.0.0' | ||
'libappleslices.so' | ||
'libdeepfryer.so=3' | ||
) | ||
|
||
makedepends=( | ||
'whisk' | ||
'onions' | ||
) | ||
|
||
checkdepends=( | ||
'customer_satisfaction' | ||
) | ||
|
||
ppa=('mcdonalds/ppa') | ||
|
||
provides=( | ||
'mashed-potatos' | ||
'aaaaaaaaaaaaaaaaaaaaaaaaaa' | ||
) | ||
|
||
conflicts=( | ||
'KFC' | ||
'potato_rights' | ||
) # can also do conflicts_$arch=() | ||
|
||
replaces=( | ||
'kidney_beans' | ||
) | ||
|
||
backup=( | ||
'etc/potato/prepare.conf' | ||
) | ||
|
||
options=( | ||
'!strip' | ||
'!docs' | ||
'etc' | ||
) | ||
|
||
groups=('potato-clan') | ||
|
||
incompatible=('debian::jessy' 'ubuntu::20.04') | ||
|
||
prepare() { | ||
cd "$pkgname-$pkgver" | ||
patch -p1 -i "$srcdir/patch-me-harder.patch" | ||
} | ||
|
||
build() { | ||
cd "$pkgname-$pkgver" | ||
./configure --prefix=/usr | ||
make | ||
} | ||
|
||
check() { | ||
cd "$pkgname-$pkgver" | ||
make -k check | ||
} | ||
|
||
package() { | ||
cd "$pkgname-$pkgver" | ||
make DESTDIR="$pkgdir/" install | ||
} | ||
|
||
pre_install() { | ||
echo "potato" | ||
} | ||
|
||
post_install() { | ||
echo "potato" | ||
} | ||
|
||
pre_upgrade() { | ||
echo "potato" | ||
} | ||
|
||
post_upgrade() { | ||
echo "potato" | ||
} | ||
|
||
pre_remove() { | ||
echo "potato" | ||
} | ||
|
||
post_remove() { | ||
echo "potato" | ||
}"# | ||
)))); | ||
} | ||
|
||
criterion_group!(benches, criterion_benchmark); | ||
criterion_main!(benches); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
use libpacstall::parser::pacbuild::PacBuild; | ||
use miette::Result; | ||
|
||
fn main() -> Result<()> { | ||
let k = 0; | ||
dbg!(PacBuild::from_source( | ||
r#" | ||
pkgname='te' | ||
pkgver="1.0" | ||
epoch="21" | ||
arch=("any") | ||
#maintainer=("foo <" "bar <>" "biz <[email protected]> <[email protected]>") | ||
license="MIT" | ||
ppa=("lol/kol") | ||
#depends=("foods" "bar: h") | ||
#optdepends=("foo: ldsfadvnvbnvbnvnvnnvbnfds") | ||
repology=("project: foo" "visiblename: distrotube") | ||
sources=("git+file:///home/wizard/tmp/::repology") | ||
"# | ||
.trim(), | ||
)?); | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Seeds for failure cases proptest has generated in the past. It is | ||
# automatically read and these particular cases re-run before any | ||
# novel cases are generated. | ||
# | ||
# It is recommended to check this file in to source control so that | ||
# everyone who runs the test benefits from these saved cases. | ||
cc d852d8ab1865b7cd6cd0a169b0f9623924b087f06f45c37b71dd755c2905d17b # shrinks to version = "¡" | ||
# Seeds for failure cases proptest has generated in the past. It is | ||
# automatically read and these particular cases re-run before any | ||
# novel cases are generated. | ||
# | ||
# It is recommended to check this file in to source control so that | ||
# everyone who runs the test benefits from these saved cases. | ||
cc c0a8aeb72996e589b4531ff434ba0cf3a78d285d0d331e57fa01ec711cf65b74 # shrinks to name = "¡" | ||
cc f1c3f577e82492bf2b437a5ea82df991eeff728a04009f6306f3f3bcfc5251d8 # shrinks to name = "-" | ||
cc e5174aa9101b6422efc1327ce3176df895036712ab6d21082731d199cfeac9b2 # shrinks to name = ".a" | ||
cc 4a837b559db189d9f3b4be4819eb293b163a433e3e9d50f476844096ff5e3c86 # shrinks to name = "z" | ||
cc 3e96b46990a80964a0d69f13de029db178dab8dac811353ad973c5fee2b85ac3 # shrinks to name = "" | ||
cc 6d1545dad9462e6e30fdf91f1a25462532b2e40327bb36a8c7a9bd152a37610e # shrinks to name = "0" | ||
cc de06beeedfa5666db998956db96183abf32ffa4a551fe22b0826242bf7535ccb # shrinks to name = ":", version_req = "0" | ||
cc b1b6390f4ec735609c5351febfee2a0d8a3b1b7895c3d03ace0e888a4b4efc53 # shrinks to name = "\t", email = "[email protected]" | ||
cc 506f616e095e77967291c2782e927324b41cef3302f04809a2230c5c057e7ca4 # shrinks to value = "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
use miette::{Diagnostic, Report, SourceSpan}; | ||
use thiserror::Error; | ||
|
||
#[derive(Debug, Diagnostic, Error)] | ||
#[error("Parser error")] | ||
pub struct ParseError { | ||
/// Source code. | ||
#[source_code] | ||
pub input: String, | ||
|
||
#[related] | ||
pub related: Vec<Report>, | ||
} | ||
|
||
#[derive(Debug, Diagnostic, Clone, Eq, PartialEq, Error)] | ||
#[error("Invalid field")] | ||
pub struct FieldError { | ||
/// States the issues with the field. | ||
pub field_label: String, | ||
|
||
/// Span of the field which has the error. | ||
#[label("{field_label}")] | ||
pub field_span: SourceSpan, | ||
|
||
/// Span of the erroneous source code. | ||
#[label("here")] | ||
pub error_span: SourceSpan, | ||
|
||
/// Suggestion for fixing the parser error. | ||
#[help] | ||
pub help: String, | ||
} | ||
|
||
#[derive(Debug, Diagnostic, Clone, Eq, PartialEq, Error)] | ||
#[error("Missing field")] | ||
pub struct MissingField { | ||
pub label: &'static str, | ||
} | ||
|
||
#[derive(Debug, Diagnostic, Clone, Eq, PartialEq, Error)] | ||
#[error("Bad syntax")] | ||
pub struct BadSyntax; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
pub mod errors; | ||
pub mod pacbuild; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use your crates.io name and email