Ideas on a new kind of package

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Ideas on a new kind of package

Holger Freyther
Hi,

Problem:
when testing my code I am using FileStream fileIn: 'Code.st' a lot. This
means that my code needs to work with and without namespaces and I used
"PackageLoader fileInPackage: .." inside the .st files. The namespace
problem is handled by changging the code (mostly extensions to String,
ByteArray). The PackageLoader code was an issue when I started to port to
Pharo so I removed it.

Proposal:
Create a new kind of Package that is actually just the git repository. With
some tooling help one could:

        - Have gst-sunit work on the unpackaged package.
        - Make it more easy to load the CWD into an image without any of
          the above issues.


Evolution:
I still dream about an in-situ FileOut that would keep the formatting, other
comments, order and replaces the file. One could enable this in-situ fileout
for these kind of 'editable' packages?


comments?
        holger


_______________________________________________
help-smalltalk mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: Ideas on a new kind of package

Holger Freyther
On Sat, Mar 02, 2013 at 05:37:04PM +0100, Holger Hans Peter Freyther wrote:
> Hi,

Hi again,

> Proposal:
> Create a new kind of Package that is actually just the git repository. With
> some tooling help one could:
>
> - Have gst-sunit work on the unpackaged package.
> - Make it more easy to load the CWD into an image without any of
>  the above issues.

based on the chat with today. I have attached a prototype for this new
kind of package format. It can be used like this:

        PackageLoader
                addDirPackage: 'packages/stinst/parser/package.xml;
                fileInPackage: 'Parser.dir'.

For every dir package the package will be made available as NAME and
NAME.dir. This is done to easily take presedence over the normal package.

What do you think? Somehow it would be cleaner if the new package and
the star package would have a common base class instead of subclassing
the star one. On the other hand the package.xml is a 'star' thing.

comments?
        holger

PS: Any ideas of an in-situ output? My goal is really to work on a package
and use PackageLoader dirPackageOut: 'Parser'. And everything is written
back to where it came from. Does anyone share this idea with me?

_______________________________________________
help-smalltalk mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-smalltalk

DirPackageInfo.st (2K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Ideas on a new kind of package

Gwenaël Casaccio
On 04/03/2013 20:59, Holger Hans Peter Freyther wrote:

> On Sat, Mar 02, 2013 at 05:37:04PM +0100, Holger Hans Peter Freyther wrote:
>> Hi,
> Hi again,
>
>> Proposal:
>> Create a new kind of Package that is actually just the git repository. With
>> some tooling help one could:
>>
>> - Have gst-sunit work on the unpackaged package.
>> - Make it more easy to load the CWD into an image without any of
>>  the above issues.
> based on the chat with today. I have attached a prototype for this new
> kind of package format. It can be used like this:
>
> PackageLoader
> addDirPackage: 'packages/stinst/parser/package.xml;
> fileInPackage: 'Parser.dir'.
>
> For every dir package the package will be made available as NAME and
> NAME.dir. This is done to easily take presedence over the normal package.
>
> What do you think? Somehow it would be cleaner if the new package and
> the star package would have a common base class instead of subclassing
> the star one. On the other hand the package.xml is a 'star' thing.
>
> comments?
> holger
>
> PS: Any ideas of an in-situ output? My goal is really to work on a package
> and use PackageLoader dirPackageOut: 'Parser'. And everything is written
> back to where it came from. Does anyone share this idea with me?
>
>
> _______________________________________________
> help-smalltalk mailing list
> [hidden email]
> https://lists.gnu.org/mailman/listinfo/help-smalltalk

Hi,

I really like the idea but I would made some changes:

1) It doesn't make sens to me to add a package to a package repository
list thus
       PackageLoader fileInPackage: 'packages/..../package.xml' seems
enough
2) Please don't subclass the star package really it hurts me.

Cheers,
Gwen


_______________________________________________
help-smalltalk mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

[PATCH] kernel: Introduce the DirPackage packages to help with development

Holger Freyther
In reply to this post by Holger Freyther
From: Holger Hans Peter Freyther <[hidden email]>

Add a way to load a Package from the package.xml and not go through
the creation of a star file. This can make developing with packages
more effective.

2013-03-24  Holger Hans Peter Freyther  <[hidden email]>

        * libgst/files.c: Add DirPackage.st to the bootstrap.
        * kernel/DirPackage.st: Add new file with the DirPackage and DirPackagesContainer.
        * kernel/PkgLoader.st: Refactor and create ExternalPackage baseclass.
---
 ChangeLog            |    6 +++
 NEWS                 |    7 +++
 kernel/DirPackage.st |  132 ++++++++++++++++++++++++++++++++++++++++++++++++++
 kernel/PkgLoader.st  |   28 +++++++----
 libgst/files.c       |    1 +
 5 files changed, 165 insertions(+), 9 deletions(-)
 create mode 100644 kernel/DirPackage.st

diff --git a/ChangeLog b/ChangeLog
index 6b6d9d2..8a3085d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2013-03-24  Holger Hans Peter Freyther  <[hidden email]>
+
+ * libgst/files.c: Add DirPackage.st to the bootstrap.
+ * kernel/DirPackage.st: Add new file with the DirPackage and DirPackagesContainer.
+ * kernel/PkgLoader.st: Refactor and create ExternalPackage baseclass.
+
 2013-03-04  Holger Hans Peter Freyther  <[hidden email]>
 
  * kernel/PkgLoader.st: Remove unused variable.
diff --git a/NEWS b/NEWS
index b5e9127..d768a8f 100644
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,12 @@
 List of user-visible changes in GNU Smalltalk
 
+NEWS FROM 3.2.5 to 3.2.90
+
+o   Add PackageLoader>>#loadPackageFromFile: to load a package by using
+    a package.xml. This can make the development more effective.
+
+-----------------------------------------------------------------------------
+
 NEWS FROM 3.2.4 to 3.2.5
 
 o   Add Delay>>#value:onTimeoutDo: as an easy way to timeout an operation.
diff --git a/kernel/DirPackage.st b/kernel/DirPackage.st
new file mode 100644
index 0000000..2cdc57e
--- /dev/null
+++ b/kernel/DirPackage.st
@@ -0,0 +1,132 @@
+"======================================================================
+|
+|   Load packages from a directory without loading a Star file.
+|
+|
+ ======================================================================"
+
+"======================================================================
+|
+| Copyright 2013
+| Free Software Foundation, Inc.
+| Written by Holger Hans Peter Freyther.
+|
+| This file is part of the GNU Smalltalk class library.
+|
+| The GNU Smalltalk class library is free software; you can redistribute it
+| and/or modify it under the terms of the GNU Lesser General Public License
+| as published by the Free Software Foundation; either version 2.1, or (at
+| your option) any later version.
+|
+| The GNU Smalltalk class library is distributed in the hope that it will be
+| useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser
+| General Public License for more details.
+|
+| You should have received a copy of the GNU Lesser General Public License
+| along with the GNU Smalltalk class library; see the file COPYING.LIB.
+| If not, write to the Free Software Foundation, 59 Temple Place - Suite
+| 330, Boston, MA 02110-1301, USA.
+|
+ ======================================================================"
+
+Namespace current: Kernel [
+
+ExternalPackage subclass: DirPackage [
+    <category: 'Language-Packaging'>
+    <comment: 'I can parse a package.xml from a directort and treat it
+    like a package. This allows loading packages from a directory without
+    the need of zipping them first.'>
+
+    DirPackage class >> file: aFile [
+        ^ self new
+            file: aFile;
+            yourself
+    ]
+
+    directory [
+        ^ self file asFile directory.
+    ]
+
+    name [
+        "Pick the name of the loaded package"
+        ^ self loadedPackage name.
+    ]
+
+    loadedPackage [
+        <category: 'accessing'>
+        | file package |
+        loadedPackage isNil ifFalse: [^loadedPackage].
+        file := self file asFile.
+        package := Package parse: file readStream.
+        package isNil
+            ifTrue: [^self error: 'invalid disabled-package tag inside a star file'].
+        package relativeDirectory: file directory.
+        package baseDirectories: {file directory}.
+        package name isNil
+            ifTrue: [^self error: 'package name must not be nil'].
+        loadedPackage := package.
+        ^loadedPackage
+    ]
+]
+
+PackageContainer subclass: DirPackageContainer [
+
+    <category: 'Language-Packaging'>
+    <comment: 'I hold a list of parsed packages.'>
+
+    DirPackageContainer class >> on: aPackage [
+        <category: 'creation'>
+        ^ self new
+            add: aPackage;
+            yourself
+    ]
+
+    add: aPackage [
+        <category: 'addition'>
+
+        self packages
+                at: aPackage name, '.dir' put: aPackage.
+    ]
+
+    refresh: aDate [
+        "no op.. packages contain what we need"
+    ]
+]
+
+]
+
+PackageLoader class extend [
+
+    dirPackages [
+        | container |
+
+        <category: '*Language-Kernel'>
+
+        "Check if there is already a container"
+        root do: [:each |
+            each class = Kernel.DirPackageContainer
+                ifTrue: [^each].
+        ].
+
+        container := Kernel.DirPackageContainer new.
+        root add: container.
+        ^ container.
+    ]
+
+    loadPackageFromFile: aFileName [
+        | package |
+        <category: '*Language-Kernel'>
+
+        "Make sure that root is initialized."
+        self refresh.
+
+        "Add the 'directory' to the packages"
+        package := Kernel.DirPackage file: aFileName.
+
+        self dirPackages add: package.
+
+        "And now file it in"
+        package primFileIn.
+    ]
+]
diff --git a/kernel/PkgLoader.st b/kernel/PkgLoader.st
index b9748f2..53d9367 100644
--- a/kernel/PkgLoader.st
+++ b/kernel/PkgLoader.st
@@ -917,20 +917,12 @@ XML.'>
 
 Namespace current: Kernel [
 
-PackageInfo subclass: StarPackage [
+PackageInfo subclass: ExternalPackage [
     | file loadedPackage |
     
     <category: 'Language-Packaging'>
     <comment: nil>
 
-    StarPackage class >> file: file [
- <category: 'accessing'>
- ^(self new)
-    file: file;
-    name: (File stripPathFrom: (File stripExtensionFrom: file name));
-    yourself
-    ]
-
     fullPathOf: fileName [
  "Try appending 'self directory' and fileName to each of the directory
  in baseDirectories, and return the path to the first tried filename that
@@ -1079,6 +1071,24 @@ PackageInfo subclass: StarPackage [
     ]
 
     loadedPackage [
+        ^ self subclassResponsibility
+    ]
+]
+
+ExternalPackage subclass: StarPackage [
+
+    <category: 'Language-Packaging'>
+    <comment: 'I represent an external package in the form of a .star package'>
+
+    StarPackage class >> file: file [
+ <category: 'accessing'>
+ ^(self new)
+    file: file;
+    name: (File stripPathFrom: (File stripExtensionFrom: file name));
+    yourself
+    ]
+
+    loadedPackage [
  <category: 'accessing'>
  | package |
  loadedPackage isNil ifFalse: [^loadedPackage].
diff --git a/libgst/files.c b/libgst/files.c
index ec33933..a7156f9 100644
--- a/libgst/files.c
+++ b/libgst/files.c
@@ -288,6 +288,7 @@ static const char standard_files[] = {
   "StreamOps.st\0"
   "Regex.st\0"
   "PkgLoader.st\0"
+  "DirPackage.st\0"
   "Autoload.st\0"
 };
 
--
1.7.10.4


_______________________________________________
help-smalltalk mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] kernel: Introduce the DirPackage packages to help with development

Holger Freyther
On Sun, Mar 24, 2013 at 07:56:15PM +0100, Holger Hans Peter Freyther wrote:

> Add a way to load a Package from the package.xml and not go through
> the creation of a star file. This can make developing with packages
> more effective.

the code needs to change the package.xml top-level and somehow the filein
does not load dependencies. I will have to look at why that is the case.

_______________________________________________
help-smalltalk mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-smalltalk