Tiny Core Linux

Off-Topic => Archive / Obsolete => SCM EXtensions => Topic started by: vinnie on April 07, 2012, 08:13:36 AM

Title: SCM buildin how-to
Post by: vinnie on April 07, 2012, 08:13:36 AM
Today I started trying to understand how work these scm, I'm downloading ffmpeg package (very big for my line) as mentioned in this topic  (http://forum.tinycorelinux.net/index.php/topic,12612.msg70908.html#msg70908)
I think it's important that other people try to create this type of package or it would risk a low diffusion.
I translated to my language (italian) first post of SCM basis (http://forum.tinycorelinux.net/index.php/topic,12457.msg67393.html#msg67393) to figure out what to do.
I found an application that works securely and has few dependencies for testing: http://nut.sourceforge.net/

However I did not understand the part of code in the first post of SCM Basics, I ask if you can create a mini howto step by step for create a .scm package
Title: Re: SCM buildin how-to
Post by: vinnie on April 07, 2012, 11:34:44 AM
Ok, I'm investigating the discourse of environment variables; I just finished building ffmpeg (it took several hours), but where is the scm?

Code: [Select]
...
INSTALL libavutil/pixfmt.h
INSTALL libavutil/random_seed.h
INSTALL libavutil/rational.h
INSTALL libavutil/samplefmt.h
INSTALL libavutil/sha.h
INSTALL libavutil/sha1.h
INSTALL libavutil/avconfig.h
INSTALL libavutil/libavutil.pc
tc@box:~/ffmpegscm/ffmpeg-shared/ffmpeg-shared$
Title: Re: SCM buildin how-to
Post by: vinnie on April 07, 2012, 03:11:09 PM
Ok, i change target of my test (nut does not have .configure file, this is a problem for --prefix)

I try with circuslinux and write this script:

Code: [Select]
build_circuslinux() {
HERE=`pwd`
NAME=circuslinu
VER=1.0.3
BUILDDEPS="compiletc.tcz SDL-dev.tcz"
#DEPS="libmikmod.tcz SDL.tcz"


PKGPATH=$1
export LDFLAGS="-L$PKGPATH/lib"
export CPPFLAGS="-I$PKGPATH/include"
export PATH="$PKGPATH/bin:$PATH"
export PKG_CONFIG_PATH="$PKGPATH/lib/pkgconfig:$PKG_CONFIG_PATH"


tar xvzf circuslinux-1.0.3.tar.gz || exit 1
cd circuslinux-1.0.3 || exit 1
./configure  --prefix="$PKGPATH" || exit 1
make || exit 1
make install || exit 1

cd "$HERE"

}

Code: [Select]
tc@box:~/circus$ ./buildscm circus.inc /apps/circux
./buildscm: line 46: build_circus.inc: command not found

for now this is naturally wrong, but I hope you'll give me a hand to correct and understand some things.

Here are some of the first questions that come to mind:
1)This SCM pack is the software, plus all its dependencies installed in /apps/packagename ?
1.2)so I must try to have only "BUILDEPS" and not "DEPS" ?

2)in the series of "export" I need to enter the directory where the libraries will be installed and searched?
2.1)how should I choose them whereas circuslinux need the sdl and libmikmod?

Title: Re: SCM buildin how-to
Post by: Jason W on April 07, 2012, 04:28:33 PM
Scm's don't need tcz deps, just build deps, as the rule now is for scm's not to depend on tcz's.  So libmikmod and sdl will need to be built into the circuslinux scm package.  All needed libraries not found in base need to be in the scm if at all possible, except for gtk2 or other library collections.

Also, when ffmpeg finishes building, you make the scm this way, thougn it can also be scripted.

cd /apps
mksquashfs ffmpeg-shared/ ffmpeg-shared.scm

You would first want to perhaps clean out unwanted files though, depending on the purpose of the package.

Also if you are using the command "buildscm circus-sc.inc /apps/circus" , then the function in the circus-sc.inc file needs to be build_circus.  Also, the file needs to be named with the -sc.inc suffix to work with the buildscm script.


Title: Re: SCM buildin how-to
Post by: Jason W on April 07, 2012, 06:43:52 PM
Ok, I made some source files for circuslinux, located below, be sure to download all the files.  I will let you make the package, this can just be a guide.

http://distro.ibiblio.org/tinycorelinux/4.x/x86/scm/src/circuslinux/

Use the command:

buildscm circuslinux-sc.inc /apps/circuslinux

and it should just work.  Study each source file to see what is going on.  Also, a wrapper is usually needed to make the resulting binaries work.  For this one do ths:

mv /apps/circuslinux/bin /apps/circuslinux/localbin
mkdir /apps/circuslinux/bin

Then create this file to be your /apps/circuslinux/bin/circuslinux file:

Code: [Select]
#!/bin/sh

export LD_LIBRARY_PATH=/apps/circuslinux/lib
export PATH=/apps/circuslinux/localbin:$PATH

/apps/circuslinux/localbin/circuslinux "$@"

Then make that file executable.  The icon and menu stuff can be easily done using existing examples. 

Oh, and FWIW, circuslinux is able to be converted directly from tcz's with the same result.
Title: Re: SCM buildin how-to
Post by: Jason W on April 08, 2012, 07:33:22 AM
I uploaded a fix in the libmad-sc.inc that was causing a build failure, should be good now.

Title: Re: SCM buildin how-to
Post by: vinnie on April 08, 2012, 09:07:25 AM
Much material to elaborate, I lower my head and I start work :)
Title: Re: SCM buildin how-to
Post by: Jason W on April 08, 2012, 04:13:19 PM
Here is a script to run for fun, creates a portable self contained circuslinux out of existing tcz's.  This approach seems to work well with some extensions, vlc is one, but not with others.  Run in a directory that does not already contain tcz files.


Code: [Select]
#!/bin/sh

tce-fetch.sh circuslinux.tcz.tree

for I in `cat circuslinux.tcz.tree`; do
[ -f "$I" ] || tce-fetch.sh "$I"
done



mkdir pkgbase
for I in `ls *.tcz`; do
unsquashfs -d pkg "$I"
cp -a pkg/* pkgbase/
sudo rm -r "$I"
sudo rm -r pkg
done

cd pkgbase
mv usr/local .
rmdir usr

find . -type f -exec sed -i -e "s|/usr|././|g" {} \;

export LD_LIBRARY_PATH=local/lib
./local/bin/circuslinux


Title: Re: SCM buildin how-to
Post by: jls on April 08, 2012, 05:25:51 PM
I don't understand the line starting with "find"
Title: Re: SCM buildin how-to
Post by: Jason W on April 08, 2012, 05:38:44 PM
That is what makes the contents of the extension portable, that is to be ported from /usr/local to /apps.  It removes hard coded paths and replaces them with relative paths, a tip from portablelinuxapps.org.
Title: Re: SCM buildin how-to
Post by: vinnie on April 09, 2012, 09:37:22 PM
ok, I tried to run buildscm for your script (sh buildscm ./circuslinux-sc.inc /apps/circuslin
ux), I did the wrapping operation, but circusilinux does not work:

Code: [Select]
tc@box:/apps/circuslinux/bin$ ./circuslinux

Warning: I could not open the options file for read:
/home/tc/.circuslinux
The error that occured was:
No such file or directory


Error: I could not load the music file:
/apps/circuslinux/share/circuslinux/data/music/finally.mod
The Simple DirectMedia error that occured was:
Unrecognized music format

tc@box:/apps/circuslinux/bin$

However, as a matter of mere teaching I tried a package even easier (with no dependencies) to create a working script, and this time I succeeded:
http://sprunge.us/KfCR?bash (sorry for italian comment)
Practically I'll have to do the same work for each dependency and then include it with ". . /dep-sc.inc" in master file,

what would the next steps?
1)wrapping (in this case  is usefull)
2)create icons and desktop file in /apps/packname/share/pixmaps and applications (automatically linked from scm-load when pack mounted)
3)purge /apps/packname from undesired file
4)put eventually start script (install) and variables/flag file (spec) in /apps/packname/config
5)make pack with mksquashfs ./packname packname.scm
it is all?


Two more question
1) it possible to create a database containing a list of all "-sc.inc" so that we can reuse them when needed to build new scm?
2) i see your tcz converting script, this makes me think that the settings given during the compilation does not make incompatible the two types of packets with each other.
it is possible in some way merge the two builds in one?

This remind me the old .tce (but I can not figure out if there are real similaritudes)

P.s. thanks Jason
Title: Re: SCM buildin how-to
Post by: Jason W on April 10, 2012, 02:38:29 AM
It appears that a dependency of circuslinux was not successfully built, which should have resulted in the build stopping.  I will try downloading the files and building again.

Converting tcz's works for some apps, not for all, and some other things have to be done on a case by case basis.

Basically those steps you describe is how it works.

A database of -sc.inc files is possible, but some apps need a particular version of something and also perhaps built a certain way, so those cases would need to run their own particular build files.
Title: Re: SCM buildin how-to
Post by: vinnie on April 10, 2012, 06:57:17 AM
Quote
Converting tcz's works for some apps, not for all, and some other things have to be done on a case by case basis.
only asked to streamline in some way the creation of the two types of packets, basically i am lazy  :)

Quote
A database of -sc.inc files is possible, but some apps need a particular version of something and also perhaps built a certain way, so those cases would need to run their own particular build files.
We could distinguish the different versions by name.
But effectively, now you make me think, your script is just a method for making the scm, but someone might like to use other.

If I can, I will try to make a package scm seriously this day.
Title: Re: SCM buildin how-to
Post by: vinnie on April 12, 2012, 07:26:52 PM
It took me a while because I did not know which program to choose, I ended up with a program called gargoyles, interactive fiction interpreter.
After various adventures I managed to compile it, but now I'm a bit undecided how to proceed.

in addition to ftjam that I will have to create it myself (but just the TCZ, this is tool for compilation), I need this tcz to compile normally gargoyle:

tce-load -i compiletc SDL-dev SDL sdl-sound-dev sdl-sound libvorbis-dev libvorbis smpeg gtk2-dev

However things that should be included in /apps/packname are only the start dependencies, so how do I proceed?
Install all tcz build dep for gargoyle start dep and compile this in scm style?
And for gtk2 use export before compiling start dep.
These exports are used to tell the program where to find libraries after being compiled?


P.s. stealing the PKGBUILD from aur, startup dependencies "should" be these:
gtk2 sdl_mixer sdl_sound libvorbis freetype2
Title: Re: SCM buildin how-to
Post by: Jason W on April 12, 2012, 07:33:28 PM
Gtk2 apps will need to be built against this tarball package:

http://distro.ibiblio.org/tinycorelinux/4.x/x86/scm/gtk2-dev.tar.xz

Just uninstall gtk2.scm and untar that xz in /apps.

Compiletc.tcz and perhaps it's related development tcz's should be your only tcz's you depend on.  SDL, gtk2, smpeg, they should be installed in the scm, or be depended on in the case of gtk2.scm.

There are -sc.inc files for sdl and libvorbis in the source area.

Title: Re: SCM buildin how-to
Post by: vinnie on April 14, 2012, 04:41:24 AM
The source of your sc.inc-are simply recompressed in the xz format or you've made ​​some changes?

P.s. You apply changes only as patches? (then I should become aware by reading -sc.inc)
Title: Re: SCM buildin how-to
Post by: Jason W on April 14, 2012, 05:23:25 AM
I try to recompress using xz to save space on the server.

Patches that are used are patches that other distros use, mainly Arch, and I use them if I feel they are applicable to what the app needs for us.  Some patches are for things like fixing man pages, so I don't use those, but others are needed for the app to build, like a fix to use with our version of gcc.
Title: Re: SCM buildin how-to
Post by: vinnie on April 14, 2012, 01:52:07 PM
hey jason, I am close but I have several problems; meanwhile, I attaching my script (I used your libvorbis with libogg & sdl_mixer with sdl and libmikmod).

I used two patches with gargoyles, the first removes the dependence smpeg, this is because I can not compile it (you can try looking smpeg-sc.inc)
Code: [Select]
Index: Jamrules
===================================================================
--- Jamrules (revision 590)
+++ Jamrules (working copy)
@@ -111,7 +111,7 @@
         if $(USESDL) = yes
         {
             GARGLKCCFLAGS += -I/usr/include/SDL ;
-            GARGLKLIBS += -lSDL_mixer -lSDL_sound -lSDL -lsmpeg -lvorbisfile ;
+            GARGLKLIBS += -lSDL_mixer -lSDL_sound -lSDL -lvorbisfile ;
         }
 
         if $(STATIC) { LINKLIBS += $(GARGLKLIBS) ; }

And the second patch serves to replace the prefix (this forces the use of a specified directory: ./buildscm gargoyle-sc.inc /apps/gargoyle):
Code: [Select]
Index: Jamfile
===================================================================
--- Jamfile (revision 590)
+++ Jamfile (working copy)
@@ -13,9 +13,9 @@
 # If SYSTEM is set, use values for a system wide install
 if $(SYSTEM)
 {
-    BINDIR = /usr/local/libexec/gargoyle ;
-    APPDIR = /usr/local/libexec/gargoyle ;
-    LIBDIR = /usr/local/lib/gargoyle ;
+    BINDIR = /apps/gargoyle/bin ;
+    APPDIR = /apps/gargoyle/bin ;
+    LIBDIR = /apps/gargoyle/lib ;
     DESTDIR = / ;
     EXEMODE = 755 ;
     FILEMODE = 755 ;


By compiling in the normal way it's all right (although the dependence smpg.tcz does his job), but when I use the method "scm" with the script (and thinks with relative export), compilation should not be.
Good normal compilation (http://sprunge.us/BJHH)
Bad scm compilation (http://sprunge.us/cIZP)


After a diff I think I've located the problem: gargoyle can not find the library LIBJPEG_6.2 of gtk, for example (just in the end of bad file):
Code: [Select]
build/linux.release/garglk/libgarglk.so: undefined reference to `jpeg_std_error@LIBJPEG_6.2'
build/linux.release/garglk/libgarglk.so: undefined reference to `jpeg_finish_decompress@LIBJPEG_6.2'
build/linux.release/garglk/libgarglk.so: undefined reference to `jpeg_stdio_src@LIBJPEG_6.2'
build/linux.release/garglk/libgarglk.so: undefined reference to `jpeg_read_scanlines@LIBJPEG_6.2'
build/linux.release/garglk/libgarglk.so: undefined reference to `jpeg_CreateDecompress@LIBJPEG_6.2'
build/linux.release/garglk/libgarglk.so: undefined reference to `jpeg_start_decompress@LIBJPEG_6.2'
build/linux.release/garglk/libgarglk.so: undefined reference to `jpeg_destroy_decompress@LIBJPEG_6.2'
build/linux.release/garglk/libgarglk.so: undefined reference to `jpeg_read_header@LIBJPEG_6.2'
collect2: ld returned 1 exit status

I assure you that I downloaded gtk2-dev.tar.xz and extracted in /apps/ .

In PKBUILD of aur they using another technique to move gargoyle's file instead of the using patch (and then edit the jamfile):
Code: [Select]
jam ||return 1
jam install || return 1
...
install $srcdir/build/dist/* $pkgdir/usr/share/gargoyle/
ln -s /usr/share/gargoyle/gargoyle $pkgdir/usr/bin/gargoyle
install $srcdir/build/dist/libgarglk.so $pkgdir/usr/lib/

if I did not use the export in gargoyle-sc.inc and then move the files by hand as in PKBUILD, the wrapper would suffice to solve the situation?

Title: Re: SCM buildin how-to
Post by: Jason W on April 14, 2012, 02:29:40 PM
Thanks, I will give it a try tonight.
Title: Re: SCM buildin how-to
Post by: vinnie on April 14, 2012, 04:26:47 PM
some good news, gargoyle.scm works (almost).

in gargoyle-sc.inc I commented all the lines of export and then build.
After building (gone well) i make wrapping and I used this script to replace gargoyle:
Code: [Select]
#!/bin/sh

export LD_LIBRARY_PATH=/apps/gargoyle/lib:/apps/gtk2/lib
export PATH=/apps/gargoyle/localbin:/apps/gtk2/bin:$PATH

/apps/gargoyle/localbin/gargoyle "$@"


After i try to install (in a core enviorment with only Xvesa, fltk and fluxbox) it work but only after I have installed libiconv and smpeg (I installed smpeg excluding its dep file, to make sure it was using the gtk2.scm library).
I do not know why it asks me smpeg again (I do not remember having commented the string of the patch that disables it), but I would ask you a hand to build this library (I also tried fo find the build-dep in the 3.x repository, but it is not there).

for libiconv I immediately start to work

Thanks to you, this is very instructive for me

P.s. ok libiconv seems to work, smpeg is the only malevolent creation  :P

P.p.s i forget, if you try, the dependency ftjam.tcz of gargoyle is in email of tcsubmit!
Title: Re: SCM buildin how-to
Post by: Jason W on April 14, 2012, 06:34:57 PM
Ok, I am attempting to build it now.  I will see what I can find.


Title: Re: SCM buildin how-to
Post by: Jason W on April 14, 2012, 08:23:19 PM
The jam command extension is not found, time is tight tonight so I can't go further.
Title: Re: SCM buildin how-to
Post by: vinnie on April 14, 2012, 08:26:05 PM
The jam command extension is not found, time is tight tonight so I can't go further.
Yep, i send ftjam to tcsubmit mail!


For now I'm Fried, I did other build tests in my other poor of dependencies environment version.
This time does not seem to work, I think the last time it took the majority of building dependencies by the system (I commented the lines of exports in gargoyle-sc.inc), and at the end with the wrapping the package scm worked.

The only things I have noticed more in this round are that sdl-sc.inc need to have SDL installed in the system otherwise it will not compile:
Code: [Select]
...
checking for SDL - version >= 1.2.0... no
*** Could not run SDL test program, checking why...
*** The test program compiled, but did not run. This usually means
*** that the run-time linker is not finding SDL or finding the wrong
*** version of SDL. If it is not finding SDL, you'll need to set your
*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point
*** to the installed location  Also, make sure you have run ldconfig if that
*** is required on your system
***
*** If you have an old version installed, it is best to remove it, although
*** you may also be able to get things to work by modifying LD_LIBRARY_PATH
configure: error: *** SDL version 1.2.0 not found!
tc@box:~/Garg$

and also smpeg is required by gargoyle in any case, patch or no patch

Thank jason, now i go to bed, and I hope to recover my strength for the next round!
Title: Re: SCM buildin how-to
Post by: Jason W on April 14, 2012, 09:03:55 PM
Ok, I will try again when ftjam is uploaded.

Title: Re: SCM buildin how-to
Post by: Jason W on April 18, 2012, 03:49:15 PM
Sorry for the delay, I have not had any opportunity to revisit this, I will  give it a shot when I can.
Title: Re: SCM buildin how-to
Post by: vinnie on April 19, 2012, 03:53:51 AM
do not worry, this week I have not much time to dedicate it, probably in the next I'll be more free.
However, I have the feeling that it is enough to figure out how to compile smpeg.
Title: Re: SCM buildin how-to
Post by: Jason W on April 19, 2012, 10:08:07 AM
smpeg needs libgl, at least the stable version does.  I was not able to look further last night, but maybe I can build it tonight, Arch Linux has libgl as an optional dep.
Title: Re: SCM buildin how-to
Post by: solorin on April 29, 2012, 08:47:52 AM
Will there be a concise guide for building and submitting scm's as there is for tcz's written up on the wiki?

Interested in buildng and submitting some audio scm's.

cheerio,
solorin
Title: Re: SCM buildin how-to
Post by: Jason W on May 05, 2012, 05:28:23 AM
I am sure there will be in time, and it would be good for someone who has the interest and opportunity to piece together the snippets found here in the threads and make a general guide.  I will try to make a post containing all the details so far and sticky it so it does not get buried.