cyclone-scheme / winds

The package manager for Cyclone Scheme.
28 stars 1 forks source link

Support semantic versioning #30

Closed arthurmaciel closed 3 years ago

arthurmaciel commented 3 years ago

@justinethier, I am going to implement semantic versioning support for Winds in the next few weeks.

With regard to dependency lists for packages, do you think it is OK, instead of using signs to inform version ranges, to support only the * sign?

justinethier commented 3 years ago

@arthurmaciel I think * is a good start for the first version. Let's get this working then consider if we want to add support for signs further down the road.

arthurmaciel commented 3 years ago

Thanks!

arthurmaciel commented 3 years ago

@justinethier, I am thinking about which character to use to separate package names from their versions on the command line. I think the most common character used is -, as in sxml-0.1.1.

But as... 1) I intend to support versions with only the major digit specified, such as sxml-1, 2) - is a valid and widely used Scheme character, 3) we decided to support - in Winds package names,

... it wouldn't be able to tell if 197 was an only-major version or the name of a package (e.g.. srfi-197).

So we would need to decide which character could be a name-version separator. It wouldn't be allowed on the package name itself. I thought about three options:

What do you think?

justinethier commented 3 years ago

Hey @arthurmaciel - I think the most elegant solution is using . as the separator. It is required anyway within the version number, is easy to type, and (even if we allowed it) is unlikely to be used as part of a package name. The only issue is that, as you wrote, the - character is typically used by other systems. But I think that is OK here.

How exactly would the full name + version be used on the command line? Is this just going to be for display purposes?

arthurmaciel commented 3 years ago

Thanks @justinethier!

I thought about this name-version syntax on the command line when trying to install many packages at once, specifying versions for (at least) some of them:

$ winds install sxml-0.1.3 srfi-197-1.3.4 iset-1.0 srfi-32 string-2.3

If I don't provide this option we could restrict the syntax of winds install to only one package at once and the problem would be solved. For instance in...

$ winds install A [B]

... A would correspond necessarily to a package name and B, if present, to its desired version.

And within the dependencies tag in package.scm the names and versions of packages could be provided as scheme lists (so no separator needed).

But I think it is fairly enough to allow the installation of multiple packages from command line. What do you think?

justinethier commented 3 years ago

Hey @arthurmaciel - I would hope that users are generally installing the latest version of each package, but it is helpful to have the extra flexibility to be able to install specific versions. I think it would be a worthwhile feature to allow specifying multiple version-specific packages at the command line.

arthurmaciel commented 3 years ago

@justinethier, I also expect that, but I think being able to select a specific version will allow Winds to manage Cyclone projects in the near future :)

justinethier commented 3 years ago

Testing with the latest version of winds, I am able to install char-set. So far so good. However, this happens if the command is run a second time:

ustin@ubuntu:~/Documents/winds$ sudo winds install char-set
Retrieving index file...
An error occurred ((Bad argument type #f #f)

Looks like this error is being raised in local-index-contains?. I think this is because we have a semantic version "0.3.0" passed to string->number, which returns #f. @arthurmaciel Do we want to use greatest-version from the new semantic library to do the comparison here? Not sure if that is quite right because the existing code is using >=.

arthurmaciel commented 3 years ago

@justinethier, thanks for pointing the problem and the solution :)

I created a pull request for that. It works here.

I updated all the packages I had write permissions on. Do you want me to update any other package?

arthurmaciel commented 3 years ago

For the record, below is a (messy) bash script to perform the version update for packages.

The index.txt need the package-name:version format. Eg.:

array-list:0.1
base64:0.3
benchmark:0.1
bytevector:0.1
char-set:0.2

The script itself:

#!/bin/bash -x

GH_METADATA_URL_TPL="https://github.com/cyclone-scheme/PACKAGE_NAME/raw/vVERSION_NUMBER/package.scm"
GH_TARBALL_URL_TPL="https://github.com/cyclone-scheme/PACKAGE_NAME/archive/vVERSION_NUMBER.tar.gz"
GH_SRC_URL_TPL="https://github.com/cyclone-scheme/PACKAGE_NAME.git"

FILENAME="index.txt"
LINES=$(cat $FILENAME)

for LINE in $LINES
do
    PKG=$(cut -d : -f 1 <<< $LINE)
    VERSION=$(cut -d : -f 2 <<< $LINE)
    NEW_VERSION=$VERSION.0
    QUOTED_NEW_VERSION=\"$NEW_VERSION\"

    TMP_GH_METADATA_URL=${GH_METADATA_URL_TPL/PACKAGE_NAME/$PKG}
    GH_METADATA_URL=${TMP_GH_METADATA_URL/VERSION_NUMBER/$VERSION}
    NEW_GH_METADATA_URL=${TMP_GH_METADATA_URL/VERSION_NUMBER/$NEW_VERSION}

    TMP_GH_TARBALL_URL=${GH_TARBALL_URL_TPL/PACKAGE_NAME/$PKG}
    GH_TARBALL_URL=${TMP_GH_TARBALL_URL/VERSION_NUMBER/$VERSION}
    NEW_GH_TARBALL_URL=${TMP_GH_TARBALL_URL/VERSION_NUMBER/$NEW_VERSION}

    GH_SRC_URL=${GH_SRC_URL_TPL/PACKAGE_NAME/$PKG}

    git clone $GH_SRC_URL &&
        cd $PKG &&
        sed -i s/$VERSION/$QUOTED_NEW_VERSION/g package.scm &&
        sed -i s/$VERSION/$QUOTED_NEW_VERSION/g README.md &&
        git add * &&
        git commit -m "Updated to semantic versioning" &&
        git push &&
        git tag -d v$VERSION &&
        git push origin :refs/tags/v$VERSION &&
        git tag v$NEW_VERSION &&
        git push --tags 
    sleep 3s &&
        cd .. &&
        rm -Rf $PKG
    sleep 1s &&
        wget -q $NEW_GH_TARBALL_URL &&
        SHA256SUM=$(sha256sum -z v$NEW_VERSION.tar.gz | cut -d ' ' -f 1) &&
        echo " ("$PKG >> new-index.scm &&
        echo "  ("$QUOTED_NEW_VERSION \"$NEW_GH_METADATA_URL\" >> new-index.scm &&
        echo "           "\"$NEW_GH_TARBALL_URL\" >> new-index.scm &&
        echo "           "\"$SHA256SUM\"\)\) >> new-index.scm
    rm v$NEW_VERSION.tar.gz
done
justinethier commented 3 years ago

@arthurmaciel That was fast and the fix works great over here too, thanks!

I like the script :). Please feel free to update the other packages. I gave you full permissions (should have done this a long time ago) so you are good to go. If I can help with anything please let me know.

arthurmaciel commented 3 years ago

Done! (as by #32)

justinethier commented 3 years ago

Excellent, thanks @arthurmaciel !