Skip to content

Update the release script to update linker mapping file#1001

Merged
igaw merged 2 commits intolinux-nvme:masterfrom
igaw:extend-release
Apr 24, 2025
Merged

Update the release script to update linker mapping file#1001
igaw merged 2 commits intolinux-nvme:masterfrom
igaw:extend-release

Conversation

@igaw
Copy link
Copy Markdown
Collaborator

@igaw igaw commented Apr 23, 2025

It is not obvious to start a new section after a release. Add an explicit new UNRELEASED section so contributers know where to put a new symbol.

I tried to get this done in awk and I really don't have a lot of experience with it. Yes, I asked a LLM to support me with it...

It is not obvious to start a new section after a release. Add an
explicit new UNRELEASED section so contributers know where to put a new
symbol.

Signed-off-by: Daniel Wagner <[email protected]>
@igaw
Copy link
Copy Markdown
Collaborator Author

igaw commented Apr 23, 2025

If this is utterly shit, we could also just use a python script...

@jk-ozlabs
Copy link
Copy Markdown
Collaborator

jk-ozlabs commented Apr 23, 2025

You probably don't want the release version to have an UNRELEASED section, right? Should those just be created (say, manually) on the first symbol change following a release?

In which case, all release.sh needs to do is sed -e s/UNRELEASED/LIBNVME_$version/

@jk-ozlabs
Copy link
Copy Markdown
Collaborator

.. I guess that doesn't address the "where do contributors add their changes" thing though

@jk-ozlabs
Copy link
Copy Markdown
Collaborator

note that the library base names change between libnvme (LIBVNME_ver) and libnvme-mi (LIBNVME_MI_ver)

@jk-ozlabs
Copy link
Copy Markdown
Collaborator

hm, and we seem to have different version syntax in these. ie:

LIBNVME_1.12

vs

LIBNVME_MI_1_12

libnvme had changed from _ to . in 1.9

@igaw
Copy link
Copy Markdown
Collaborator Author

igaw commented Apr 23, 2025

My idea was always have a UNRELEASED section at the beginning of the linker script, because it happens very often new symbols are placed somewhere. Though if we can't have the 'global' label it's kind of useless. Maybe we should just add a proper comment at the beginning and have the sed rename thing.

Though one think I do like at this awk script is the sorting of the new symbol names.

@igaw
Copy link
Copy Markdown
Collaborator Author

igaw commented Apr 23, 2025

libnvme had changed from _ to . in 1.9

Argh! That's why a release script is needed

@jk-ozlabs
Copy link
Copy Markdown
Collaborator

My idea was always have a UNRELEASED section at the beginning of the linker script

OK, makes sense. So we want something along the lines of:

  • if there is an UNRELEASED section that contains symbols, rename it to the new version, and add a new UNRELEASED section
  • if there are no symbols in UNRELEASED, leave it as-is

is that correct?

@igaw
Copy link
Copy Markdown
Collaborator Author

igaw commented Apr 23, 2025

Yes that is what I tried to do with the awk script. It's not easy to read I agree.

(hit the wrong button...)

@igaw igaw closed this Apr 23, 2025
@igaw igaw reopened this Apr 23, 2025
@jk-ozlabs
Copy link
Copy Markdown
Collaborator

Something like this?

declare -A maps
maps=(
    [src/libnvme.map]=LIBNVME
    [src/libnvme-mi.map]=LIBNVME_MI
)

lib_ver="${ver//./_}"

for map_file in "${!maps[@]}"
do
    lib_name=${maps[$map_file]}

    if [ ! -f "${map_file}" ]; then
       continue
    fi

    lib_unreleased="${lib_name}_UNRELEASED"

    # Check if UNRELEASED has symbols
    if ! awk -v lib_unreleased="$lib_unreleased" '
        $0 ~ "^"lib_unreleased { in_section = 1; next }
        in_section && $0 ~ /\}/ { exit }
        in_section && $0 !~ /^[[:space:]]*($|\/|\/\*|\*|#)/ { found = 1; exit }
        END { exit !found }
    ' "${map_file}"; then
        continue
    fi

    sed -i -e "s/${lib_unreleased}/${lib_name}_${lib_ver}/" "$map_file"

    git add "${map_file}"
    echo "${map_file} updated."
done

Comment thread src/libnvme-mi.map
@@ -1,3 +1,7 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
LIBNVME_UNRELEASED {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LIBNVME_MI_UNRELEASED

@jk-ozlabs
Copy link
Copy Markdown
Collaborator

Ah, plus adding the new UNRELEASED section, just a minute.

@igaw
Copy link
Copy Markdown
Collaborator Author

igaw commented Apr 23, 2025

Something like this?

yes, that is way saner than what I've done :)

@jk-ozlabs
Copy link
Copy Markdown
Collaborator

declare -A maps
maps=(
    [src/libnvme.map]=LIBNVME
    [src/libnvme-mi.map]=LIBNVME_MI
)

lib_ver="${ver//./_}"

for map_file in "${!maps[@]}"
do
    lib_name=${maps[$map_file]}

    if [ ! -f "${map_file}" ]; then
       continue
    fi

    lib_unreleased="${lib_name}_UNRELEASED"

    # Check if UNRELEASED has symbols
    if ! awk -v lib_unreleased="$lib_unreleased" '
        $0 ~ "^"lib_unreleased { in_section = 1; next }
        in_section && $0 ~ /\}/ { exit }
        in_section && $0 !~ /^[[:space:]]*($|\/|\/\*|\*|#)/ { found = 1; exit }
        END { exit !found }
    ' "${map_file}"; then
        continue
    fi

    sed -i \
        -e "s/^${lib_unreleased}\s*{/&\n};\n\n${lib_name}_${lib_ver} {/" \
        "$map_file"

    git add "${map_file}"
    echo "${map_file} updated."
done

@jk-ozlabs
Copy link
Copy Markdown
Collaborator

(only the sed expression has changed there)

To reduce the confusion where to put a new exported symbol, there is a
new UNRELEASED section with all the unreleased symbols. On release,
update the export map to the new release version and add back the
UNRELEASED section.

Signed-off-by: Daniel Wagner <[email protected]>
@igaw
Copy link
Copy Markdown
Collaborator Author

igaw commented Apr 23, 2025

I've gave it a quick test and it seems to do the trick! Way better than my awk hack...

@igaw
Copy link
Copy Markdown
Collaborator Author

igaw commented Apr 23, 2025

I'd like to change the author credits to you if this is okay with you.

@jk-ozlabs
Copy link
Copy Markdown
Collaborator

No need, all I did was write a bit of sed there :)

@igaw igaw merged commit 9ad93c4 into linux-nvme:master Apr 24, 2025
12 checks passed
@igaw
Copy link
Copy Markdown
Collaborator Author

igaw commented Apr 24, 2025

Okay, thanks anyway! :)

@igaw igaw deleted the extend-release branch April 24, 2025 08:06
@jk-ozlabs
Copy link
Copy Markdown
Collaborator

I think this still had the LIBNVME_UNRELEASED tag for libnvme-mi.map?

@igaw
Copy link
Copy Markdown
Collaborator Author

igaw commented Apr 24, 2025

Oops. Fix it directly. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants