flat assembler
Message board for the users of flat assembler.

flat assembler > Linux > fasm setup bash scrpt (v0.1 alpha)

Author
Thread Post new topic Reply to topic
scientica
Retired moderator


Joined: 16 Jun 2003
Posts: 689
Location: Linköping, Sweden
Windows didn't start to day so I booted up Linux instead (i.e. just like many other days Razz Wink)
Anyway, I downloaded the latest fasm for linux (I still ran the 1.46.9.1!), and after I installed it (unpacked, fixed the symlink) I thought maybe I should make some script to make my life easier. So I put together bellow, as the subject row says it's still alpha (meaning that I'm still writing on it).
I'd like to hear you comments on it, suggestion of improvements, etc.

If you decide to use it then you'd need to know this:
  1. The fasm package must e in the same folder as the script-
  2. You must run the script from the folder where it lies.
  3. I used xterm for testing of the script, there is "ANSI formating" in the output.
  4. I might have forgot to mention something, but I've warned you, it's an alpha Rolling Eyes

The script unpacks the fasm package to the installation folder and renames it to fasm-1.47, and then if you selected yes, set up an symlink in /usr/bin that points to the fasm elf (so it can be eaily run from anywhere).

here's the script (v01.sh):
Code:
#!/bin/bash
#debug: !/bin/bash -x
# fasm setup script - version 0.1 alpha
# Copyright notice:
#  fasm is the creation of Tomasz Grysztar (aka Privalov)
#  This setup script is the creation of Fredrik Klasson (aka scientica),
#  thus the copyright notice bellow on applies to this script, not
#  fasm it self.
# Copyright (c) Fredrik Klasson 2003.
#
# WARNING!
# This script is an alpha version, this means it's still experimental
# and is not to e considered stable or safe, use at you own risk. If
# you are unsure wheter to run this script or not, **don't run it**!

set_all(){
 fasm_version_str="1.47"
 fasm_path="/usr/local/bin"
 fasm_setup_dir=$(pwd)
}
unset_all(){
unset fasm_version
unset fasm_path
unset fasm_setup_dir
unset fasm_sylink
unset ans
}
#------------------------------------------------------------------------
do_unpack(){
 #echo -e "cd $fasm_path"
 cd "$fasm_path"
 #echo -e "gunzip -cdN $fasm_setup_dir/fasm-$fasm_version_str.tar.gz > tmp.tar"
 gunzip -cdN "$fasm_setup_dir/fasm-$fasm_version_str.tar.gz" > tmp.tar
 if [ $? != 0 ]; then
  return 1;
 fi;
 #echo -e "tar -xf tmp.tar"
 tar -xf tmp.tar
 if [ $? != 0 ]; then
  return 1;
 fi;
 #echo -e "rm tmp.tar"
 rm tmp.tar
 if [ $? != 0 ]; then
  return 1;
 fi;
 #echo -e "mv fasm fasm-$fasm_version_str"
 mv "fasm" "fasm-$fasm_version_str"
 if [ $? != 0 ]; then
  return 1;
 fi;
 return 0;
# return -1; - <deug>
}
#------------------------------------------------------------------------
set_all

# Display alpha version warning:
echo -e "\x1b[31m# WARNING!\n"
echo -e "# This script is an alpha version, this means it's still experimental\n"
echo -e "# and is not to e considered stable or safe, use at you own risk. If\n"
echo -e "# you are unsure wheter to run this script or not, \x1b[1m**don't run it**!\n\n\x1b[0m"

echo -e "Welcome to the \x1b[30m\x1b[32mflat assembler\x1b[0m (\x1b[30m\x1b[32mfasm\x1b[0m) setup for version $fasm_version_str"

if [ "$USER" != "root" ]; then
 echo -e "\x1b[31mNote: It's recomended to run this setup as root.\x1b[0m"
fi;

echo -e "\nWould you like to setup a symbolic link to fasm in \x1b[36m/usr/bin\x1b[0m?"
echo -e "Note! If you intend to install fasm in \x1b[36m/usr/bin\x1b[0m select \x1b[1mno\x1b[0m (\x1b[1mnot recomended\x1b[0m)"
echo -e "[yes/no] \c"
read fasm_sylink
if [ "$fasm_sylink" = "yes" ]; then
 fasm_symlink=true
elif [ "$fasm_sylink" = "no" ]; then
 fasm_symlink=false
else
 echo -e "\x1b[1m\x1b[31mError:\x1b[0m\x1b[31m invalid input!\x1b[0m"
 unset_all
 exit
fi;

echo -e "Install fasm in \x1b[36m$fasm_path\x1b[0m? [yes/no] \c"
read ans

if [ "$ans" = "yes" ]; then
 echo -e "\c"
elif [ "$ans" = "no" ]; then
 echo -e "Note! Specify the folder in which the \x1b[36mfasm-$fasm_version_str\x1b[0m is to be placed. This folder must exist, the \x1b[36mfasm-$fasm_version_str\x1b[0m directory will be created by the setup."
 echo -e "Enter new target folder: \x1b[33m\c"
 read fasm_path
 echo -e "\x1b[0m\c"
else
 echo -e "\x1b[1m\x1b[31mError:\x1b[0m\x1b[31m invalid input! If you wanted to install to a diffrent location please type no at the prompt.\x1b[0m"
 unset_all
 exit
fi;

echo -e "Unpacking to \x1b[36m$fasm_path\x1b[0m..."

do_unpack
if [ $? != 0 ]; then
 echo -e "\x1b[1m\x1b[31mError:\x1b[0m\x1b[31m Unpacking failed!\x1b[0m"
 unset_all
 exit
fi;

if [ $fasm_symlink = true ]; then
 echo -e "A symbolic link with the name \x1b[36mfasm\x1b[0m will be created in \x1b[36m/usr/bin\x1b[0m and point to \x1b[36m$fasm_path/fasm\x1b[0m, hit enter to execute the following line:"
 #echo -e "ln -isv \x1b[36m$fasm_path/fasm-$fasm_version_str/fasm /usr/bin/fasm\x1b[0m"
 ln -isv "$fasm_path/fasm-$fasm_version_str/fasm" /usr/bin/fasm
 read
fi;

unset_all
echo -e "\x1b[0m\c"    


Here's an example of how it can be used (real working usage Cool ):
[root@centralplexus tmp]# ./v01.sh
# WARNING!

# This script is an alpha version, this means it's still experimental

# and is not to e considered stable or safe, use at you own risk. If

# you are unsure wheter to run this script or not, **don't run it**!”



Welcome to the flat assembler (fasm) setup for version 1.47

Would you like to setup a symbolic link to fasm in /usr/bin?
Note! If you intend to install fasm in /usr/bin select no (not recomended)
[yes/no] no
Install fasm in /usr/local/bin? [yes/no] no
Note! Specify the folder in which the fasm-1.47 is to be placed. This folder must exist, the fasm-1.47 directory will e created by the setup.
Enter new target folder: /tmp
Unpacking to /tmp...
[root@centralplexus tmp]# ll
totalt 1744
drwxr-xr-x 4 88295 users 4096 jun 28 07:47 fasm-1.47
--snip-- this dir is just the standard /tmp, it's sooooo interesting Wink
[root@centralplexus tmp]# ll fasm-1-47
totalt 224
drwxr-xr-x 5 88295 users 4096 jun 28 07:47 examples
-rwxr-xr-x 1 88295 users 54176 jun 28 07:47 fasm
-rw-r--r-- 1 88295 users 141098 jun 28 07:47 fasm.txt
-rw-r--r-- 1 88295 users 1782 jun 28 07:47 license.txt
drwxr-xr-x 5 88295 users 4096 jun 28 07:47 source
-rw-r--r-- 1 88295 users 6204 jun 28 07:47 whatsnew.txt
[root@centralplexus tmp]#

_________________
... a professor saying: "use this proprietary software to learn computer science" is the same as English professor handing you a copy of Shakespeare and saying: "use this book to learn Shakespeare without opening the book itself.
- Bradley Kuhn
Post 19 Jul 2003, 20:00
View user's profile Send private message Visit poster's website MSN Messenger ICQ Number Reply with quote
scientica
Retired moderator


Joined: 16 Jun 2003
Posts: 689
Location: Linköping, Sweden
I just installed version 1.48 with my script (now version 0.2, considered stable)
I added support (untested!) for bzip2 (de)compression, since my copy of fasm for linux was names fasl-1.48.tar.gz.bz2. (It turned out to be just tar-gziped, I saw that the download had the right extension now).

Is there any one using my little script, or is posting it just a waist of bandwith?

(p.s. .sh isn't allowed as extension so I gziped the script)


Description: Scientica's fasm setup script - version 0.2 (stable)
Download
Filename: v02.sh.gz
Filesize: 1.3 KB
Downloaded: 262 Time(s)


_________________
... a professor saying: "use this proprietary software to learn computer science" is the same as English professor handing you a copy of Shakespeare and saying: "use this book to learn Shakespeare without opening the book itself.
- Bradley Kuhn
Post 26 Jul 2003, 06:55
View user's profile Send private message Visit poster's website MSN Messenger ICQ Number Reply with quote
gorshing



Joined: 27 Jul 2003
Posts: 72
Location: Okla, US
Code:
# WARNING!
 
# This script is an alpha version, this means it's still experimental
 
# and is not to e considered stable or safe, use at you own risk. If
 
# you are unsure wheter to run this script or not, **don't run it**!
 
 
Welcome to the flat assembler (fasm) setup for version 1.47
Note: It's recomended to run this setup as root.
 
Would you like to setup a symbolic link to fasm in /usr/bin?
Note! If you intend to install fasm in /usr/bin select no (not recomended)
[yes/no] yes
Install fasm in /usr/local/bin? [yes/no] no
Note! Specify the folder in which the fasm-1.47 is to be placed. This folder must exist, the fasm-1.47 directory will be created by the setup.
Enter new target folder: /packages
Unpacking to /packages...
gunzip: /packages/fasm-1.47.tar.gz: No such file or directory
Error: Unpacking failed!
    


I did that on purpose.

But anyways, when you return from do_unpack and test for return value, you might want to also remove the tmp.tar file. Although it is an empty file, it's not meant to be there Smile

Other than that, seems good to me ... I used it Smile
Post 27 Jul 2003, 22:46
View user's profile Send private message Visit poster's website Reply with quote
scientica
Retired moderator


Joined: 16 Jun 2003
Posts: 689
Location: Linköping, Sweden
Ah, now I see Sad well positive thinking: first bug removed Wink
Thanks for the bug report (I've put a bug history in the scirpt, a "Hall of Shame")

I also removed the bzip2 support (I'll re-implent it if needed in the furture, now it only adds size and time ( Rolling Eyes ))

[EDIT]If you want to use the script to install an other version of fasm than 1.48, simply change the fasm_version_str, here's an little example of how to make the script install version 1.48.9.5 (just an example):
Code:
set_all(){
fasm_version_str="1.48.9.5"    

the fasm package file name is "created" using this line:
fasm-$fasm_version_str.tar.gz
thus when fasm_version_str is changed to above it will look like this:
fasm-1.48.9.5.tar.gz
[/EDIT]


Description: fasm setup script - version 0.2b (stable)
Download
Filename: v02b.sh.gz
Filesize: 1.29 KB
Downloaded: 245 Time(s)


_________________
... a professor saying: "use this proprietary software to learn computer science" is the same as English professor handing you a copy of Shakespeare and saying: "use this book to learn Shakespeare without opening the book itself.
- Bradley Kuhn
Post 28 Jul 2003, 10:47
View user's profile Send private message Visit poster's website MSN Messenger ICQ Number Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2019, Tomasz Grysztar.

Powered by rwasa.