chore: import upstream snapshot with attribution

This commit is contained in:
wehub-resource-sync
2026-07-13 12:08:36 +08:00
commit 93bdeb5e95
383 changed files with 83019 additions and 0 deletions
+20
View File
@@ -0,0 +1,20 @@
[Desktop Entry]
Version=1.0
Type=Application
Name=Lapce
Comment=Lightning-fast and powerful code editor written in Rust
Categories=Development;IDE;
GenericName=Code Editor
StartupWMClass=lapce
Icon=dev.lapce.lapce
Exec=lapce %F
Terminal=false
MimeType=text/plain;inode/directory;
Actions=new-window;
[Desktop Action new-window]
Name=New Window
Exec=lapce --new %F
Icon=dev.lapce.lapce
+63
View File
@@ -0,0 +1,63 @@
<?xml version="1.0" encoding="UTF-8"?>
<component type="desktop-application">
<id>dev.lapce.lapce</id>
<name>Lapce</name>
<developer_name>Dongdong Zhou, et al.</developer_name>
<summary>Lightning-fast and powerful code editor written in Rust</summary>
<metadata_license>MIT</metadata_license>
<project_license>Apache-2.0</project_license>
<url type="homepage">https://lapce.dev/</url>
<url type="bugtracker">https://github.com/lapce/lapce/issues</url>
<url type="help">https://docs.lapce.dev/</url>
<categories>
<category>IDE</category>
<category>Development</category>
</categories>
<description>
<p>
Lapce is an open source code editor written in Rust. By utilising native GUI and GPU rendering, and with the performance Rust provides, Lapce is one of the fastest code editors out there.
</p>
<p>Features:</p>
<ul>
<li>Modal Editing (Vim like) support as first class citizen (can be turned off as well)</li>
<li>Built-in LSP (Language Server Protocol) support to give you code intelligence like code completion, diagnostics and code actions etc.</li>
<li>Built-in remote development support (inspired by VSCode Remote Development) for a seamless "local" experience, benefiting from the full power of the remote system.</li>
<li>Plugins can be written in programming languages that can compile to the WASI format (C, Rust, AssemblyScript)</li>
<li>Built-in terminal, so you can execute commands in your workspace, without leaving Lapce.</li>
</ul>
</description>
<content_rating type="oars-1.1" />
<launchable type="desktop-id">dev.lapce.lapce.desktop</launchable>
<screenshots>
<screenshot type="default" environment="plasma">
<caption>Lapce source project opened in Lapce with Rust source code file opened</caption>
<image type="source" width="1000" height="700">https://raw.githubusercontent.com/lapce/lapce/refs/tags/v0.4.5/extra/images/linux/code-file-with-highlight.png</image>
</screenshot>
</screenshots>
<releases>
<release version="0.4.6" date="2026-01-21">
<url type="details">https://github.com/lapce/lapce/releases/tag/v0.4.6</url>
<issues>
<issue url="https://github.com/lapce/lapce/issues/3821">#3821</issue>
<issue url="https://github.com/lapce/lapce/issues/3832">#3832</issue>
<issue url="https://github.com/lapce/lapce/pull/3818">#3818</issue>
<issue url="https://github.com/lapce/lapce/pull/3819">#3819</issue>
</issues>
</release>
<release version="0.4.5" date="2025-09-05">
<url type="details">https://github.com/lapce/lapce/releases/tag/v0.4.5</url>
<issues>
<issue url="https://github.com/lapce/lapce/issues/3795">#3795</issue>
</issues>
</release>
<release version="0.4.4" date="2025-08-30">
<url type="details">https://github.com/lapce/lapce/releases/tag/v0.4.4</url>
<issues>
<issue url="https://github.com/lapce/lapce/issues/3786">#3795</issue>
</issues>
</release>
<release version="0.4.3" date="2024-06-27">
<url type="details">https://github.com/lapce/lapce/releases/tag/v0.4.3</url>
</release>
</releases>
</component>
+123
View File
@@ -0,0 +1,123 @@
# syntax=docker/dockerfile:1
ARG DISTRIBUTION_VERSION
ARG RUST_VERSION
ARG XX_VERSION=latest
FROM --platform=$BUILDPLATFORM tonistiigi/xx:${XX_VERSION} AS xx
FROM --platform=$BUILDPLATFORM rust:${RUST_VERSION}-alpine${DISTRIBUTION_VERSION} AS build-base
COPY --from=xx / /
SHELL [ "/bin/ash", "-c" ]
# install host dependencies
ARG DISTRIBUTION_PACKAGES
RUN \
--mount=type=cache,target=/var/cache/apk,sharing=private \
--mount=type=cache,target=/etc/apk/cache,sharing=private \
<<EOF
apk upgrade -Ua
apk add --no-cache \
bash clang lld llvm file git sccache \
cmake pkgconf build-base abuild curl mold \
${DISTRIBUTION_PACKAGES}
EOF
SHELL [ "/bin/bash", "-c" ]
WORKDIR /source
COPY --link . .
FROM build-base AS build-prep
ENV CARGO_REGISTRIES_CRATES_IO_PROTOCOL='sparse'
ENV CARGO_TARGET_DIR='/root/.cache/rust'
RUN \
--mount=type=cache,target=/cargo/git/db,sharing=locked \
--mount=type=cache,target=/cargo/registry/cache,sharing=locked \
--mount=type=cache,target=/cargo/registry/index,sharing=locked \
<<EOF
#!/usr/bin/env bash
set -euxo pipefail
xx-cargo fetch --locked
EOF
# Install target dependencies
ARG TARGETPLATFORM
ARG DISTRIBUTION_PACKAGES
RUN \
--mount=type=cache,target=/var/cache/apk,sharing=private \
--mount=type=cache,target=/etc/apk/cache,sharing=private \
<<EOF
#!/usr/bin/env bash
set -euxo pipefail
xx-apk add \
"xx-cxx-essentials" \
${DISTRIBUTION_PACKAGES}
EOF
FROM build-prep AS build
ARG PACKAGE_NAME
ENV PACKAGE_NAME="${PACKAGE_NAME}"
ARG OUTPUT_DIR="/output"
ENV OUTPUT_DIR="${OUTPUT_DIR}"
ARG CARGO_BUILD_INCREMENTAL='false'
ENV CARGO_TARGET_DIR='/root/.cache/rust'
ARG RELEASE_TAG_NAME
ENV RELEASE_TAG_NAME="${RELEASE_TAG_NAME}"
RUN \
--mount=type=cache,target=/cargo/git/db,sharing=locked \
--mount=type=cache,target=/cargo/registry/cache,sharing=locked \
--mount=type=cache,target=/cargo/registry/index,sharing=locked \
--mount=type=cache,target=/root/.cache,sharing=private \
<<EOF
#!/usr/bin/env bash
set -euxo pipefail
xx-clang --setup-target-triple
xx-clang --wrap
if ! xx-info is-cross; then
export OPENSSL_DIR="/usr"
else
export OPENSSL_DIR="/$(xx-info triple)/usr"
fi
export LIBZ_SYS_STATIC="1"
export LIBSSH2_STATIC="1"
export LIBGIT2_STATIC="1"
export OPENSSL_STATIC="1"
export PKG_CONFIG_ALL_STATIC="1"
export OPENSSL_NO_VENDOR="1"
export ZSTD_SYS_USE_PKG_CONFIG="1"
export RUSTFLAGS="-C linker=clang -C link-arg=-fuse-ld=mold -C target-feature=+crt-static"
export PKG_CONFIG="$(xx-clang --print-prog-name=pkg-config)"
xx-cargo build \
--verbose \
--frozen \
--bin lapce-proxy \
--profile release-lto \
--no-default-features
xx-verify "${CARGO_TARGET_DIR}"/"$(xx-cargo --print-target-triple)"/release-lto/lapce-proxy
mkdir -p /target
mv -v "${CARGO_TARGET_DIR}"/"$(xx-cargo --print-target-triple)"/release-lto/lapce-proxy /usr/local/bin/
EOF
FROM build-prep AS dev
FROM scratch AS binary
COPY --from=build /usr/local/bin/lapce-proxy .
FROM scratch AS cross-binary
COPY --from=build /usr/local/bin/lapce-proxy .
+186
View File
@@ -0,0 +1,186 @@
# syntax=docker/dockerfile:1
ARG DISTRIBUTION_VERSION
ARG RUST_VERSION
ARG XX_VERSION=latest
FROM --platform=$BUILDPLATFORM tonistiigi/xx:${XX_VERSION} AS xx
FROM --platform=$BUILDPLATFORM rust:${RUST_VERSION}-${DISTRIBUTION_VERSION} AS build-base
COPY --from=xx / /
SHELL [ "/bin/bash", "-c" ]
ENV DEBIAN_FRONTEND=noninteractive
# install host dependencies
ARG DISTRIBUTION_PACKAGES
RUN \
--mount=type=cache,target=/var/cache/apt,sharing=private \
--mount=type=cache,target=/var/lib/apt,sharing=private \
<<EOF
apt-get update -y
apt-get install -y \
bash clang lld llvm file cmake pkg-config dpkg-dev \
${DISTRIBUTION_PACKAGES}
EOF
WORKDIR /source
COPY --link . .
FROM build-base AS build-prep
ENV CARGO_REGISTRIES_CRATES_IO_PROTOCOL='sparse'
ENV CARGO_TARGET_DIR='/root/.cache/rust'
RUN \
--mount=type=cache,target=/cargo/git/db,sharing=locked \
--mount=type=cache,target=/cargo/registry/cache,sharing=locked \
--mount=type=cache,target=/cargo/registry/index,sharing=locked \
<<EOF
#!/usr/bin/env bash
set -euxo pipefail
cargo fetch --locked
EOF
# Install target dependencies
ARG TARGETPLATFORM
ARG DISTRIBUTION_PACKAGES
RUN \
--mount=type=cache,target=/var/cache/apt,sharing=private \
--mount=type=cache,target=/var/lib/apt,sharing=private \
<<EOF
#!/usr/bin/env bash
set -euxo pipefail
xx-apt-get install -y \
"xx-cxx-essentials" \
${DISTRIBUTION_PACKAGES}
EOF
FROM build-prep AS build
ARG PACKAGE_NAME
ENV PACKAGE_NAME="${PACKAGE_NAME}"
ARG OUTPUT_DIR="/output"
ENV OUTPUT_DIR="${OUTPUT_DIR}"
# in bullseye arm64 target does not link with lld so configure it to use ld instead
# RUN [ ! -f /etc/alpine-release ] && xx-info is-cross && [ "$(xx-info arch)" = "arm64" ] && XX_CC_PREFER_LINKER=ld xx-clang --setup-target-triple || true
ARG CARGO_BUILD_INCREMENTAL='false'
ENV CARGO_TARGET_DIR='/root/.cache/rust'
ENV CC='xx-clang'
ENV CXX='xx-clang++'
ENV OPENSSL_NO_VENDOR="1"
ENV ZSTD_SYS_USE_PKG_CONFIG="1"
ARG RELEASE_TAG_NAME
ENV RELEASE_TAG_NAME="${RELEASE_TAG_NAME}"
RUN \
--mount=type=cache,target=/cargo/git/db,sharing=locked \
--mount=type=cache,target=/cargo/registry/cache,sharing=locked \
--mount=type=cache,target=/cargo/registry/index,sharing=locked \
--mount=type=cache,target=/root/.cache,sharing=private \
<<EOF
#!/usr/bin/env bash
set -euxo pipefail
xx-clang --setup-target-triple
xx-clang --wrap
export RUSTFLAGS="-C linker=clang -C link-arg=-fuse-ld=/usr/bin/ld.lld"
export PKG_CONFIG="$(xx-clang --print-prog-name=pkg-config)"
export CARGO_BUILD_TARGET="$(xx-cargo --print-target-triple)"
xx-cargo build \
--frozen \
--package lapce-app \
--profile release-lto \
--no-default-features
xx-verify "${CARGO_TARGET_DIR}"/"$(xx-cargo --print-target-triple)"/release-lto/lapce
mkdir -p /target
mv -v "${CARGO_TARGET_DIR}"/"$(xx-cargo --print-target-triple)"/release-lto/lapce /target/
cargo pkgid | cut -d'#' -f2 | cut -d'@' -f2 | cut -d':' -f2 | tee /target/lapce.version
EOF
WORKDIR /output
RUN <<EOF
#!/usr/bin/env bash
set -euxo pipefail
export _PACKAGE_ARCHITECTURE=$(xx-info debian-arch)
mkdir -v -p ${PACKAGE_NAME}/{etc,usr/{bin,share/{applications,metainfo,pixmaps}},debian}
cd ${PACKAGE_NAME}
cp '/source/extra/linux/dev.lapce.lapce.desktop' './usr/share/applications/dev.lapce.lapce.desktop'
cp '/source/extra/linux/dev.lapce.lapce.metainfo.xml' './usr/share/metainfo/dev.lapce.lapce.metainfo.xml'
cp '/source/extra/images/logo.png' './usr/share/pixmaps/dev.lapce.lapce.png'
mv '/target/lapce' './usr/bin/'
if [[ "${PACKAGE_NAME}" == "lapce" ]]; then
conflicts="lapce-nightly"
else
conflicts="lapce"
fi
case "${RELEASE_TAG_NAME}" in
nightly-*)
version=$(cat /target/lapce.version)
commit=$(echo "${RELEASE_TAG_NAME}" | cut -d'-' -f2)
# date=$(date +%Y%m%d%H%M)
RELEASE_TAG_NAME="${version}+${commit}"
;;
debug|nightly)
version=$(cat /target/lapce.version)
date=$(date +%Y%m%d%H%M)
RELEASE_TAG_NAME="${version}+${date}"
;;
*)
RELEASE_TAG_NAME="${RELEASE_TAG_NAME//v/}"
;;
esac
cat <<- EOL > debian/control
Package: ${PACKAGE_NAME}
Version: ${RELEASE_TAG_NAME}
Conflicts: ${conflicts}
Maintainer: Jakub Panek <me+debian@panekj.dev>
Architecture: ${_PACKAGE_ARCHITECTURE}
Description: Lightning-fast and Powerful Code Editor
Source: https://lapce.dev
EOL
depends=$(dpkg-shlibdeps -O -e usr/bin/lapce)
depends=$(echo "${depends}" | sed 's/shlibs:Depends=//')
echo "Depends: ${depends}" >> debian/control
mv debian DEBIAN
. /etc/os-release
dpkg-deb --root-owner-group --build . "${OUTPUT_DIR}"/"${PACKAGE_NAME}.${ID}.${VERSION_CODENAME}.${_PACKAGE_ARCHITECTURE}.deb"
EOF
FROM build-base AS dev
COPY . ./dev
FROM scratch AS binary
COPY --from=build /output/lapce .
FROM scratch AS cross-binary
COPY --from=build /output/lapce .
FROM scratch AS package
COPY --from=build /output/*.deb .
FROM scratch AS cross-package
COPY --from=build /output/*.deb .
+190
View File
@@ -0,0 +1,190 @@
# syntax=docker/dockerfile:1
ARG DISTRIBUTION_VERSION
ARG RUST_VERSION
ARG XX_VERSION=latest
FROM --platform=$BUILDPLATFORM ghcr.io/panekj/xx:${XX_VERSION} AS xx
FROM --platform=$BUILDPLATFORM fedora:${DISTRIBUTION_VERSION} AS build-base
COPY --from=xx --link / /
SHELL [ "/bin/bash", "-c" ]
# install host dependencies
ARG DISTRIBUTION_PACKAGES
RUN \
--mount=type=cache,target=/var/cache/dnf,sharing=locked \
<<EOF
#!/usr/bin/env bash
set -euxo pipefail
printf "keepcache=True" >> /etc/dnf/dnf.conf
dnf update -y
dnf install -y \
bash clang lld llvm file cmake pkg-config curl git rpm-build
EOF
ENV CARGO_HOME="/cargo"
ENV RUSTUP_HOME="/rustup"
RUN \
<<EOF
#!/usr/bin/env bash
set -euxo pipefail
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
EOF
ENV PATH="${CARGO_HOME}/bin:${PATH}"
WORKDIR /source
FROM build-base AS build-prep
ENV CARGO_REGISTRIES_CRATES_IO_PROTOCOL='sparse'
ENV CARGO_TARGET_DIR='/target'
ENV CARGO_NET_GIT_FETCH_WITH_CLI="true"
COPY --link . .
RUN \
--mount=type=cache,target=/cargo/git/db,sharing=locked \
--mount=type=cache,target=/cargo/registry/cache,sharing=locked \
--mount=type=cache,target=/cargo/registry/index,sharing=locked \
<<EOF
#!/usr/bin/env bash
set -euxo pipefail
cargo fetch --locked
EOF
# Install target dependencies
ARG TARGETPLATFORM
ARG DISTRIBUTION_PACKAGES
RUN \
--mount=type=cache,target=/var/cache/dnf,sharing=locked \
<<EOF
#!/usr/bin/env bash
set -euxo pipefail
mkdir -p /run/lock
mkdir -p /var/run/lock
XX_DEBUG_DNF=1 \
xx-dnf install -y \
"xx-cxx-essentials" \
${DISTRIBUTION_PACKAGES}
EOF
FROM build-prep AS build
ARG PACKAGE_NAME
ENV PACKAGE_NAME="${PACKAGE_NAME}"
ARG CARGO_BUILD_INCREMENTAL='false'
ENV CC='xx-clang'
ENV CXX='xx-clang++'
ENV OPENSSL_NO_VENDOR="1"
ENV ZSTD_SYS_USE_PKG_CONFIG="1"
ARG RELEASE_TAG_NAME
ENV RELEASE_TAG_NAME="${RELEASE_TAG_NAME}"
RUN \
--mount=type=cache,target=/cargo/git/db,readonly=true \
--mount=type=cache,target=/cargo/registry/cache,readonly=true \
--mount=type=cache,target=/cargo/registry/index,readonly=true \
--mount=type=cache,target=/root/.cache,sharing=private \
<<EOF
#!/usr/bin/env bash
set -euxo pipefail
LAPCE_VERSION=$(cargo pkgid | cut -d'#' -f2 | cut -d'@' -f2 | cut -d':' -f2)
case "${RELEASE_TAG_NAME}" in
nightly-*)
commit=$(echo "${RELEASE_TAG_NAME}" | cut -d'-' -f2)
RELEASE_TAG_NAME="${LAPCE_VERSION}+${commit}"
;;
debug|nightly)
date=$(date +%Y%m%d%H%M)
RELEASE_TAG_NAME="${LAPCE_VERSION}+${date}"
;;
*)
RELEASE_TAG_NAME="${RELEASE_TAG_NAME//v/}"
;;
esac
. /etc/os-release
export DISTRO_ID="$(echo $ID | tr - _)"
export DISTRO_VERSION="$(echo $VERSION_ID | tr - _)"
cat > lapce.spec <<EOL
Name: ${PACKAGE_NAME}
Version: ${RELEASE_TAG_NAME}
Release: 1.${DISTRO_ID}${DISTRO_VERSION}
Summary: Lightning-fast and Powerful Code Editor written in Rust
License: Apache-2.0
URL: https://github.com/lapce/lapce
Packager: Jakub Panek
%description
Lapce is written in pure Rust with a UI in Floem (which is also written in Rust).
It is designed with Rope Science from the Xi-Editor which makes for lightning-fast computation, and leverages OpenGL for rendering.
%build
xx-clang --setup-target-triple
xx-clang --wrap
export RUSTFLAGS="-C linker=clang -C link-arg=-fuse-ld=/usr/bin/ld.lld"
export PKG_CONFIG="$(xx-clang --print-prog-name=pkg-config)"
rustup target add "$(xx-cargo --print-target-triple)"
export RELEASE_TAG_NAME="${RELEASE_TAG_NAME}"
xx-cargo build --profile release-lto --bin lapce --frozen
xx-verify "${CARGO_TARGET_DIR}"/"$(xx-cargo --print-target-triple)"/release-lto/lapce
%install
install -Dm755 "${CARGO_TARGET_DIR}"/"$(xx-cargo --print-target-triple)"/release-lto/lapce %{buildroot}%{_bindir}/lapce
install -Dm644 extra/linux/dev.lapce.lapce.desktop %{buildroot}/usr/share/applications/dev.lapce.lapce.desktop
install -Dm644 extra/linux/dev.lapce.lapce.metainfo.xml %{buildroot}/usr/share/metainfo/dev.lapce.lapce.metainfo.xml
install -Dm644 extra/images/logo.png %{buildroot}/usr/share/pixmaps/dev.lapce.lapce.png
%files
%license LICENSE*
%doc *.md
%{_bindir}/lapce
/usr/share/applications/dev.lapce.lapce.desktop
/usr/share/metainfo/dev.lapce.lapce.metainfo.xml
/usr/share/pixmaps/dev.lapce.lapce.png
%changelog
* Thu Apr 25 2024 Jakub Panek
- See GitHub for full changelog
EOL
/usr/bin/rpmbuild --build-in-place --noclean --noprep -bb --rmspec lapce.spec --verbose -D 'debug_package %{nil}'
ls -lahR $HOME/rpmbuild
EOF
RUN \
<<EOF
#!/usr/bin/env bash
set -euxo pipefail
mv -v $HOME/rpmbuild/RPMS/* /output/
EOF
FROM build-base AS dev
COPY . ./dev
FROM scratch AS binary
COPY --from=build /output/lapce .
FROM scratch AS cross-binary
COPY --from=build /output/lapce .
FROM scratch AS package
COPY --from=build /output/*.rpm .
FROM scratch AS cross-package
COPY --from=build /output/*.rpm .
+213
View File
@@ -0,0 +1,213 @@
# syntax=docker/dockerfile:1
ARG DISTRIBUTION_VERSION
ARG RUST_VERSION
ARG XX_VERSION
FROM --platform=$BUILDPLATFORM tonistiigi/xx:${XX_VERSION} AS xx
FROM --platform=$BUILDPLATFORM ubuntu:${DISTRIBUTION_VERSION} AS build-base
COPY --from=xx / /
SHELL [ "/bin/bash", "-c" ]
ENV DEBIAN_FRONTEND=noninteractive
RUN \
<<EOF
#!/usr/bin/env bash
set -euxo pipefail
rm -f /etc/apt/apt.conf.d/docker-clean
echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache
EOF
# install host dependencies
ARG DISTRIBUTION_PACKAGES
RUN \
--mount=type=cache,target=/var/cache/apt,sharing=private \
--mount=type=cache,target=/var/lib/apt,sharing=private \
<<EOF
#!/usr/bin/env bash
set -euxo pipefail
apt-get update -y
apt-get upgrade -y
apt-get install -y \
bash clang lld llvm file cmake pkg-config curl git dpkg-dev \
${DISTRIBUTION_PACKAGES}
EOF
ENV CARGO_HOME="/cargo"
ENV RUSTUP_HOME="/rustup"
RUN \
<<EOF
#!/usr/bin/env bash
set -euxo pipefail
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
EOF
ENV PATH="${CARGO_HOME}/bin:${PATH}"
WORKDIR /source
COPY --link . .
FROM build-base AS build-prep
ENV CARGO_TARGET_DIR='/target'
RUN \
--mount=type=cache,target=/cargo/git/db,sharing=locked \
--mount=type=cache,target=/cargo/registry/cache,sharing=locked \
--mount=type=cache,target=/cargo/registry/index,sharing=locked \
<<EOF
#!/usr/bin/env bash
set -euxo pipefail
cargo fetch --locked
EOF
# Install target dependencies
ARG TARGETPLATFORM
ARG DISTRIBUTION_PACKAGES
RUN \
--mount=type=cache,target=/var/cache/apt,sharing=private \
--mount=type=cache,target=/var/lib/apt,sharing=private \
<<EOF
#!/usr/bin/env bash
set -euxo pipefail
xx-apt-get install -y \
"xx-cxx-essentials" \
${DISTRIBUTION_PACKAGES}
EOF
FROM build-prep AS build
ARG PACKAGE_NAME
ARG OUTPUT_DIR="/output"
ARG CARGO_BUILD_INCREMENTAL='false'
ENV CC='xx-clang'
ENV CXX='xx-clang++'
ARG ZSTD_SYS_USE_PKG_CONFIG
ARG LIBGIT2_STATIC
ARG LIBSSH2_STATIC
ARG LIBZ_SYS_STATIC
ARG OPENSSL_STATIC
ARG OPENSSL_NO_VENDOR
ARG PKG_CONFIG_ALL_STATIC
ARG RELEASE_TAG_NAME
RUN \
--mount=type=cache,target=/cargo/git/db,sharing=shared,readonly \
--mount=type=cache,target=/cargo/registry/cache,sharing=shared,readonly \
--mount=type=cache,target=/cargo/registry/index,sharing=shared,readonly \
--mount=type=cache,target=/root/.cache,sharing=private \
<<EOF
#!/usr/bin/env bash
set -euxo pipefail
xx-clang --setup-target-triple
xx-clang --wrap
export RUSTFLAGS="-C linker=clang -C link-arg=-fuse-ld=/usr/bin/ld.lld"
export PKG_CONFIG="$(xx-clang --print-prog-name=pkg-config)"
export CARGO_BUILD_TARGET="$(xx-cargo --print-target-triple)"
env
xx-cargo build \
--frozen \
--package lapce-app \
--profile release-lto \
--no-default-features
xx-verify "${CARGO_TARGET_DIR}"/"$(xx-cargo --print-target-triple)"/release-lto/lapce
mkdir -p /target
mv -v "${CARGO_TARGET_DIR}"/"$(xx-cargo --print-target-triple)"/release-lto/lapce /target/
cargo pkgid | cut -d'#' -f2 | cut -d'@' -f2 | cut -d':' -f2 | tee /target/lapce.version
EOF
FROM build-base AS dev
COPY . ./dev
FROM scratch AS binary
COPY --from=build /target/lapce .
FROM scratch AS cross-binary
COPY --from=build /target/lapce .
FROM build AS package-prepare
WORKDIR /output
COPY --from=build /target /target
RUN <<EOF
#!/usr/bin/env bash
set -euxo pipefail
export _PACKAGE_ARCHITECTURE=$(xx-info debian-arch)
mkdir -v -p ${PACKAGE_NAME}/{etc,usr/{bin,share/{applications,metainfo,pixmaps}},debian}
cd ${PACKAGE_NAME}
cp '/source/extra/linux/dev.lapce.lapce.desktop' './usr/share/applications/dev.lapce.lapce.desktop'
cp '/source/extra/linux/dev.lapce.lapce.metainfo.xml' './usr/share/metainfo/dev.lapce.lapce.metainfo.xml'
cp '/source/extra/images/logo.png' './usr/share/pixmaps/dev.lapce.lapce.png'
mv '/target/lapce' './usr/bin/'
if [[ "${PACKAGE_NAME}" == "lapce" ]]; then
conflicts="lapce-nightly"
else
conflicts="lapce"
fi
case "${RELEASE_TAG_NAME}" in
nightly-*)
version=$(cat /target/lapce.version)
commit=$(echo "${RELEASE_TAG_NAME}" | cut -d'-' -f2)
# date=$(date +%Y%m%d%H%M)
RELEASE_TAG_NAME="${version}+${commit}"
;;
debug|nightly)
version=$(cat /target/lapce.version)
date=$(date +%Y%m%d%H%M)
RELEASE_TAG_NAME="${version}+${date}"
;;
*)
RELEASE_TAG_NAME="${RELEASE_TAG_NAME//v/}"
;;
esac
cat <<- EOL > debian/control
Package: ${PACKAGE_NAME}
Version: ${RELEASE_TAG_NAME}
Conflicts: ${conflicts}
Maintainer: Jakub Panek <me+debian@panekj.dev>
Architecture: ${_PACKAGE_ARCHITECTURE}
Description: Lightning-fast and Powerful Code Editor
Source: https://lapce.dev
EOL
depends=$(dpkg-shlibdeps -O -e usr/bin/lapce)
depends=$(echo "${depends}" | sed 's/shlibs:Depends=//')
echo "Depends: ${depends}" >> debian/control
mv debian DEBIAN
. /etc/os-release
dpkg-deb --root-owner-group --build . "${OUTPUT_DIR}"/"${PACKAGE_NAME}.${ID}.${VERSION_CODENAME}.${_PACKAGE_ARCHITECTURE}.deb"
EOF
FROM scratch AS package
COPY --from=package-prepare /output/*.deb .
FROM scratch AS cross-package
COPY --from=package-prepare /output/*.deb .