Compare commits

...

2 commits

Author SHA1 Message Date
leafee98 82734470d2 refactor package directory, enhance build script
All checks were successful
ci/woodpecker/push/build Pipeline was successful
- update makedeb
- use bin, git, normal, leafee98 to classify packages
- only build package from leafee98 and bin in ci
- add script to build all packages locally
- add more log about running hook in build.sh
2023-08-18 17:28:14 +08:00
leafee98 c6a80b741b Fix missing quotes when retrieving PACKAGE_DIR 2023-08-18 15:59:10 +08:00
19 changed files with 67 additions and 28 deletions

6
.gitignore vendored
View file

@ -1,8 +1,8 @@
/secrets.env
/packages/*/*
!/packages/*/DEBBUILD
!/packages/*/materials
/packages/*/*/*
!/packages/*/*/DEBBUILD
!/packages/*/*/materials
!/script/*
!/makedeb

View file

@ -2,28 +2,25 @@ steps:
- name: build_all
image: debian-pack:0.4
secrets:
- WEBDAV_USER
- WEBDAV_PASS
- WEBDAV_HOST
- WEBDAV_REPOPATH
- WEBDAV_USER
environment:
- WEBDAV_UPLOAD_TARGET=https://dufs.leafee98.com/apt/income
- APT_BASE=https://dufs.leafee98.com/apt
commands:
- rm -f /tmp/apt-file-exists-cache.json
- hook_str="$(realpath ./script/package_exists.py)
--filename {}
--cache-file /tmp/apt-file-exists-cache.json
--package-arch amd64
--apt-base https://dufs.leafee98.com/apt/"
- ./script/build_all.sh
- ./script/build.sh
--makedeb-path makedeb/makedeb
--package-exists-hook "$hook_str"
--upload-to-webdav "https://dufs.leafee98.com/apt/income"
--package-exists-hook "
$(realpath ./script/package_exists.py)
--filename {}
--cache-file /tmp/apt-file-exists-cache.json
--package-arch amd64
--apt-base $APT_BASE
"
--upload-to-webdav "$WEBDAV_UPLOAD_TARGET"
--webdav-user "$WEBDAV_USER"
--webdav-pass "$WEBDAV_PASS"
--package packages/apt-repo-updater
--package packages/dufs-bin
--package packages/filebrowser-bin
--package packages/forgejo-bin
--package packages/neovim-bin
--package packages/plik-bin
--package packages/static-deployer-git
--package-dir packages/bin
--package-dir packages/leafee98

@ -1 +1 @@
Subproject commit 3065562dab1aa1fffc8e0fe3b8885acc93e3c9ad
Subproject commit 9aedecc62e9585ba1d9b88efe083b52105e0947f

View file

@ -14,8 +14,9 @@ function msg_warn {
function usage {
echo "$_PROGRAM_NAME:"
echo " --package <dir-name> add a dir to build, allow use it multi times"
echo " --package-dir <dir> all dir in this directory is a package"
echo " --package <dir-name> add a dir to build, can use multi times"
echo " --package-dir <dir> all dir in this directory is a package,"
echo " can use multi times"
echo " --makedeb-path <path> specify the path of makedeb"
echo " --upload-to-webdav https://webdav_host/path/dir"
echo " upload built file to a webdav server"
@ -46,8 +47,13 @@ function run_hook {
local exe_str="$1"
local place_holder="$2"
local package_name="$3"
local log_exe_str="${4-}"
local final_exe_str="${exe_str/$place_holder/$package_name}"
echo $final_exe_str
if [[ -n "${log_exe_str}" ]] ; then
msg_info "Running: $final_exe_str"
fi
$final_exe_str
}
@ -77,7 +83,12 @@ while (( "$#" >= 1 )); do
--upload-to-webdav) UPLOAD_TO_WEBDAV="$2" ; shift ;;
--webdav-user) WEBDAV_USER="$2" ; shift ;;
--webdav-pass) WEBDAV_PASS="$2" ; shift ;;
--package-exists-hook) PACKAGE_EXISTS_HOOK="$2" ; shift ;;
--package-exists-hook)
PACKAGE_EXISTS_HOOK="$2"
# strip white space, see https://stackoverflow.com/a/3352015
PACKAGE_EXISTS_HOOK="${PACKAGE_EXISTS_HOOK#"${PACKAGE_EXISTS_HOOK%%[![:space:]]*}"}"
PACKAGE_EXISTS_HOOK="${PACKAGE_EXISTS_HOOK%"${PACKAGE_EXISTS_HOOK##*[![:space:]]}"}"
shift ;;
--)
shift
MAKEDEB_ARGS=("$@")
@ -99,7 +110,7 @@ else
MAKEDEB_PATH="$(realpath "$MAKEDEB_PATH")"
fi
if [[ -n ${PACKAGE_DIR-} && "${#PACKAGE_DIR}" -gt 0 ]] ; then
if [[ -n "${PACKAGE_DIR-}" && "${#PACKAGE_DIR}" -gt 0 ]] ; then
for p in "${PACKAGE_DIR[@]}" ; do
for f in "$p"/* ; do
_PACKGES_TO_BUILD+=("$f")
@ -114,6 +125,10 @@ if [[ "${#_PACKGES_TO_BUILD[@]}" -eq 0 ]] ; then
msg_info "No package to build, exiting..."
fi
if [[ -n "$PACKAGE_EXISTS_HOOK" ]] ; then
msg_info "hook for checking if package exists: $PACKAGE_EXISTS_HOOK"
fi
for package in "${_PACKGES_TO_BUILD[@]}" ; do
(
msg_info "$_DELIMITER"
@ -130,7 +145,8 @@ for package in "${_PACKGES_TO_BUILD[@]}" ; do
if [[ -n "${PACKAGE_EXISTS_HOOK}" ]] ; then
ret=0
run_hook "$PACKAGE_EXISTS_HOOK" "{}" "$package_name" || ret="$?"
msg_info "Checking if package $package_name exists..."
run_hook "$PACKAGE_EXISTS_HOOK" "{}" "$package_name" log_exe_str || ret="$?"
if [[ $ret -eq 0 ]] ; then
msg_info "Package ${package_name} already built, skip"
@ -138,6 +154,8 @@ for package in "${_PACKGES_TO_BUILD[@]}" ; do
fi
fi
msg_info "Start building..."
"$MAKEDEB_PATH" --noextract "${MAKEDEB_ARGS[@]}" && ret=$? || ret=$?
if [[ $ret -ne 0 ]] ; then
msg_warn "Error occurred when running makedeb, skip this package"

24
script/local_build.sh Executable file
View file

@ -0,0 +1,24 @@
#!/usr/bin/env bash
WEBDAV_UPLOAD_TARGET=https://dufs.leafee98.com/apt/income
APT_BASE=https://dufs.leafee98.com/apt
./script/build.sh \
--makedeb-path makedeb/makedeb \
--package-exists-hook "
$(realpath ./script/package_exists.py)
--filename {}
--cache-file /tmp/apt-file-exists-cache.json
--package-arch amd64
--apt-base $APT_BASE \
"\
--package-dir packages/bin \
--package-dir packages/leafee98 \
--package-dir packages/git \
--package-dir packages/normal \
-- \
-f
# --upload-to-webdav "$WEBDAV_UPLOAD_TARGET" \
# --webdav-user "$WEBDAV_USER" \
# --webdav-pass "$WEBDAV_PASS" \