Skip to content

Conversation

@KwadFan
Copy link
Contributor

@KwadFan KwadFan commented Dec 17, 2020

According to #93

if set in config
Signed-off-by: Stephan Wendel <me@stephanwe.de>
@guysoft
Copy link
Owner

guysoft commented Dec 24, 2020

I don't understand what does it fix, also in #93. Because I don't understand the problem.
Can you explain

  1. how you are building the image?
  2. What output do you expect?
  3. What output did you get?
  4. A short explanation, if needed, why ${BASE_RELEASE_IMG_NAME%.img}.img" is better than IMG_FILENAME="${BASE_IMG_NAME}"?

@KwadFan
Copy link
Contributor Author

KwadFan commented Dec 24, 2020

Hi and a Merry Christmas for you and your Family.
Because english isnt my mothertongue, I'll try to explain what I meant as I could.

So, after I asked you by email where are the Descriptions are for Customizing the config file, I fiddled around with that.
After I understand how tho whole concept is to understand, I started to build my own Image.
I use the Docker Method with your custompios:devel Docker Image and latest RaspberryOS Image, because I am using Arch Linux and it is a Pita every update to fiddle around with docker-compose due Python Updates :( But thats not the Point.

I expected that, when I add BASE_RELEASE_IMG_NAME=mypersonal BASE_RELEASE_ZIP_NAME=mypersonalzip in config the Image would be renamed after building it.
but it doesnt.
My best way is to show code that I mean.

FILENAME=$(basename ls . | grep -e .img$ -e .raw$ | tail -n 1`)

if [ "${BASE_RELEASE_IMG_NAME}" == "default" ]; then
if [ "${BASE_DISTRO}" == "ubuntu" ]; then
CHANGE_STRING_LIST=( "ubuntu" )
else
CHANGE_STRING_LIST=( "raspbian" "raspios")
fi

# Handle variant name
for CHANGE_STRING in "${CHANGE_STRING_LIST[@]}"
do
    if [ -z "$1" ] || [ "$BASE_IGNORE_VARIANT_NAME" == "yes" ] ;then
        IMG_FILENAME=$(echo "${FILENAME::-4}"-"${DIST_VERSION}" | sed "s/${CHANGE_STRING}/${DIST_NAME,,}/").img
    else
        IMG_FILENAME=$(echo "${FILENAME::-4}"-"${DIST_VERSION}" | sed "s/${CHANGE_STRING}/${DIST_NAME,,}-$1/").img
    fi
done

else
IMG_FILENAME="${BASE_IMG_NAME}"
fi

mv "${FILENAME}" "${IMG_FILENAME}"

if [ "${BASE_RELEASE_COMPRESS}" == "yes" ]; then
echo "Compressing image"
if [ "${BASE_RELEASE_IMG_NAME}" == "default" ]; then
zip "${IMG_FILENAME::-4}.zip" "${IMG_FILENAME}"
else
zip "${BASE_IMG_NAME%.zip}".zip "${IMG_FILENAME}"
fi
else
echo "Not compressing because setting is disabled"
fi`

in the portion if [ "${BASE_RELEASE_IMG_NAME}" == "default" ]; then

you test for other Variable Content then "default", if it is on default the outcome is how it is expected.
the Image named in my case 2020-12-02-mypersonalos-buster-lite.img

But if I set those variables to my wanted names the image name is the same as my Input image.
So I greped the release script an thought about it.
Then I figured out that it is not "default" you set IMG_FILENAME="${BASE_IMG_NAME}"
but putting these variable in the config file has no effect. Same File Name as "default".
After that i wrote a little test script and as I expected I couldnt find where "${BASE_IMG_NAME}"
it gets parsed.
If you rename this to BASE_RELEASE_IMG_NAME you get the expected behavior to rename the IMG File to your liking.

This brought the Problem that thi zip file has the Name of the bare input file.
I hope that makes more sense to you.
Otherwise test the behavior by your self. and see what happends.
Another thing that brought me to this is - name: Copy output image run: cp ${{ github.workspace }}/repository/src/workspace/*-raspios-*-lite.img mainsailos-raspios-lite-latest.img

from a github - workflow .yml file.
This has BASE* Vars set but they had the Line above as Workaround through false renaming.

Regards Stephan

@KwadFan
Copy link
Contributor Author

KwadFan commented Dec 24, 2020

Ah and I forget: ${BASE_RELEASE_IMG_NAME%.img}.img" is the savest way to prevent a double .img at the end if someone ( is stupid like me) an puts filename extension in the VAR mistakenly ;)

@guysoft
Copy link
Owner

guysoft commented Dec 24, 2020

Got it, thanks for the contribution!

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