You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

104 lines
2.0 KiB

#!/bin/bash
packagesfile=packages.txt
outfile=.drone.yml
buildimage=registry.186526.xyz/docker-makepkg:next
volumename=oblivion
volumepath=/oblivion
buildjobfile=buildjob.txt
apiurl=http://10.0.0.85:8081/service/rest/v1
function registerPackage(){
echo "Registering Package $1"
# Check if custom command
IFS='^' read -ra ADDR <<< "$1"
if [ ${#ADDR[@]} -eq 1 ]; then
# No Commands specified
echo " - name: $1
image: $buildimage
failure: ignore
volumes:
- name: $volumename
path: $volumepath
environment:
DOCKER_MAKEPKG_PATH: /drone/src/"\$DRONE_STEP_NAME"
DOCKER_OUT_PATH: $volumepath
REPO_API_URL: $apiurl
" >> "$outfile"
else
packageName=${ADDR[0]}
echo " - name: $packageName
image: $buildimage
failure: ignore
volumes:
- name: $volumename
path: $volumepath
environment:
DOCKER_MAKEPKG_PATH: /drone/src/\$DRONE_STEP_NAME
DOCKER_OUT_PATH: $volumepath
REPO_API_URL: $apiurl
commands:" >> "$outfile"
for i in "${ADDR[@]}"; do
if [ "$i" != "$packageName" ]
then
echo " - $i" >> "$outfile"
fi
done
echo " - /bin/su -s /bin/sh -c '/run.sh /drone/src/\"\$DRONE_STEP_NAME\" \"\$OUTPUT_DIR\"' notroot" >> "$outfile"
echo "
" >> "$outfile"
fi
}
function header(){
echo "kind: pipeline
type: docker
name: default
clone:
git:
image: plugins/git
recursive: true
steps:
- name: submodules
image: alpine/git
commands:
- git submodule status
- git submodule update --init --recursive
" > "$outfile"
}
function registerBuildStep(){
echo "Registering Build Job"
cat "$buildjobfile" >> "$outfile"
}
function writeVolumes(){
echo "Write Volumes"
echo "
" >> "$outfile"
echo "volumes:
- name: oblivion
temp: {}" >> "$outfile"
}
# Write Header
header
# Read packages.txt
while read line; do
registerPackage "$line"
done <"$packagesfile"
registerBuildStep
writeVolumes