From 79de70a53ac7569265cf1724107a8766420b361d Mon Sep 17 00:00:00 2001 From: Kiron Date: Sat, 16 Dec 2023 11:43:16 +0800 Subject: [PATCH] Packages repository for Ubuntu --- .github/workflows/main.yaml | 46 +++++++++++++++++++++++++++++++++++++ apt-ftparchive.conf | 28 ++++++++++++++++++++++ apt.sh | 44 +++++++++++++++++++++++++++++++++++ cache/.gitignore | 1 + focal.conf | 9 ++++++++ jammy.conf | 9 ++++++++ public/.gitignore | 1 + 7 files changed, 138 insertions(+) create mode 100644 .github/workflows/main.yaml create mode 100644 apt-ftparchive.conf create mode 100755 apt.sh create mode 100644 cache/.gitignore create mode 100644 focal.conf create mode 100644 jammy.conf create mode 100644 public/.gitignore diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml new file mode 100644 index 0000000..64d1eac --- /dev/null +++ b/.github/workflows/main.yaml @@ -0,0 +1,46 @@ +--- + +name: main + +on: + push: + branches: + - main + pull_request: + branches: + - main + workflow_dispatch: + +jobs: + # Build job + build: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v3 + - name: Build + run: ./apt.sh + - name: Upload Pages Artifact + uses: actions/upload-pages-artifact@v2 + with: + path: "public" + + # Deploy job + deploy: + needs: build + + # Grant GITHUB_TOKEN the permissions required to make a Pages deployment + permissions: + pages: write + id-token: write + + # Deploy to the github-pages environment + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + + runs-on: ubuntu-latest + steps: + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v3 diff --git a/apt-ftparchive.conf b/apt-ftparchive.conf new file mode 100644 index 0000000..58a9a1a --- /dev/null +++ b/apt-ftparchive.conf @@ -0,0 +1,28 @@ +Dir { + ArchiveDir "./public/ubuntu"; + CacheDir "./cache"; +}; +Default { + Packages::Extensions ".deb"; + Packages::Compress ". gzip bzip2"; + Sources::Compress ". gzip bzip2"; + Contents::Compress "gzip bzip2"; +}; + +TreeDefault { + BinCacheDB "packages-$(SECTION)-$(ARCH).db"; + Packages "$(DIST)/$(SECTION)/binary-$(ARCH)/Packages"; + SrcDirectory "pool/$(SECTION)"; + Sources "$(DIST)/$(SECTION)/source/Sources"; + Contents "$(DIST)/Contents-$(ARCH)"; +}; +Tree "dists/focal" { + Sections "main"; + Directory "pool/focal/$(SECTION)"; + Architectures "amd64"; +} +Tree "dists/jammy" { + Sections "main"; + Directory "pool/jammy/$(SECTION)"; + Architectures "amd64"; +} diff --git a/apt.sh b/apt.sh new file mode 100755 index 0000000..e892334 --- /dev/null +++ b/apt.sh @@ -0,0 +1,44 @@ +#!/usr/bin/env bash +# +# https://unix.stackexchange.com/a/403489 +# https://gist.github.com/aarroyoc/1a96b2f8b01fcf34221a +# + +set -euo pipefail + +# repos=(kiron1/proxydetox kiron1/bazel-compile-commands) +repos=(kiron1/proxydetox) +machines=(x86_64) + +declare -A aptarch=( ["x86_64"]="amd64" ) + +suits=(focal jammy) + +eval "$(apt-config -c apt-ftparchive.conf shell archive_dir Dir::ArchiveDir/d)" + +mkdir -p "${archive_dir}/pool/main" + +for r in "${repos[@]}"; do + tag=$(gh release view -R "${r}" --json tagName --jq '.tagName') + for s in "${suits[@]}"; do + mkdir -p "${archive_dir}/pool/${s}/main" + rm -f -- "${archive_dir}/pool/${s}/main"/*.deb + for m in "${machines[@]}"; do + printf 'Download %s %s\n' "${r}" "${tag}" + gh release download -R "${r}" "${tag}" --dir "${archive_dir}/pool/${s}/main" --pattern "*-${m}-${s}.deb" --skip-existing + done + find "${archive_dir}/pool/${s}/main/" -name '*.deb' -exec dpkg-name {} + + done +done + +r=kiron1/bazel-compile-commands +tag=$(gh release view -R "${r}" --json tagName --jq '.tagName') +gh release download -R "${r}" "${tag}" --dir "${archive_dir}/pool/focal/main" --pattern "*.deb" --skip-existing + +for s in "${suits[@]}"; do + for m in "${machines[@]}"; do + mkdir -p "${archive_dir}/dists/${s}/main/binary-${aptarch[${m}]}" + done + apt-ftparchive generate apt-ftparchive.conf + apt-ftparchive "-c=${s}.conf" release "${archive_dir}/dists/${s}" > "${archive_dir}/dists/${s}/Release" +done diff --git a/cache/.gitignore b/cache/.gitignore new file mode 100644 index 0000000..98e6ef6 --- /dev/null +++ b/cache/.gitignore @@ -0,0 +1 @@ +*.db diff --git a/focal.conf b/focal.conf new file mode 100644 index 0000000..3131b53 --- /dev/null +++ b/focal.conf @@ -0,0 +1,9 @@ +APT::FTPArchive::Release { + Origin "Your origin"; + Label "Your label"; + Suite "focal"; + Codename "focal"; + Architectures "amd64"; + Components "main"; + Description "color to see see"; +}; diff --git a/jammy.conf b/jammy.conf new file mode 100644 index 0000000..3a2338f --- /dev/null +++ b/jammy.conf @@ -0,0 +1,9 @@ +APT::FTPArchive::Release { + Origin "Your origin"; + Label "Your label"; + Suite "jammy"; + Codename "jammy"; + Architectures "amd64"; + Components "main"; + Description "color to see see"; +}; diff --git a/public/.gitignore b/public/.gitignore new file mode 100644 index 0000000..8617afd --- /dev/null +++ b/public/.gitignore @@ -0,0 +1 @@ +ubuntu/