Page 1 of 1

[HOWTO] improper way to compile/create module

Posted: 12 Nov 2011, 18:23
by lachman
WARNING: This violates all sorts of conventions that people have made great efforts to maintain. Modules created this way should not be shared ever. Idea of this post is personal convenience and quick OS production/consumption. Any suggestions to make this more 'proper' are welcome. If I saw this post I would delete it. end disclaimer.

Say you download source tar for X:

Decompress source:

Code: Select all

tar xzvf X.gz
Move into the source directory

Code: Select all

cd X
Configure before compiling. May need to customize.

Code: Select all

./configure --prefix=/usr/
Compile

Code: Select all

make
Take a snapshot of the file system

Code: Select all

find /mnt/live/memory/changes -type f > /tmp/oldchanges
Install the package

Code: Select all

make install
Take a post install snapshot of the filesystem

Code: Select all

find /mnt/live/memory/changes -type f > /tmp/newchanges
Move out the source directory

Code: Select all

cd ../
Identify differences made after installation

Code: Select all

diff /tmp/oldchanges /tmp/newchanges > files
Remove the prefix so path is relative to '/'

Code: Select all

cat files | grep -v "tmp/newchanges" | grep ">" | sed 's_> /mnt/live/memory/changes__' > newfiles
Create the module

Code: Select all

cat newfiles| xargs tar cf temp.tar
mkdir temp
tar xf temp.tar -C temp
dir2xzm temp X.xzm
The idea is to make a script to set up all modules needed for a customized OS. Imagine one script with 10 concatenated instances of the script below:

tar xzvf X.gz
cd X
./configure --prefix=/usr/
make
find /mnt/live/memory/changes -type f > /tmp/oldchanges
make install
find /mnt/live/memory/changes -type f > /tmp/newchanges
cd ../
diff /tmp/oldchanges /tmp/newchanges > files
cat files | grep -v "tmp/newchanges" | grep ">" | sed 's_> /mnt/live/memory/changes__' > newfiles
rm temp.tar
cat newfiles| xargs tar cf temp.tar
rm -rf temp
mkdir temp
tar xf temp.tar -C temp
dir2xzm temp X.xzm

Re: [HOWTO] improper way to compile/create module

Posted: 12 Nov 2011, 18:35
by Hamza
Welcome on board!

That is very appreciated to write an HOWTO for users.

Please take a moment and rewrite an correct HOWTO.

An example of "correct" howto :
  1. Decompress the archive using this command - where X is the real name of the archive

    Code: Select all

    tar xzvf X.gz
  2. Go to the directory where the archive was uncompressed - where X is the real path of the directory

    Code: Select all

    cd X
  3. Prepare the system and checks the dependencies

    Code: Select all

    ./configure --prefix=/usr/
  4. Launch the compilation using make command

    Code: Select all

    make
  5. Execute this command to make a list of changes between the old version and new version.

    Code: Select all

    find /mnt/live/memory/changes -type f > /tmp/oldchanges
  6. Execute this command to install the result of the compilation to the current system.

    Code: Select all

    make install
You could use this example to write an HOWTO if you do not like to write a long text. :)

Regards

Re: [HOWTO] improper way to compile/create module

Posted: 12 Nov 2011, 18:51
by lachman
Making me work Hamza! improper==poor==lazy :-)

maybe upload script: X == $1. K. I'll edit see how it goes....

Re: [HOWTO] improper way to compile/create module

Posted: 12 Nov 2011, 19:12
by Hamza
If you want to post an how to like this one.
Please move your topic in Development section

Regards

Re: [HOWTO] improper way to compile/create module

Posted: 12 Nov 2011, 19:19
by lachman
done. is there a way to delete this post? Dont' see it. Anywho, I just found the above script helpful. Nice to make one big script that creates all xzms. cheers

Re: [HOWTO] improper way to compile/create module

Posted: 12 Nov 2011, 19:24
by Hamza
Thank you.
You should have an X at top of your first message.
Push on it and confirm that you want to remove the topic.

Re: [HOWTO] improper way to compile/create module

Posted: 12 Nov 2011, 19:31
by lachman
i got no 'X'... Am i missing something.. trying to post a screenshot

Re: [HOWTO] improper way to compile/create module

Posted: 12 Nov 2011, 19:33
by Hamza
True. :roll:
I will send a PM to Admins about this problem.

Re: [HOWTO] improper way to compile/create module

Posted: 12 Nov 2011, 19:38
by lachman
Thanks Hamza. Not trying to dirty up the place. My room is already a mess. No need for the forum to be :-)

Re: [HOWTO] improper way to compile/create module

Posted: 12 Nov 2011, 20:43
by wread
Porteus has a built in script named /opt/porteus/changes-time.sh that does that. You have to invoke it after make install and it will put the changes in a folder in /root. Rename it as required, inspect it and right click it to convert it to a porteus module. This wheel is already invented by fanthom.

However, and I don't know why, but if you compile a source pre-worked for cmake, this method by fanthom sometimes fails; you have to complete it by hand copying some files, according to my experience. Maybe your method is better for that case.

You should go ahead with it. In the community there are many CLI-experts that could help you. It is a good exercise!

Regards

Re: [HOWTO] improper way to compile/create module

Posted: 12 Nov 2011, 21:42
by fanthom
@lachman
we have a FAQ Q/A which covers this matter:
http://porteus.org/faq.html#29

i like your method of separating files but it's not perfect - it wont work in case of upgrading package when user is saving changes.
for exapmle when you compile never version of mplayer (and previous one is already in /mnt/live/memory/changes) majority of files will be the same thus not catched up by diff utility.

'changes-time.sh' script is better (but not best) cause it searches /mnt/live/memory/changes folder for files/dirs modified in last 1,2,3,n minutes.
'changes-time.sh' has one weakness - it wont work for precompiled binaries like Virtualbox when libs included in .run file were compiled some time ago (day, week, month).
Anyway - 'changes-time.sh' should work for all aps compiled directly from sources.

btw: i have deleted same topic from 'Development' as this 'HOWTO' fits better here.

Re: [HOWTO] improper way to compile/create module

Posted: 14 Nov 2011, 21:22
by brokenman
I might just add that usually the DESTDIR variable is available when compiling from source. This negates the need to run around looking for changes.

Code: Select all

grep DESTDIR Makefile
If it exists you can simply create a folder and install directly there before stripping for porteus,

Code: Select all

make DESTDIR=/tmp/myfolder install
You can open /opt/porteus-scripts/txz2xzm to see how to strip a package of unwanted files.

Re: [HOWTO] improper way to compile/create module

Posted: 14 Nov 2011, 21:50
by lachman
@fanthom
I did not know changes-time.sh existed. I found an instance where my build scripts don't work, some files were missing, and changes-time caught them.

It doesn't make sense to build packages one at a time while sleeping for the clock, so does it make sense to have a script that sets everything in /mnt/live/memory/changes to 1970 and use changes-time.sh. Ie:

./configure
make
/opt/changes-zero-clock.sh
make install
/opt/changes-time.sh (couple years)
build xzm

@brokenman
Thanks. I will try the DESTDIR.

Re: [HOWTO] improper way to compile/create module

Posted: 03 Jan 2012, 11:29
by Sniker
root@porteus:~/Documents/aMule-2.2.6# ./configure --prefix=/usr/

checking for a BSD-compatible install... /usr/bin/ginstall -c
checking whether build environment is sane... yes
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether to enable maintainer-specific portions of Makefiles... no
checking build system type... i686-pc-linux-gnu
checking host system type... i686-pc-linux-gnu
checking if this is a FreeBSD 4 or earlier system... no
checking for g++... g++
checking for C++ compiler default output file name... a.out
checking whether the C++ compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking for style of include used by make... GNU
checking dependency style of g++... gcc3
checking how to run the C++ preprocessor... /lib/cpp
configure: error: C++ preprocessor "/lib/cpp" fails sanity check
See `config.log' for more details.

LOOK UP.... I HAVE THIS ERROR...

Re: [HOWTO] improper way to compile/create module

Posted: 03 Jan 2012, 20:25
by fanthom
@Sniker
What's your Porteus version and arch? where can i get source code for aMule (i would like to recreate error on my side)?
did you try to compile it in 'Always Fresh' mode with /base modules only?
finally - did you have development module activated when running configure?

please answer all of the questions above.