Skip to content

Commit

Permalink
Add plain-copy list to .pkgmeta for copying files without processing
Browse files Browse the repository at this point in the history
  • Loading branch information
nebularg committed Feb 27, 2022
1 parent 7957498 commit fafae95
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 18 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ for more info.
- *externals* (Git, SVN, and Mercurial) Caveats: An external's .pkgmeta is only
parsed for ignore and externals will not have localization keywords replaced.
- *ignore*
- *plain-copy*
- *changelog-title*
- *manual-changelog*
- *move-folders*
Expand Down
66 changes: 48 additions & 18 deletions release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -759,6 +759,7 @@ changelog=
changelog_markup="text"
enable_nolib_creation=
ignore=
unchanged=
contents=
nolib_exclude=
wowi_gen_changelog="true"
Expand Down Expand Up @@ -798,7 +799,7 @@ parse_ignore() {
yaml_line=${yaml_line#"${yaml_line%%[! ]*}"} # trim leading whitespace
# Get the YAML list item.
yaml_listitem "$yaml_line"
if [ "$pkgmeta_phase" = "ignore" ]; then
if [[ "$pkgmeta_phase" == "ignore" || "$pkgmeta_phase" == "plain-copy" ]]; then
pattern=$yaml_item
if [ -d "$checkpath/$pattern" ]; then
pattern="$copypath$pattern/*"
Expand All @@ -808,10 +809,18 @@ parse_ignore() {
else
pattern="$copypath$pattern"
fi
if [ -z "$ignore" ]; then
ignore="$pattern"
else
ignore="$ignore:$pattern"
if [[ "$pkgmeta_phase" == "ignore" ]]; then
if [ -z "$ignore" ]; then
ignore="$pattern"
else
ignore="$ignore:$pattern"
fi
elif [[ "$pkgmeta_phase" == "plain-copy" ]]; then
if [ -z "$unchanged" ]; then
unchanged="$pattern"
else
unchanged="$unchanged:$pattern"
fi
fi
fi
;;
Expand Down Expand Up @@ -903,6 +912,20 @@ if [ -f "$pkgmeta_file" ]; then
ignore="$ignore:$pattern"
fi
;;
plain-copy)
pattern=$yaml_item
if [ -d "$topdir/$pattern" ]; then
pattern="$pattern/*"
elif [ ! -f "$topdir/$pattern" ]; then
# doesn't exist so match both a file and a path
pattern="$pattern:$pattern/*"
fi
if [ -z "$unchanged" ]; then
unchanged="$pattern"
else
unchanged="$unchanged:$pattern"
fi
;;
tools-used)
relations["$yaml_item"]="tool"
;;
Expand Down Expand Up @@ -1579,33 +1602,32 @@ copy_directory_tree() {
( cd "$_cdt_srcdir" && eval "$_cdt_find_cmd" ) | while read -r file; do
file=${file#./}
if [ -f "$_cdt_srcdir/$file" ]; then
# Check if the file should be ignored.
skip_copy=
_cdt_skip_copy=
_cdt_only_copy=
# Prefix external files with the relative pkgdir path
_cdt_check_file=$file
if [ -n "${_cdt_destdir#$pkgdir}" ]; then
_cdt_check_file="${_cdt_destdir#$pkgdir/}/$file"
fi
# Skip files matching the colon-separated "ignored" shell wildcard patterns.
if [ -z "$skip_copy" ] && match_pattern "$_cdt_check_file" "$_cdt_ignored_patterns"; then
skip_copy="true"
if match_pattern "$_cdt_check_file" "$_cdt_ignored_patterns"; then
_cdt_skip_copy="true"
fi
# Never skip files that match the colon-separated "unchanged" shell wildcard patterns.
unchanged=
if [ -n "$skip_copy" ] && match_pattern "$file" "$_cdt_unchanged_patterns"; then
skip_copy=
unchanged="true"
if match_pattern "$file" "$_cdt_unchanged_patterns"; then
_cdt_skip_copy=
_cdt_only_copy="true"
fi
# Copy unskipped files into $_cdt_destdir.
if [ -n "$skip_copy" ]; then
if [ -n "$_cdt_skip_copy" ]; then
echo " Ignoring: $file"
else
dir=${file%/*}
if [ "$dir" != "$file" ]; then
mkdir -p "$_cdt_destdir/$dir"
fi
# Check if the file matches a pattern for keyword replacement.
if [ -n "$unchanged" ] || ! match_pattern "$file" "*.lua:*.md:*.toc:*.txt:*.xml"; then
if [ -n "$_cdt_only_copy" ] || ! match_pattern "$file" "*.lua:*.md:*.toc:*.txt:*.xml"; then
echo " Copying: $file (unchanged)"
cp "$_cdt_srcdir/$file" "$_cdt_destdir/$dir"
else
Expand Down Expand Up @@ -1728,12 +1750,20 @@ if [ -z "$skip_copying" ]; then
[ -n "$split" ] && cdt_args+="S"
[ -n "$game_type" ] && cdt_args+=" -g $game_type"
[ -n "$ignore" ] && cdt_args+=" -i \"$ignore\""
[ -n "$changelog" ] && cdt_args+=" -u \"$changelog\""
if [ -n "$changelog" ]; then
if [ -z "$unchanged" ]; then
unchanged="$changelog"
else
unchanged="$unchanged:$changelog"
fi
fi
[ -n "$unchanged" ] && cdt_args+=" -u \"$unchanged\""
eval copy_directory_tree "$cdt_args" "\"$topdir\"" "\"$pkgdir\""
fi

# Reset ignore and parse pkgmeta ignores again to handle ignoring external paths
ignore=
unchanged=
parse_ignore "$pkgmeta_file"

###
Expand Down Expand Up @@ -1864,9 +1894,9 @@ checkout_external() {
if [[ "$_external_uri" == *"wowace.com"* || "$_external_uri" == *"curseforge.com"* ]]; then
project_site="https://wow.curseforge.com"
fi
# If a .pkgmeta file is present, process it for an "ignore" list.
# If a .pkgmeta file is present, process it for "ignore" and "plain-copy" lists.
parse_ignore "$_cqe_checkout_dir/.pkgmeta" "$_external_dir"
copy_directory_tree -dnpe -i "$ignore" "$_cqe_checkout_dir" "$pkgdir/$_external_dir"
copy_directory_tree -dnpe -i "$ignore" -u "$unchanged" "$_cqe_checkout_dir" "$pkgdir/$_external_dir"
)
# Remove the ".checkout" subdirectory containing the full checkout.
if [ -d "$_cqe_checkout_dir" ]; then
Expand Down

0 comments on commit fafae95

Please sign in to comment.