diff --git a/.github/workflows/aur-check.yml b/.github/workflows/aur-check.yml new file mode 100644 index 00000000..2fbdfd53 --- /dev/null +++ b/.github/workflows/aur-check.yml @@ -0,0 +1,84 @@ +name: Arch Linux Container Validation + +on: + pull_request: + paths: + - '.github/workflows/aur-check.yml' + - 'aur/**' + push: + paths: + - '.github/workflows/aur-check.yml' + - 'aur/**' + branches: + - main + workflow_dispatch: + +jobs: + archlinux-validation: + name: Arch Linux Container Build & Test + runs-on: ubuntu-latest + container: + image: archlinux/archlinux:latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Cache Pacman Dependencies + uses: actions/cache@v4 + with: + path: /var/cache/pacman/pkg + key: ${{ runner.os }}-pacman-${{ hashFiles('/etc/pacman.conf', '/etc/makepkg.config', '/etc/makepkg/rust.conf') }} + restore-keys: | + ${{ runner.os }}-pacman- + + - name: Install base dependencies + run: | + pacman -Syu --noconfirm + + pacman -S --noconfirm \ + namcap \ + shellcheck + + - name: Validate PKGBUILD files + run: | + set -e + + # Color codes + RED='\033[0;31m' + GREEN='\033[0;32m' + YELLOW='\033[1;33m' + BLUE='\033[0;34m' + MAGENTA='\033[0;35m' + CYAN='\033[0;36m' + WHITE='\033[1;37m' + NC='\033[0m' # No Color + + for pathname in aur/PKGBUILD*; do + if [ -f "${pathname}" ]; then + filename=$(basename ${pathname}) + dirname=$(dirname ${pathname}) + + echo -e "${CYAN}============ Validating [${NC}${filename}${CYAN}] ============${NC}\n\n" + + echo -e "${YELLOW}============ Running Shellcheck On${NC} ${filename} ${YELLOW}============${NC}\n" + if shellcheck --shell=bash --exclude=SC2034,SC2154,SC2164 "${pathname}"; then + echo -e "${GREEN}✅ Shellcheck passed${NC}" + else + echo -e "${RED}❌ Shellcheck failed${NC}" + exit 1 + fi + + echo -e "${BLUE}============ Running Namcap On${NC} ${filename} ${BLUE}============${NC}\n" + if namcap "${pathname}"; then + echo -e "${GREEN}✅ Namcap passed${NC}" + else + echo -e "${RED}❌ Namcap failed${NC}" + exit 1 + fi + + echo -e "${GREEN}🎉 ${filename} Validation Completed Successfully!${NC}" + echo "" + fi + done + + echo -e "${GREEN}🚀 All PKGBUILD files validated successfully!${NC}" diff --git a/aur/PKGBUILD b/aur/PKGBUILD index ce1e062b..24989062 100644 --- a/aur/PKGBUILD +++ b/aur/PKGBUILD @@ -7,7 +7,7 @@ pkgrel=1 pkgdesc='Visualize Ownership and Lifetimes in Rust' url='https://github.com/cordx56/rustowl' license=('MPL-2.0') -makedepends=('rustup') +makedepends=('gcc' 'make' 'autoconf' 'cmake' 'curl') depends=() conflicts=('rustowl-git' 'rustowl-bin') arch=('any') @@ -16,36 +16,25 @@ sha256sums=('fa120643aeb48061eb32a7c993dabff88aa4e9d0b32f8ab0f3289b3fb2cf5744') prepare() { cd rustowl-${pkgver} - export RUSTC_BOOTSTRAP=1 - export RUSTUP_TOOLCHAIN=1.89.0 - rustup component add rust-src rustc-dev llvm-tools - cargo fetch --locked --target "$(rustc -vV | sed -n 's/host: //p')" + ./scripts/build/toolchain cargo fetch --locked --target "$(rustc -vV | sed -n 's/host: //p')" } build() { cd rustowl-${pkgver} export CARGO_TARGET_DIR=target - export RUSTC_BOOTSTRAP=1 - export RUSTUP_TOOLCHAIN=1.89.0 export RUSTOWL_RUNTIME_DIRS=/opt/rustowl - cargo build --frozen --release --all-features --target $(rustc --print=host-tuple) + ./scripts/build/toolchain cargo build --frozen --release --all-features --target "$(rustc --print=host-tuple)" } check() { cd rustowl-${pkgver} - export RUSTC_BOOTSTRAP=1 - export RUSTUP_TOOLCHAIN=1.89.0 - cargo test --frozen --all-features + ./scripts/build/toolchain cargo test --frozen --all-features } package() { cd rustowl-${pkgver} find target -type d | grep -E 'rustowl-build-time-out$' | xargs -I % cp -r % ./ - mkdir sysroot - ACTIVE_TOOLCHAIN="$(rustup show active-toolchain | awk '{ print $1 }')" - cp -r "$(rustc --print=sysroot)" sysroot/$ACTIVE_TOOLCHAIN - find sysroot -type f | grep -v -E '\.(rlib|so|dylib|dll)$' | xargs rm -rf - find sysroot -depth -type d -empty -exec rm -rf {} \; + ./target/"$(rustc --print=host-tuple)"/release/rustowl toolchain install --path sysroot/"$(rustup show active-toolchain | awk '{ print $1 }')" install -d -m 755 "$pkgdir/opt/rustowl" cp -a sysroot/ "$pkgdir/opt/rustowl/" install -Dm0755 -t "$pkgdir/usr/bin/" "target/$(rustc --print=host-tuple)/release/rustowl" diff --git a/aur/PKGBUILD-GIT b/aur/PKGBUILD-GIT index 0163a8d8..5afef3e2 100644 --- a/aur/PKGBUILD-GIT +++ b/aur/PKGBUILD-GIT @@ -7,7 +7,7 @@ pkgrel=1 pkgdesc='Visualize Ownership and Lifetimes in Rust' url='https://github.com/cordx56/rustowl' license=('MPL-2.0') -makedepends=('git' 'rustup' 'zig=0.13.0') +makedepends=('git' 'gcc' 'make' 'autoconf' 'cmake' 'curl') arch=('any') source=("git+https://github.com/cordx56/rustowl.git") sha256sums=('SKIP') @@ -20,36 +20,24 @@ pkgver() { prepare() { cd "$srcdir/rustowl" - export RUSTC_BOOTSTRAP=1 - export RUSTUP_TOOLCHAIN=1.89.0 - rustup component add rust-src rustc-dev llvm-tools - cargo fetch --locked --target "$(rustc -vV | sed -n 's/host: //p')" + ./scripts/build/toolchain cargo fetch --locked --target "$(rustc -vV | sed -n 's/host: //p')" } build() { cd "$srcdir/rustowl" - export CARGO_TARGET_DIR=target - export RUSTC_BOOTSTRAP=1 - export RUSTUP_TOOLCHAIN=1.89.0 export RUSTOWL_RUNTIME_DIRS=/opt/rustowl - cargo build --frozen --release --all-features --target $(rustc --print=host-tuple) + ./scripts/build/toolchain cargo build --frozen --release --all-features --target "$(rustc --print=host-tuple)" } check() { cd "$srcdir/rustowl" - export RUSTC_BOOTSTRAP=1 - export RUSTUP_TOOLCHAIN=1.89.0 - cargo test --frozen --all-features + ./scripts/build/toolchain cargo test --frozen --all-features } package() { cd "$srcdir/rustowl" find target -type d | grep -E 'rustowl-build-time-out$' | xargs -I % cp -r % ./ - mkdir sysroot - ACTIVE_TOOLCHAIN="$(rustup show active-toolchain | awk '{ print $1 }')" - cp -r "$(rustc --print=sysroot)" sysroot/$ACTIVE_TOOLCHAIN - find sysroot -type f | grep -v -E '\.(rlib|so|dylib|dll)$' | xargs rm -rf - find sysroot -depth -type d -empty -exec rm -rf {} \; + ./target/"$(rustc --print=host-tuple)"/release/rustowl toolchain install --path sysroot/"$(rustup show active-toolchain | awk '{ print $1 }')" --skip-rustowl-toolchain install -d -m 755 "$pkgdir/opt/rustowl" cp -a sysroot/ "$pkgdir/opt/rustowl/" install -Dm0755 -t "$pkgdir/usr/bin/" "target/$(rustc --print=host-tuple)/release/rustowl"