Welcome to Linux Forums!

With a comprehensive Linux Forum, information on various types of Linux software and many Linux Reviews articles, we have all the knowledge you need a click away, or accessible via our knowledgeable members.

Linux Forum ArticlesLinux ForumsLinux Forum DownloadsLinux Hosts
Home|Register|FAQ|Member List|Calendar|Unanswered Posts|Forum Rules|Today's Posts|Advanced Search|
SEARCH FOR IN
Go Back   Linux Forums > GNU Linux Zone > Linux Programming & Scripting
Reload this Page This is for the second time of asking...
Linux Forums
Linux Forums
Welcome To The Linux Forums!
Welcome to Linux Forums. We pride ourselves in being one of the largest Linux communities on the web, we encourage you to REGISTER on our forums and participate in the community. There are over 150,000 members ready to answer your questions. JOINING US today will allow you to make new posts, get support, send messages to other members and submit downloads to our downloads directory and many other great features!

Linux Programming & Scripting C, Perl, PHP, Bash Scripts, anything programming or script related post in here!

Reply
 
Thread Tools Display Modes
Old 05-09-2008   #1 (permalink)
hazel
Linux Newbie
 
hazel's Avatar
 
Join Date: May 2004
Location: Harrow, UK
Posts: 236
This is for the second time of asking...

I've written a little program which I find quite useful. It puts up a buttonbar on my fluxbox desktop so that I can launch my favourite apps with one click. I like to use different workspaces for different purposes and by using different config files, I can have a customised buttonbar on each one. I would like to package this up and maybe share it with others but I need someone to hold my hand through the process. I have pored over man pages and HOWTOs for autoconf and automake but frankly it's all a bit beyond me.
__________________
"I'm just a little old lady; don't try to dazzle me with jargon!"
hazel is offline   Reply With Quote
Old 05-09-2008   #2 (permalink)
totycro
Just Joined!
 
Join Date: May 2008
Posts: 7
I once wrote a program, where i let kdevelop handle the configure-script and all that stuff, which worked great..
totycro is offline   Reply With Quote
Old 05-10-2008   #3 (permalink)
hazel
Linux Newbie
 
hazel's Avatar
 
Join Date: May 2004
Location: Harrow, UK
Posts: 236
Quote:
Originally Posted by totycro View Post
I once wrote a program, where i let kdevelop handle the configure-script and all that stuff, which worked great..
I don't have kde installed. Is there a gnome equivalent? And if there is, will it work for a program that wasn't developed under it?
__________________
"I'm just a little old lady; don't try to dazzle me with jargon!"
hazel is offline   Reply With Quote
Old 05-12-2008   #4 (permalink)
SagaciousKJB
Just Joined!
 
SagaciousKJB's Avatar
 
Join Date: Aug 2007
Location: Yakima, WA
Posts: 99
Send a message via AIM to SagaciousKJB Send a message via MSN to SagaciousKJB
Wait, there's programs available to do this? I learned how to write my own custom config scripts and make files. I wish I would have known there were programs to try.

I suppose I could probably help you out with that aspect of it if you need, but the program I was packaging was extremely simple so it was pretty easy for me to do.

I often wondered about this process myself before going ahead and just packaging everything manually. At that point I assumed that's how everyone did it.
SagaciousKJB is offline   Reply With Quote
Old 05-13-2008   #5 (permalink)
hazel
Linux Newbie
 
hazel's Avatar
 
Join Date: May 2004
Location: Harrow, UK
Posts: 236
Quote:
Originally Posted by SagaciousKJB View Post
I suppose I could probably help you out with that aspect of it if you need, but the program I was packaging was extremely simple so it was pretty easy for me to do.
I might just take you up on that offer. "Cinderella" is also pretty simple: 2 small code files and a header file. The only libraries it uses are glib/gdk/gtk and of course glibc. At present I have a simple makefile which I wrote myself and which works on my system but I don't know if it would more generally. For example I don't know if the libraries are always in the same place in different distros - my makefile uses pkg-config to find them. This is supposed to be the kind of thing that autoconf looks after in a proper package but I can't see what information I need to give it.

I've had a lot of help from the community over the years. I just want to be able to give something back.
__________________
"I'm just a little old lady; don't try to dazzle me with jargon!"
hazel is offline   Reply With Quote
Old 05-13-2008   #6 (permalink)
smolloy
Linux Guru
 
smolloy's Avatar
 
Join Date: Apr 2005
Location: San Francisco, CA, but from Belfast, N.Ireland.
Posts: 1,782
I'm afraid I can't help, but I wanted to say that it's great to see someone deliberately trying to "give back" by packaging up a program they wrote. I really hope someone can help you with this. What you're trying to do really is one of the reasons I love linux.

I wonder if SourceForge has any tutorials or guidance for doing this?
__________________
Registered Linux user #388328 || Registered LFS user #15880
AMD 64 X2 4600+ :: 2X1GB DDR2 800 :: GeForce 7300 GT 512MB :: ASUS M2N32 Deluxe :: 4X250GB SATAII
smolloy is offline   Reply With Quote
Old 05-13-2008   #7 (permalink)
SagaciousKJB
Just Joined!
 
SagaciousKJB's Avatar
 
Join Date: Aug 2007
Location: Yakima, WA
Posts: 99
Send a message via AIM to SagaciousKJB Send a message via MSN to SagaciousKJB
Quote:
Originally Posted by hazel View Post
I might just take you up on that offer. "Cinderella" is also pretty simple: 2 small code files and a header file. The only libraries it uses are glib/gdk/gtk and of course glibc. At present I have a simple makefile which I wrote myself and which works on my system but I don't know if it would more generally. For example I don't know if the libraries are always in the same place in different distros - my makefile uses pkg-config to find them. This is supposed to be the kind of thing that autoconf looks after in a proper package but I can't see what information I need to give it.

I've had a lot of help from the community over the years. I just want to be able to give something back.
Well, I couldn't find a terrible amount of tips on how to write a makefile, so I left most of the work up to a config script written in bash.

Code:
#!/bin/bash

findlib()
{
whereis $1 | sed "s/$1: //g" | sed "s/ /\n/g" | while read file; do if [ -f "$file" ]; then ls "$file"; else return 1; fi; done
}
#whereis returns locations of file searched for.  sed parses this result so that the while read loop can parse it, test if the file is okay, and then list the location of said file.  If [ -f "$file" ] fails for some reason,  it then returns 1 for exit code

echo -e "Checking dependencies...\n"
echo -n gcc && gcc --version > /dev/null
#first print gcc, then run gcc --version to see if it is installed
if [ $? != 0 ]; then
        echo "gcc not found"
        exit 0
fi
#report gcc not found if exit code of gcc --version does not equal 0
echo -e "\tOK\n"

findlib libc > /dev/null
#run findlib for libc

if [ $? = 1 ]; then
        echo -e "libc\tFAIL"
        echo -e "\nYou do not have libc libraries."
        exit 1
else
#report libc not found if findlib returns 1

        echo -e "libc\tOK\n"
fi

echo -n make && make --version > /dev/null
if [ $? != 0 ]; then
        echo "gnumake not found"
        exit 0
fi
echo -e "\tOK\n\nDONE"

case $1 in
"")
echo 'CC = gcc' > ./makefile
echo 'CFLAGS = -W xcet.c -o ./binaries/Linux/xcet' >> ./makefile
echo "" >> ./makefile
echo "xcet : xcet.c" >> ./makefile
echo -e "\t\$(CC) \$(CFLAGS)" >> ./makefile
echo "install : installer" >> ./makefile
echo -e '\t./installer' >> ./makefile
;;
#default makefile configurations, formated to proper makefile syntax.  Modify CC and CFLAG lines for compiler and options, and change the rule "xcet" and the corresponding source file for your specific project
"--path")
echo 'CC = gcc' > ./makefile
echo "CFLAGS = -W xcet.c -o ./binaries/Linux/xcet" >> ./makefile
echo "" >> ./makefile
echo "xcet : xcet.c" >> ./makefile
echo -e "\t\$(CC) \$(CFLAGS)" >> ./makefile
echo "install : installer" >> ./makefile
echo -e "\t./installer --path $2" >> ./makefile
;;
#writes the makefile in the same way, but invokes installer with custom path arguments

#at this point everything else is custom to my program
"--factors")
if [ -z $2 ] || [ -z $3 ] 2> /dev/null; then
        echo "./config --factors bfvar_factor pblen_factor"
        exit 0
fi
mv ./xcet.h ./xcet.h.tmp
cat ./xcet.h.tmp | sed "s/bfvar_factor = [0-9]*/bfvar_factor = $2/g" > ./xcet.h.tmp2
cat ./xcet.h.tmp2 | sed "s/pblen_factor = [0-9]*/pblen_factor = $3/g" > ./xcet.h
rm ./xcet.h.tmp
rm ./xcet.h.tmp2
esac
To test for gcc and make, I simply use the version parameters for those programs, and test the exit code. To see if libc6 is installed, I use "whereis" and then operate on the results with the findlib() function. The makefile is then written based on options given to the user defined by the case switch.

I'm not sure if this is the proper way of doing this, but it worked out nicely for me, especially because my program is simple enough not to require a really complex makefile. I suppose the most you'll need to do is edit the CC and CFLAGS to use your compiler with the options you need and the files, of course; after that, configuring the install script to match your package should be trivial as well. I'm actually a pretty novice programmer just getting back into it, so I don't really know the nuances involved with compiling a program with two source files, but I'm pretty sure this will work for you with the right CFLAG settnigs. Edit: I think you'll also need to add two source files under one rule, or otherwise modify the written makefile accordingly. It shouldn't be too hard to do that for a simple program.

The other problem is that, I can't really help with testing for those libraries. Another member here clued me into the "whereis" command, and it works if you do "whereis libc", but not glib. So, I'm not quite sure how those other libraries you're using function, but on my system "whereis gtk" comes back with /etc/gtk/. It's probablly just a matter of testing the correct library name, but "whereis gdk" produces nothing, which is most likely just because I don't have the gnome development kit installed. You might want to write a small bash script using the findlib function and see if it works for finding the libraries you need; if it works on one distribution, it should be able to find the locations on another too.

Now, aside from the config script, I have the installer script referred to by the makefile that is written by the config script.

Code:
#!/bin/bash

if [ $UID != '0' ]; then
        echo -e "*WARNING*\n\nYou are not root, problems will probably occur\n\nIf you are using sudo this is probably fine just hit enter, otherwise enter 'q' and enter to quit and start as root\n\n"
        read var
        if [ $var = 'q' ] 2> /dev/null; then
                exit 0
        fi
fi

#test to see if user is root, if they are not, warn them that installation might not be successful, and give them the option to quit and start over

echo -e "\n\nInstalling...\n"

APPNAME=xcet

case $1 in
"")
PTH=/usr/bin

        echo $PATH | grep -o /usr/bin 1> /dev/null
        if [ $? != 0 ]; then
                echo -e "/usr/bin not in path, use ./config --path and one of the following\n\n $PATH"
                exit 0
        fi

#test if PTH is in the users PATH

        mv ./binaries/Linux/xcet $PTH/$APPNAME 2> /dev/null
#move the compiled binary to the PTH
        if ! ls -lah $PTH/$APPNAME 2> /dev/null; then
                echo "Unsuccessful"
                if [ $UID != 0 ]; then
                        echo "This is a probably a permission issue, you are not root."
                fi
                exit 0
        else
                echo "xcet installed"
        fi
#test for success, and if unsuccessful tests if problem is lack of permissions
;;
"--path")
PTH=$2

        echo $PATH | grep -o $PTH 1> /dev/null
        if [ $? != 0 ]; then
                echo -e "$PTH not in path\n\n Use one of these\n\n $PATH"
                exit 0
        fi

        mv ./binaries/Linux/xcet $PTH/$APPNAME 2> /dev/null
        if ! ls -lah $PTH/$APPNAME 2> /dev/null; then
                echo "Unsuccessful"
                if [ $UID != 0 ]; then
                        echo "This is a probably a permission issue, you are not root."
                        exit 0
                fi
        else
                echo "xcet installed"
        fi
;;
esac

echo ""

$PTH/$APPNAME -a 2> /dev/null

if [ $? != '0' ]; then
        if [ -e ./makefile ]; then
                echo "XCET was installed but does not run properly. If you compiled, this should not happen, contact author."
        else
                echo "XCET was installed but does not run proplery. If you used the precompiled version, try compiling."
        fi
fi
As you can see, I tried to write the config and install script in a way that I might accomdate it for other programs in the future, so maybe it will help you out too. If you want to look at the whole packages to get a better idea of how it works in relation of the files and the aesthetic versus functional parts of the config/install scripts, you can download my program here
http://www.mousebaked.org/xcet.tar.gz

Now, I should let it be known that I haven't really tested this on a lot of distributions. Just Kubuntu, Debian Etch, and Linux From Scratch I don't think that it would make any difference so long as "whereis" is installed, which I think is a standard on Linux systems, because it was present on Linux From Scratch.

Anyway, I hope this helps. I spent about three or four days working on this config and installer script combo, but I think the majority of that was just trying to figure out how it will work and how to do it. I think that the scripting is probably pretty obvious, but if you have any questions about what is going on and where, let me know by PM or here; I've got this thread subscribed to. I've also added comments to the scripts in this post to help; they don't have the same comments on the actual package though, so use this post to refer to them.
SagaciousKJB is offline   Reply With Quote
Old 05-14-2008   #8 (permalink)
hazel
Linux Newbie
 
hazel's Avatar
 
Join Date: May 2004
Location: Harrow, UK
Posts: 236
Thanks, Sagacious! For a start, you've taught me a new command; I never heard of whereis before. I intend to study your scripts thoroughly. I'm sure I could customise them for my purpose.

The only minus is that there seems to be a proper GNU way of doing these things and your way is non-standard. I don't know how far that actually matters. I suspect that if you want to put something up on an official site like sourceforge or freshmeat, then it has to be done by the book.

On the other hand, if I just want to share with forum folks who might be interested...
__________________
"I'm just a little old lady; don't try to dazzle me with jargon!"
hazel is offline   Reply With Quote
Old 05-14-2008   #9 (permalink)
SagaciousKJB
Just Joined!
 
SagaciousKJB's Avatar
 
Join Date: Aug 2007
Location: Yakima, WA
Posts: 99
Send a message via AIM to SagaciousKJB Send a message via MSN to SagaciousKJB
Quote:
Originally Posted by hazel View Post
Thanks, Sagacious! For a start, you've taught me a new command; I never heard of whereis before. I intend to study your scripts thoroughly. I'm sure I could customise them for my purpose.

The only minus is that there seems to be a proper GNU way of doing these things and your way is non-standard. I don't know how far that actually matters. I suspect that if you want to put something up on an official site like sourceforge or freshmeat, then it has to be done by the book.

On the other hand, if I just want to share with forum folks who might be interested...
Well, I don't know about Freshmeat, but it doesn't matter for SourceForge. You can put your software up without any installation packaging at all; I've seen lone scripts, and packages of just pure source code. As far as putting it under GPL goes, I think so long as it contains the GPL, it should be fine. That's my understanding of it anyway.

But, yeah, you should have no problem licensing under GPL and putting it up on SourceForge, as I did with mine.
SagaciousKJB is offline   Reply With Quote
Old 05-16-2008   #10 (permalink)
SagaciousKJB
Just Joined!
 
SagaciousKJB's Avatar
 
Join Date: Aug 2007
Location: Yakima, WA
Posts: 99
Send a message via AIM to SagaciousKJB Send a message via MSN to SagaciousKJB
Well, sorry for the double post, but I can't edit my last one...

Anyway, I was looking around GNU last night, and I stumbled upon GNU's Coding Standards page and GNU Software Evalution page.

The Coding Standards page is a very hefty manual, but the part you're interested is here:
GNU Coding Standards

This page offers some nice questionnaire to check your program with, as well as submission for evaluation. It seems pretty neat

GNU Software Evaluation - GNU Project - Free Software Foundation (FSF)

However, I should note, the following link is to actually submit a package as a maintainer. So, you could alternatively just submit it to the Free Directory to not have that much responsibility, but it still offers some nice information.
SagaciousKJB is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


All times are GMT. The time now is 08:14 PM.

Powered by vBulletin 3.6.8 ©2000 - 2007, content relevant URLs by vBSEO, Property of Core Root.

Content Relevant URLs by vBSEO 3.0.0