Skip to content

Commit

Permalink
GH-41679: [Release][Packaging][deb] Update package name in 01-prepare…
Browse files Browse the repository at this point in the history
…sh too (#41859)

### Rationale for this change

It's needed when we publish minor release. For example:

```console
$ dev/release/01-prepare.sh 16.0.0 17.0.0 # Release 16.0.0
...
$ dev/release/post-11-bump-versions.sh 16.0.0 17.0.0 # Released 16.0.0
...
$ dev/release/01-prepare.sh 16.1.0 17.0.0 # Release 16.1.0: This is effected
...
$ dev/release/post-11-bump-versions.sh 16.1.0 17.0.0 # Released 16.1.0
```

We can't detect minor release in `post-11-bump-versions.sh`.

### What changes are included in this PR?

Share update codes via `utils-prepare.sh` and use the same logic in `01-prepare.sh` too.

Linux packages related update code are also shared but it's not related to this change. Sorry.

### Are these changes tested?

Yes.

### Are there any user-facing changes?

Yes.
* GitHub Issue: #41679

Authored-by: Sutou Kouhei <[email protected]>
Signed-off-by: Sutou Kouhei <[email protected]>
  • Loading branch information
kou authored May 29, 2024
1 parent 4d524eb commit 9f58990
Show file tree
Hide file tree
Showing 6 changed files with 142 additions and 68 deletions.
45 changes: 42 additions & 3 deletions dev/release/01-prepare-test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,45 @@ def prepare(*targets)
sh(env, "dev/release/01-prepare.sh", @release_version, @next_version, "0")
end

data(:release_type, [nil, :major, :minor, :patch])
def test_deb_package_names
omit_on_release_branch
current_commit = git_current_commit
stdout = prepare("DEB_PACKAGE_NAMES")
changes = parse_patch(git("log", "-p", "#{current_commit}.."))
sampled_changes = changes.collect do |change|
first_hunk = change[:hunks][0]
first_removed_line = first_hunk.find { |line| line.start_with?("-") }
first_added_line = first_hunk.find { |line| line.start_with?("+") }
{
sampled_diff: [first_removed_line, first_added_line],
path: change[:path],
}
end
case release_type
when :major, :minor
expected_changes = [
{
sampled_diff: [
"-Package: libarrow#{@snapshot_so_version}",
"+Package: libarrow#{@so_version}",
],
path: "dev/tasks/linux-packages/apache-arrow/debian/control.in",
},
{
sampled_diff: [
"- - libarrow-acero#{@snapshot_so_version}-dbgsym_{no_rc_version}-1_[a-z0-9]+.d?deb",
"+ - libarrow-acero#{@so_version}-dbgsym_{no_rc_version}-1_[a-z0-9]+.d?deb",
],
path: "dev/tasks/tasks.yml",
},
]
else
expected_changes = []
end
assert_equal(expected_changes, sampled_changes, "Output:\n#{stdout}")
end

def test_linux_packages
user = "Arrow Developers"
email = "[email protected]"
Expand Down Expand Up @@ -96,7 +135,7 @@ def test_linux_packages
assert_equal(expected_changes, sampled_changes, "Output:\n#{stdout}")
end

data(:release_type, [:major, :minor, :patch])
data(:next_release_type, [:major, :minor, :patch])
def test_version_pre_tag
omit_on_release_branch

Expand Down Expand Up @@ -158,7 +197,7 @@ def test_version_pre_tag
],
},
]
unless release_type == :patch
unless next_release_type == :patch
expected_changes += [
{
path: "docs/source/_static/versions.json",
Expand Down Expand Up @@ -236,7 +275,7 @@ def test_version_pre_tag
],
},
]
if release_type == :major
if next_release_type == :major
expected_changes += [
{
path: "r/pkgdown/assets/versions.json",
Expand Down
15 changes: 6 additions & 9 deletions dev/release/01-prepare.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ release_candidate_branch="release-${version}-rc${rc_number}"

: ${PREPARE_DEFAULT:=1}
: ${PREPARE_CHANGELOG:=${PREPARE_DEFAULT}}
: ${PREPARE_DEB_PACKAGE_NAMES:=${PREPARE_DEFAULT}}
: ${PREPARE_LINUX_PACKAGES:=${PREPARE_DEFAULT}}
: ${PREPARE_VERSION_PRE_TAG:=${PREPARE_DEFAULT}}
: ${PREPARE_BRANCH:=${PREPARE_DEFAULT}}
Expand Down Expand Up @@ -78,16 +79,12 @@ if [ ${PREPARE_CHANGELOG} -gt 0 ]; then
git commit -m "MINOR: [Release] Update CHANGELOG.md for $version"
fi

if [ ${PREPARE_DEB_PACKAGE_NAMES} -gt 0 ]; then
update_deb_package_names "$(current_version)" "${version}"
fi

if [ ${PREPARE_LINUX_PACKAGES} -gt 0 ]; then
echo "Updating .deb/.rpm changelogs for $version"
cd $SOURCE_DIR/../tasks/linux-packages
rake \
version:update \
ARROW_RELEASE_TIME="$(date +%Y-%m-%dT%H:%M:%S%z)" \
ARROW_VERSION=${version}
git add */debian*/changelog */yum/*.spec.in
git commit -m "MINOR: [Release] Update .deb/.rpm changelogs for $version"
cd -
update_linux_packages "${version}" "$(date +%Y-%m-%dT%H:%M:%S%z)"
fi

if [ ${PREPARE_VERSION_PRE_TAG} -gt 0 ]; then
Expand Down
8 changes: 4 additions & 4 deletions dev/release/post-11-bump-versions-test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def bump_versions(*targets)
end
end

data(:release_type, [:major, :minor, :patch])
data(:next_release_type, [:major, :minor, :patch])
def test_version_post_tag
omit_on_release_branch

Expand Down Expand Up @@ -136,7 +136,7 @@ def test_version_post_tag
],
},
]
unless release_type == :patch
unless next_release_type == :patch
expected_changes += [
{
path: "docs/source/_static/versions.json",
Expand Down Expand Up @@ -202,7 +202,7 @@ def test_version_post_tag
],
},
]
if release_type == :major
if next_release_type == :major
expected_changes += [
{
path: "c_glib/tool/generate-version-header.py",
Expand Down Expand Up @@ -276,7 +276,7 @@ def test_version_post_tag

import_path = "github.com/apache/arrow/go/v#{@snapshot_major_version}"
hunks = []
if release_type == :major
if next_release_type == :major
lines = File.readlines(path, chomp: true)
target_lines = lines.each_with_index.select do |line, i|
line.include?(import_path)
Expand Down
50 changes: 3 additions & 47 deletions dev/release/post-11-bump-versions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,6 @@ version=$1
next_version=$2
next_version_snapshot="${next_version}-SNAPSHOT"

current_version=$(grep ARROW_VERSION "${SOURCE_DIR}/../../cpp/CMakeLists.txt" | \
head -n1 | \
grep -E -o '([0-9]+\.[0-9]+\.[0-9]+)')

case "${version}" in
*.0.0)
is_major_release=1
Expand All @@ -68,52 +64,12 @@ if [ ${BUMP_VERSION_POST_TAG} -gt 0 ]; then
fi

if [ ${BUMP_DEB_PACKAGE_NAMES} -gt 0 ] && \
[ "${next_version}" != "${current_version}" ]; then
echo "Updating .deb package names for ${next_version}"
so_version() {
local version=$1
local major_version=$(echo $version | sed -E -e 's/^([0-9]+)\.[0-9]+\.[0-9]+$/\1/')
local minor_version=$(echo $version | sed -E -e 's/^[0-9]+\.([0-9]+)\.[0-9]+$/\1/')
expr ${major_version} \* 100 + ${minor_version}
}
deb_lib_suffix=$(so_version $version)
next_deb_lib_suffix=$(so_version $next_version)
if [ "${deb_lib_suffix}" != "${next_deb_lib_suffix}" ]; then
cd $SOURCE_DIR/../tasks/linux-packages/apache-arrow
for target in debian*/lib*${deb_lib_suffix}.install; do
git mv \
${target} \
$(echo $target | sed -e "s/${deb_lib_suffix}/${next_deb_lib_suffix}/")
done
deb_lib_suffix_substitute_pattern="s/(lib(arrow|gandiva|parquet)[-a-z]*)${deb_lib_suffix}/\\1${next_deb_lib_suffix}/g"
sed -i.bak -E -e "${deb_lib_suffix_substitute_pattern}" debian*/control*
rm -f debian*/control*.bak
git add debian*/control*
cd -
cd $SOURCE_DIR/../tasks/
sed -i.bak -E -e "${deb_lib_suffix_substitute_pattern}" tasks.yml
rm -f tasks.yml.bak
git add tasks.yml
cd -
cd $SOURCE_DIR
sed -i.bak -E -e "${deb_lib_suffix_substitute_pattern}" rat_exclude_files.txt
rm -f rat_exclude_files.txt.bak
git add rat_exclude_files.txt
git commit -m "MINOR: [Release] Update .deb package names for $next_version"
cd -
fi
[ "${next_version}" != "$(current_version)" ]; then
update_deb_package_names "${version}" "${next_version}"
fi

if [ ${BUMP_LINUX_PACKAGES} -gt 0 ]; then
echo "Updating .deb/.rpm changelogs for $version"
cd $SOURCE_DIR/../tasks/linux-packages
rake \
version:update \
ARROW_RELEASE_TIME="$(git log -n1 --format=%aI apache-arrow-${version})" \
ARROW_VERSION=${version}
git add */debian*/changelog */yum/*.spec.in
git commit -m "MINOR: [Release] Update .deb/.rpm changelogs for $version"
cd -
update_linux_packages "${version}" "$(git log -n1 --format=%aI apache-arrow-${version})"
fi

if [ ${BUMP_PUSH} -gt 0 ]; then
Expand Down
29 changes: 25 additions & 4 deletions dev/release/test-helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,27 +96,48 @@ def parse_patch(patch)

module VersionDetectable
def release_type
(data || {})[:release_type] || :major
(data || {})[:release_type]
end

def next_release_type
(data || {})[:next_release_type] || :major
end

def detect_versions
top_dir = Pathname(__dir__).parent.parent
cpp_cmake_lists = top_dir + "cpp" + "CMakeLists.txt"
@snapshot_version = cpp_cmake_lists.read[/ARROW_VERSION "(.+?)"/, 1]
@snapshot_major_version = @snapshot_version.split(".")[0]
@release_version = @snapshot_version.gsub(/-SNAPSHOT\z/, "")
@snapshot_so_version = compute_so_version(@snapshot_version.split("-")[0])
release_version = @snapshot_version.gsub(/-SNAPSHOT\z/, "")
release_version_components = release_version.split(".")
case release_type
when nil
when :major
release_version_components[0].succ!
when :minor
release_version_components[1].succ!
when :patch
release_version_components[2].succ!
else
raise "unknown release type: #{release_type.inspect}"
end
@release_version = release_version_components.join(".")
@release_compatible_version = @release_version.split(".")[0, 2].join(".")
@so_version = compute_so_version(@release_version)
next_version_components = @release_version.split(".")
case release_type
case next_release_type
when :major
next_version_components[0].succ!
next_version_components[1] = 0
next_version_components[2] = 0
when :minor
next_version_components[1].succ!
next_version_components[2] = 0
when :patch
next_version_components[2].succ!
else
raise "unknown release type: #{release_type.inspect}"
raise "unknown next release type: #{next_release_type.inspect}"
end
@next_version = next_version_components.join(".")
@next_major_version = @next_version.split(".")[0]
Expand Down
63 changes: 62 additions & 1 deletion dev/release/utils-prepare.sh
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ update_versions() {
DESCRIPTION
rm -f DESCRIPTION.bak
git add DESCRIPTION

# Replace dev version with release version
sed -i.bak -E -e \
"/^<!--/,/^# arrow /s/^# arrow .+/# arrow ${base_version}/" \
Expand Down Expand Up @@ -206,3 +206,64 @@ update_versions() {
git add r/pkgdown/assets/versions.json
popd
}

current_version() {
grep ARROW_VERSION "${ARROW_DIR}/cpp/CMakeLists.txt" | \
head -n1 | \
grep -E -o '([0-9]+\.[0-9]+\.[0-9]+)'
}

so_version() {
local version=$1
local major_version=$(echo ${version} | cut -d. -f1)
local minor_version=$(echo ${version} | cut -d. -f2)
expr ${major_version} \* 100 + ${minor_version}
}

update_deb_package_names() {
local version=$1
local next_version=$2
echo "Updating .deb package names for ${next_version}"
deb_lib_suffix=$(so_version ${version})
next_deb_lib_suffix=$(so_version ${next_version})
if [ "${deb_lib_suffix}" != "${next_deb_lib_suffix}" ]; then
pushd ${ARROW_DIR}/dev/tasks/linux-packages/apache-arrow
for target in debian*/lib*${deb_lib_suffix}.install; do
git mv \
${target} \
$(echo ${target} | sed -e "s/${deb_lib_suffix}/${next_deb_lib_suffix}/")
done
deb_lib_suffix_substitute_pattern="s/(lib(arrow|gandiva|parquet)[-a-z]*)${deb_lib_suffix}/\\1${next_deb_lib_suffix}/g"
sed -i.bak -E -e "${deb_lib_suffix_substitute_pattern}" debian*/control*
rm -f debian*/control*.bak
git add debian*/control*
popd

pushd ${ARROW_DIR}/dev/tasks
sed -i.bak -E -e "${deb_lib_suffix_substitute_pattern}" tasks.yml
rm -f tasks.yml.bak
git add tasks.yml
popd

pushd ${ARROW_DIR}/dev/release
sed -i.bak -E -e "${deb_lib_suffix_substitute_pattern}" rat_exclude_files.txt
rm -f rat_exclude_files.txt.bak
git add rat_exclude_files.txt
git commit -m "MINOR: [Release] Update .deb package names for ${next_version}"
popd
fi
}

update_linux_packages() {
local version=$1
local release_time=$2
echo "Updating .deb/.rpm changelogs for ${version}"
pushd ${ARROW_DIR}/dev/tasks/linux-packages
rake \
version:update \
ARROW_RELEASE_TIME="${release_time}" \
ARROW_VERSION=${version}
git add */debian*/changelog */yum/*.spec.in
git commit -m "MINOR: [Release] Update .deb/.rpm changelogs for ${version}"
popd
}

0 comments on commit 9f58990

Please sign in to comment.