@@ -80,9 +80,6 @@ FROM build-prep AS build
80
80
ARG PACKAGE_NAME
81
81
ENV PACKAGE_NAME="${PACKAGE_NAME}"
82
82
83
- ARG OUTPUT_DIR="/output"
84
- ENV OUTPUT_DIR="${OUTPUT_DIR}"
85
-
86
83
ARG CARGO_BUILD_INCREMENTAL='false'
87
84
88
85
ENV CC='xx-clang'
@@ -95,58 +92,99 @@ ARG RELEASE_TAG_NAME
95
92
ENV RELEASE_TAG_NAME="${RELEASE_TAG_NAME}"
96
93
97
94
RUN \
98
- --mount=type=cache,target=/cargo/git/db,sharing=locked, readonly=true \
99
- --mount=type=cache,target=/cargo/registry/cache,sharing=locked, readonly=true \
100
- --mount=type=cache,target=/cargo/registry/index,sharing=locked, readonly=true \
95
+ --mount=type=cache,target=/cargo/git/db,readonly=true \
96
+ --mount=type=cache,target=/cargo/registry/cache,readonly=true \
97
+ --mount=type=cache,target=/cargo/registry/index,readonly=true \
101
98
--mount=type=cache,target=/root/.cache,sharing=private \
102
99
<<EOF
103
100
# !/usr/bin/env bash
104
101
set -euxo pipefail
105
102
103
+ LAPCE_VERSION=$(cargo pkgid | cut -d'#' -f2 | cut -d'@' -f2 | cut -d':' -f2)
104
+
105
+ case "${RELEASE_TAG_NAME}" in
106
+ nightly-*)
107
+ commit=$(echo "${RELEASE_TAG_NAME}" | cut -d'-' -f2)
108
+ RELEASE_TAG_NAME="${LAPCE_VERSION}+${commit}"
109
+ ;;
110
+ debug|nightly)
111
+ date=$(date +%Y%m%d%H%M)
112
+ RELEASE_TAG_NAME="${LAPCE_VERSION}+${date}"
113
+ ;;
114
+ *)
115
+ RELEASE_TAG_NAME="${RELEASE_TAG_NAME//v/}"
116
+ ;;
117
+ esac
118
+
119
+ . /etc/os-release
120
+ export DISTRO_ID="$(echo $ID | tr - _)"
121
+ export DISTRO_VERSION="$(echo $VERSION_ID | tr - _)"
122
+
123
+ cat > lapce.spec <<EOL
124
+ Name: ${PACKAGE_NAME}
125
+ Version: ${RELEASE_TAG_NAME}
126
+ Release: 1.${DISTRO_ID}${DISTRO_VERSION}
127
+ Summary: Lightning-fast and Powerful Code Editor written in Rust
128
+ License: Apache-2.0
129
+ URL: https://github.com/lapce/lapce
130
+ Packager: Jakub Panek
131
+
132
+ %description
133
+ Lapce is written in pure Rust with a UI in Druid (which is also written in Rust).
134
+ It is designed with Rope Science from the Xi-Editor which makes for lightning-fast computation, and leverages OpenGL for rendering.
135
+
136
+ %build
106
137
xx-clang --setup-target-triple
107
138
xx-clang --wrap
108
-
109
139
export RUSTFLAGS="-C linker=clang -C link-arg=-fuse-ld=/usr/bin/ld.lld"
110
140
export PKG_CONFIG="$(xx-clang --print-prog-name=pkg-config)"
111
- export CARGO_BUILD_TARGET="$(xx-cargo --print-target-triple)"
112
-
113
141
rustup target add "$(xx-cargo --print-target-triple)"
142
+ export RELEASE_TAG_NAME="${RELEASE_TAG_NAME}"
114
143
xx-cargo build --profile release-lto --bin lapce --frozen
115
144
xx-verify "${CARGO_TARGET_DIR}" /"$(xx-cargo --print-target-triple)" /release-lto/lapce
116
145
117
- mkdir -p /target
118
- mv -v "${CARGO_TARGET_DIR}" /"$(xx-cargo --print-target-triple)" /release-lto/lapce /target/
146
+ %install
147
+ install -Dm755 "${CARGO_TARGET_DIR}" /"$(xx-cargo --print-target-triple)" /release-lto/lapce %{buildroot}%{_bindir}/lapce
148
+ install -Dm644 extra/linux/dev.lapce.lapce.desktop %{buildroot}/usr/share/applications/dev.lapce.lapce.desktop
149
+ install -Dm644 extra/linux/dev.lapce.lapce.metainfo.xml %{buildroot}/usr/share/metainfo/dev.lapce.lapce.metainfo.xml
150
+ install -Dm644 extra/images/logo.png %{buildroot}/usr/share/pixmaps/dev.lapce.lapce.png
151
+
152
+ %files
153
+ %license LICENSE*
154
+ %doc *.md
155
+ %{_bindir}/lapce
156
+ /usr/share/applications/dev.lapce.lapce.desktop
157
+ /usr/share/metainfo/dev.lapce.lapce.metainfo.xml
158
+ /usr/share/pixmaps/dev.lapce.lapce.png
159
+
160
+ %changelog
161
+ * Thu Apr 25 2024 Jakub Panek
162
+ - See GitHub for full changelog
163
+ EOL
164
+
165
+ /usr/bin/rpmbuild --build-in-place --noclean --noprep -bb --rmspec lapce.spec --verbose
166
+ ls -lahR $HOME/rpmbuild
119
167
EOF
120
168
121
- WORKDIR /output
122
- RUN <<EOF
169
+ RUN \
170
+ <<EOF
123
171
# !/usr/bin/env bash
124
172
set -euxo pipefail
125
173
126
- export _PACKAGE_ARCHITECTURE=$(xx-info rhel-arch)
127
-
128
- mkdir -v -p ${PACKAGE_NAME}/{etc,usr/bin}
129
- cd ${PACKAGE_NAME}
130
-
131
- mv /target/lapce ./usr/bin/
132
-
133
- if [ "${PACKAGE_NAME}" = "lapce" ]; then
134
- conflicts="lapce-nightly"
135
- else
136
- conflicts="lapce"
137
- fi
138
-
139
- if [ "${RELEASE_TAG_NAME}" = "nightly" ]; then
140
- RELEASE_TAG_NAME="v0.0.1"
141
- fi
142
-
174
+ mv -v $HOME/rpmbuild/RPMS/* /output/
143
175
EOF
144
176
145
177
FROM build-base AS dev
146
178
COPY . ./dev
147
179
148
180
FROM scratch AS binary
149
- COPY --from=build /output/*.deb .
181
+ COPY --from=build /output/lapce .
150
182
151
183
FROM scratch AS cross-binary
152
- COPY --from=build /output/*.deb .
184
+ COPY --from=build /output/lapce .
185
+
186
+ FROM scratch AS package
187
+ COPY --from=build /output/*.rpm .
188
+
189
+ FROM scratch AS cross-package
190
+ COPY --from=build /output/*.rpm .
0 commit comments