summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Berto <roberto.berto@under.com.br>2024-06-08 17:14:58 -0300
committerRoberto Berto <roberto.berto@under.com.br>2024-06-08 17:14:58 -0300
commitbc094b8954b79d35fba6bf97814f4a18ebd7274e (patch)
tree124510d78dc97a42f11a7e63a0f89bda2622e629
parent4cb4c83efd93aa7f893f7f7d44c680ab01452d94 (diff)
downloadvyos-apt-bc094b8954b79d35fba6bf97814f4a18ebd7274e.tar.gz
vyos-apt-bc094b8954b79d35fba6bf97814f4a18ebd7274e.zip
added a simple project starting point
-rw-r--r--.env.example3
-rw-r--r--Jenkinsfile39
-rw-r--r--README.md44
-rw-r--r--conf/distributions4
-rw-r--r--scripts/build_packages.sh23
-rw-r--r--scripts/update_repo.sh21
-rw-r--r--scripts/upload_repo.sh22
7 files changed, 155 insertions, 1 deletions
diff --git a/.env.example b/.env.example
new file mode 100644
index 0000000..d0327f1
--- /dev/null
+++ b/.env.example
@@ -0,0 +1,3 @@
+BUCKET_NAME=your-bucket-name
+AWS_PROFILE=vyos-apt
+REPO_URL=https://github.com/vyos-contrib/vyos-apt.git
diff --git a/Jenkinsfile b/Jenkinsfile
new file mode 100644
index 0000000..7dd07b7
--- /dev/null
+++ b/Jenkinsfile
@@ -0,0 +1,39 @@
+pipeline {
+ agent any
+ triggers {
+ cron('0 18 * * *') // run daily on 18:00
+ }
+ environment {
+ REPO_URL = credentials('repo-url')
+ }
+ stages {
+ stage('Checkout') {
+ steps {
+ git "${REPO_URL}"
+ }
+ }
+ stage('Build Packages') {
+ steps {
+ sh 'scripts/build_packages.sh'
+ }
+ }
+ stage('Update APT Repo') {
+ steps {
+ sh 'scripts/update_repo.sh'
+ }
+ }
+ stage('Upload to R2') {
+ steps {
+ withCredentials([string(credentialsId: 'aws-profile', variable: 'AWS_PROFILE')]) {
+ sh 'scripts/upload_repo.sh'
+ }
+ }
+ }
+ }
+ post {
+ always {
+ archiveArtifacts artifacts: '**/output/**/*.deb', allowEmptyArchive: true
+ cleanWs()
+ }
+ }
+}
diff --git a/README.md b/README.md
index aa8b082..1016d3c 100644
--- a/README.md
+++ b/README.md
@@ -1 +1,43 @@
-# vyos-apt \ No newline at end of file
+# vyos-apt
+
+This repository contains the configuration and scripts necessary to build VyOS packages and update an APT repository automatically using Jenkins. It also includes steps to upload the repository to Cloudflare R2.
+
+## Directory Structure
+
+- `Jenkinsfile`: Jenkins pipeline configuration.
+- `scripts/build_packages.sh`: Script to build VyOS packages.
+- `scripts/update_repo.sh`: Script to update the APT repository.
+- `scripts/upload_repo.sh`: Script to upload the repository to Cloudflare R2.
+- `conf/distributions`: APT repository configuration.
+- `.env.example`: Example environment configuration file.
+
+## How to Use
+
+1. **Set Up a Jenkins Server:**
+ Install Jenkins on your server. Follow the [Jenkins installation guide](https://www.jenkins.io/doc/book/installing/) for detailed instructions.
+
+2. **Create a New Pipeline Job in Jenkins:**
+ - In Jenkins, create a new pipeline job and point it to this repository.
+ - Configure the job to use the `Jenkinsfile` provided in this repository.
+
+3. **Configure Cloudflare R2:**
+ - Set up a Cloudflare R2 bucket.
+ - Configure your AWS CLI with a profile for Cloudflare R2.
+
+4. **Create a `.env` File:**
+ - Create a `.env` file in the root of this repository based on the `.env.example` file.
+ - Fill in the necessary details such as `BUCKET_NAME`, `AWS_PROFILE`, and `REPO_URL`.
+
+5. **Run the Pipeline:**
+ - The pipeline will automatically build the VyOS packages daily, update the APT repository, and upload the repository to Cloudflare R2.
+
+## Dependencies
+
+- Jenkins
+- reprepro
+- debuild
+- AWS CLI
+
+## Contributions
+
+Feel free to contribute improvements and new packages!
diff --git a/conf/distributions b/conf/distributions
new file mode 100644
index 0000000..b5bcfba
--- /dev/null
+++ b/conf/distributions
@@ -0,0 +1,4 @@
+Codename: debian-12
+Suite: stable
+Components: main
+Architectures: amd64
diff --git a/scripts/build_packages.sh b/scripts/build_packages.sh
new file mode 100644
index 0000000..3141a32
--- /dev/null
+++ b/scripts/build_packages.sh
@@ -0,0 +1,23 @@
+#!/bin/bash
+
+set -e
+
+# packages to build
+packages=("keepalived" "ethtool")
+
+WORKDIR=$(pwd)
+
+git clone https://github.com/vyos/vyos-build.git
+cd vyos-build/packages
+
+
+# build each package
+for pkg in "${packages[@]}"; do
+ cd "$pkg"
+ debuild -b -us -uc
+ cd ..
+done
+
+# copy the packages to the output directory
+mkdir -p "$WORKDIR/output"
+cp ../*.deb "$WORKDIR/output"
diff --git a/scripts/update_repo.sh b/scripts/update_repo.sh
new file mode 100644
index 0000000..606bf43
--- /dev/null
+++ b/scripts/update_repo.sh
@@ -0,0 +1,21 @@
+#!/bin/bash
+
+set -e
+
+WORKDIR=$(pwd)
+
+REPO_DIR="$WORKDIR/apt-repo"
+
+# create necessary directories
+mkdir -p "$REPO_DIR/{conf,dists,incoming,indices,pool,db}"
+
+# repo configuration
+cat > "$REPO_DIR/conf/distributions" <<EOF
+Codename: focal
+Suite: stable
+Components: main
+Architectures: amd64
+EOF
+
+# add packages to the repo
+reprepro -b "$REPO_DIR" includedeb focal "$WORKDIR/output/*.deb"
diff --git a/scripts/upload_repo.sh b/scripts/upload_repo.sh
new file mode 100644
index 0000000..3945c7d
--- /dev/null
+++ b/scripts/upload_repo.sh
@@ -0,0 +1,22 @@
+#!/bin/bash
+
+set -e
+
+# Load environment variables from .env file
+source .env
+
+# Define the working directory
+WORKDIR=$(pwd)
+
+# Install AWS CLI if not already installed
+if ! command -v aws &> /dev/null
+then
+ echo "AWS CLI not found, installing..."
+ pip install awscli
+fi
+
+# Configure AWS CLI to use the specified profile
+export AWS_PROFILE=$AWS_PROFILE
+
+# Upload the APT repository to Cloudflare R2
+aws s3 sync "$WORKDIR/apt-repo" "s3://$BUCKET_NAME" --delete \ No newline at end of file