Skip to content

Commit 2a8cf64

Browse files
committed
generate flat repository
1 parent 1b2b415 commit 2a8cf64

2 files changed

Lines changed: 49 additions & 2 deletions

File tree

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
FROM gcr.io/google.com/cloudsdktool/google-cloud-cli:slim
22

33
RUN apt-get update \
4-
&& apt-get install -y --no-install-recommends aptly createrepo-c gnupg ca-certificates \
4+
&& apt-get install -y --no-install-recommends aptly createrepo-c gnupg ca-certificates dpkg-dev \
55
&& rm -rf /var/lib/apt/lists/*

scripts/publish-package-repo.sh

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,10 +230,57 @@ APTLYCONF
230230
done
231231

232232
while IFS= read -r existing_public_path; do
233-
rm -rf "$PACKAGE_REPO_STAGE_DIR/${existing_public_path#"$APTLY_ROOT_DIR/public"/}"
233+
rm -rf "${PACKAGE_REPO_STAGE_DIR:?}/${existing_public_path#"$APTLY_ROOT_DIR/public"/}"
234234
done < <(find "$APTLY_ROOT_DIR/public" -mindepth 1 -maxdepth 1)
235235

236236
cp -R "$APTLY_ROOT_DIR/public/." "$PACKAGE_REPO_STAGE_DIR/"
237+
238+
# Generate flat repository (supports "deb URL ./" apt sources, distribution-agnostic)
239+
flat_packages_file="$PACKAGE_REPO_STAGE_DIR/Packages"
240+
(cd "$PACKAGE_REPO_STAGE_DIR" && dpkg-scanpackages --multiversion pool 2>/dev/null) \
241+
> "$flat_packages_file"
242+
gzip -k -f "$flat_packages_file"
243+
244+
flat_release_file="$PACKAGE_REPO_STAGE_DIR/Release"
245+
{
246+
echo "Origin: ${APTLY_ORIGIN}"
247+
echo "Label: ${APTLY_LABEL}"
248+
echo "Architectures: ${APTLY_ARCHITECTURES//,/ }"
249+
echo "Components: ${APTLY_COMPONENT}"
250+
echo "Date: $(date -Ru)"
251+
echo "MD5Sum:"
252+
for _f in Packages Packages.gz; do
253+
[ -f "$PACKAGE_REPO_STAGE_DIR/$_f" ] || continue
254+
printf " %s %16d %s\n" \
255+
"$(md5sum "$PACKAGE_REPO_STAGE_DIR/$_f" | cut -d' ' -f1)" \
256+
"$(stat -c%s "$PACKAGE_REPO_STAGE_DIR/$_f")" \
257+
"$_f"
258+
done
259+
echo "SHA256:"
260+
for _f in Packages Packages.gz; do
261+
[ -f "$PACKAGE_REPO_STAGE_DIR/$_f" ] || continue
262+
printf " %s %16d %s\n" \
263+
"$(sha256sum "$PACKAGE_REPO_STAGE_DIR/$_f" | cut -d' ' -f1)" \
264+
"$(stat -c%s "$PACKAGE_REPO_STAGE_DIR/$_f")" \
265+
"$_f"
266+
done
267+
} > "$flat_release_file"
268+
269+
gpg --batch --yes \
270+
--passphrase-file "$passphrase_file" \
271+
--pinentry-mode loopback \
272+
-u "$APTLY_GPG_KEY_ID" \
273+
--armor --detach-sign \
274+
--output "${flat_release_file}.gpg" \
275+
"$flat_release_file"
276+
277+
gpg --batch --yes \
278+
--passphrase-file "$passphrase_file" \
279+
--pinentry-mode loopback \
280+
-u "$APTLY_GPG_KEY_ID" \
281+
--clearsign \
282+
--output "$PACKAGE_REPO_STAGE_DIR/InRelease" \
283+
"$flat_release_file"
237284
fi
238285

239286
gpg --batch --yes --armor --export "$APTLY_GPG_KEY_ID" >"$PACKAGE_REPO_STAGE_DIR/${APTLY_PUBLIC_KEY_NAME}.asc"

0 commit comments

Comments
 (0)