|
33 | 33 | git checkout "$REVISION" |
34 | 34 | fi |
35 | 35 |
|
36 | | -# initialize the submodules |
37 | | -git submodule update --init --recursive |
| 36 | +# read optional exclusions from .copr-ci config file |
| 37 | +# each non-empty, non-comment line is treated as a submodule path or directory |
| 38 | +# to exclude (relative to the repo root, e.g. "third-party/build-deps") |
| 39 | +EXCLUDED_PATHS=() |
| 40 | +if [[ -f ".copr-ci" ]]; then |
| 41 | + echo "Found .copr-ci config file, reading exclusions..." |
| 42 | + while IFS= read -r line || [[ -n "$line" ]]; do |
| 43 | + # skip empty lines and comments |
| 44 | + [[ -z "$line" || "$line" =~ ^# ]] && continue |
| 45 | + EXCLUDED_PATHS+=("$line") |
| 46 | + echo " Excluding: $line" |
| 47 | + done < ".copr-ci" |
| 48 | +fi |
| 49 | + |
| 50 | +# initialize the submodules, skipping any excluded paths |
| 51 | +if [[ ${#EXCLUDED_PATHS[@]} -gt 0 ]]; then |
| 52 | + # get all top-level submodule paths, then init only the ones not excluded |
| 53 | + mapfile -t TOP_SUBMODULES < <(git submodule status | awk '{print $2}') |
| 54 | + |
| 55 | + for submodule in "${TOP_SUBMODULES[@]}"; do |
| 56 | + skip=false |
| 57 | + for excluded in "${EXCLUDED_PATHS[@]}"; do |
| 58 | + # match exact path or any path that starts with the excluded prefix |
| 59 | + if [[ "$submodule" == "$excluded" || "$submodule" == "$excluded/"* ]]; then |
| 60 | + skip=true |
| 61 | + break |
| 62 | + fi |
| 63 | + done |
| 64 | + if [[ "$skip" == false ]]; then |
| 65 | + git submodule update --init --recursive --depth 1 -- "$submodule" |
| 66 | + else |
| 67 | + echo "Skipping submodule: $submodule" |
| 68 | + fi |
| 69 | + done |
| 70 | +else |
| 71 | + git submodule update --init --recursive --depth 1 |
| 72 | +fi |
38 | 73 |
|
39 | 74 | # get the tag of this commit IF it has one |
40 | 75 | TAG=$(git tag --points-at HEAD | head -n1) |
@@ -74,5 +109,9 @@ sed -i "s|%global build_version 0|%global build_version ${TAG}|" "${resultdir}"/ |
74 | 109 | sed -i "s|%global branch 0|%global branch ${BRANCH}|" "${resultdir}"/*.spec |
75 | 110 | sed -i "s|%global commit 0|%global commit ${COMMIT}|" "${resultdir}"/*.spec |
76 | 111 |
|
77 | | -# create a tarball of the source code |
78 | | -tar -czf "${resultdir}/tarball.tar.gz" . |
| 112 | +# create a tarball of the source code, excluding any configured paths |
| 113 | +TAR_EXCLUDE_ARGS=() |
| 114 | +for path in "${EXCLUDED_PATHS[@]}"; do |
| 115 | + TAR_EXCLUDE_ARGS+=("--exclude=./${path}") |
| 116 | +done |
| 117 | +tar -czf "${resultdir}/tarball.tar.gz" "${TAR_EXCLUDE_ARGS[@]}" . |
0 commit comments