Skip to content

Commit

Permalink
app-misc/meilisearch Replace Python autogen with YAML-based generator…
Browse files Browse the repository at this point in the history
… for Meilisearch

- replaced the Python autogen script with a YAML generator
- adjusted templates
-
- added network-sandbox restriction as custom build command of lindera-ko-dic building requests a download during compiling
```
workstation-mark-repo ~ # cat /var/tmp/portage/app-misc/meilisearch-1.12.0/work/cargo_home/gentoo/lindera-ko-dic-0.32.2/build.rs
use std::error::Error;

#[cfg(feature = "ko-dic")]
fn main() -> Result<(), Box<dyn Error>> {
    lindera_assets::fetch(
        lindera_assets::FetchParams {
            file_name: "mecab-ko-dic-2.1.1-20180720.tar.gz",
            input_dir: "mecab-ko-dic-2.1.1-20180720",
            output_dir: "lindera-ko-dic",
            download_url: "https://dlwqk3ibdg1xh.cloudfront.net/mecab-ko-dic-2.1.1-20180720.tar.gz",
            dummy_input: "테스트,1785,3543,4721,NNG,행위,F,테스트,*,*,*,*\n",
        },
        lindera_ko_dic_builder::ko_dic_builder::KoDicBuilder::new(),
    )
}

#[cfg(not(feature = "ko-dic"))]
fn main() -> Result<(), Box<dyn Error>> {
    Ok(())
}
```

(cherry picked from commit f6603f1c79600a254002dd1ad11e9f11d4724150)
(cherry picked from commit 355c931721d2818d83ea13d075b70c88acdb69e4)
  • Loading branch information
org-tekeli-borisp committed Dec 29, 2024
1 parent 5aa84b2 commit 1de5d80
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 82 deletions.
61 changes: 0 additions & 61 deletions core-server-kit/curated/app-misc/meilisearch/autogen.py

This file was deleted.

8 changes: 8 additions & 0 deletions core-server-kit/curated/app-misc/meilisearch/autogen.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
meilisearch_rule:
generator: github-1
packages:
- meilisearch:
github:
query: releases
extensions:
- rust
Original file line number Diff line number Diff line change
Expand Up @@ -21,37 +21,21 @@ BDEPEND="

S="${WORKDIR}/{{ github_user }}-{{ github_repo }}-{{ sha[:7] }}"

RESTRICT="network-sandbox"

MEILI_DATA_DIR="/var/lib/${PN}"

pkg_setup() {
enewgroup "${PN}"
enewuser "${PN}" -1 -1 "${MEILI_DATA_DIR}" "${PN}"
}

src_prepare() {
default

# Patch lindera-unidic to use the unidic-mecab src downloaded by the ebuild
local lindera_unidic_build=$(find "${WORKDIR}"/cargo_home/gentoo/lindera-unidic-* -iname build.rs)

# Replace the input/unpacked folder with our version
sed -i 's|\(let input_dir =.*\)\("unidic-mecab.*"\)\(.*\)|\1"{{ unidic.final_name.rsplit(".", 1)[0] }}"\3|' "${lindera_unidic_build}"

# Replace the path to the source with the one downloaded by the ebuild
sed -i "s|\(let source_path_for_build =\).*$|\1 Path::new("'"'"${DISTDIR}/{{ unidic.final_name }}"'"'");|" "${lindera_unidic_build}"

if use mini-dashboard; then
# Inject path to downloaded mini-dashboard build
sed -i "s|{{ dashboard_url }}|${DISTDIR}/{{ artifacts["mini-dashboard"][0].final_name }}|g" "${S}"/meilisearch/Cargo.toml

# Replace HTTP fetch with direct file read
sed -i -r 's|(let dashboard_assets_bytes =)(.*)$|\1 std::fs::read(url)?;|' "${S}"/meilisearch/build.rs
fi
src_unpack() {
cargo_src_unpack
}

src_configure() {
CARGO_FEATURES=(
"analytics"
"meilisearch-types/all-tokenizations"
"$(usex mini-dashboard mini-dashboard '')"
)
Expand All @@ -68,7 +52,7 @@ src_compile() {
}

src_install() {
cargo_src_install --path meilisearch --frozen \
cargo_src_install --path crates/meilisearch --frozen \
--no-default-features ${CARGO_FEATURES:+--features "${CARGO_FEATURES[*]}"}

mkdir -p "${ED}"/"${MEILI_DATA_DIR}"
Expand Down

0 comments on commit 1de5d80

Please sign in to comment.