- An Application Name
- A version
- Description of application
- An Application Name
- A Version if Any
- A One-Line Application Description
Code: Select all
sh dir2txz.sh <fakeroot> [<version string>] "<application>:<space><description>"
Code: Select all
Usage: dir2txz <fakeroot> [<version string>] "<application>:<space><description>"
<version string>: <version>[-tag[initials]] initials:'xy'
Version Defaulted: [<tag>]<initials> tag:'0'
<initials>: [a-z][a-z] (2 letters) <tag>: [0-9]
<version>: [0-9].[0-9][.[0-9]]
- Prolog
Code: Select all
guest@porteus:~$ mkdir far; Fakeroot Directory guest@porteus:~$ and="symfix: Sym Link Fix for /lib/liblzma.so.5 and /lib/libgpg-error.so.0"; # Application & Description
- Package File Required:
- symfix-3.5.6-i486-8zb.txz
Code: Select all
guest@porteus:~$ dir2txz far 3.5.6-8zb "$and" Continue to make Package symfix-3.5.6-i486-8zb.txz? [Y/n] -> Package Creation
- symfix-0.9-i486-2zb.txz
Code: Select all
guest@porteus:~$ dir2txz far 0.9-2zb "$and" Continue to make Package symfix-0.9-i486-2zb.txz? [Y/n] -> Package Creation
- symfix-3.5.6-i486-8zb.txz
- Package File Defaults
- symfix-2.6.4-i486-7xy.txz
Code: Select all
guest@porteus:~$ dir2txz far 2.6.4-7 "$and" Continue to make Package symfix-2.6.4-i486-7xy.txz? [Y/n] -> Package Creation
- symfix-1.8.3-i486-0xy.txz
Code: Select all
guest@porteus:~$ dir2txz far 1.8.3 "$and" Continue to make Package symfix-1.8.3-i486-0xy.txz? [Y/n] -> Package Creation
- symfix-0.5-i486-2xy.txz
Code: Select all
guest@porteus:~$ dir2txz far 0.5-2 "$and" Continue to make Package symfix-0.5-i486-2xy.txz? [Y/n] -> Package Creation
- symfix-0.3-i486-0xy.txz
Code: Select all
guest@porteus:~$ dir2txz far 0.3 "$and" Continue to make Package symfix-0.3-i486-0xy.txz? [Y/n] -> Package Creation
- symfix-2.6.4-i486-7xy.txz
- Simple Defaults
- symfix-0.0.0-i486-0xy.txz
Code: Select all
guest@porteus:~$ dir2txz far "$and" Continue to make Package symfix-0.0.0-i486-0xy.txz? [Y/n] -> Package Creation
- symfix-0.0.0-i486-0zb.txz
Code: Select all
guest@porteus:~$ dir2txz far zb "$and" Continue to make Package symfix-0.0.0-i486-0zb.txz? [Y/n] -> Package Creation
- symfix-0.0.0-i486-9zb.txz
Code: Select all
guest@porteus:~$ dir2txz far 9zb "$and" Continue to make Package symfix-0.0.0-i486-9zb.txz? [Y/n] -> Package Creation
- symfix-0.0.0-i486-0xy.txz
Code: Select all
# dir2txz.sh <- 2txz.sh 2016-12-14 14:08:39
## Verification by Key Press 2015-02-12 00:11:36
kpv ()
{
local nu; local k;
while (( 1 ))
do
read -s -n1 -p "$1? [Y/n]" k
case $k in
"$nu" ) echo ""; return 0;;
[yY] ) echo ""; return 0;;
[nN] ) echo ""; return 1;;
* ) echo $'\n'"Invalid Key '$k'"
esac
done
}
## Key Press with Confirmation
# 1st Param: Default string msg
# 2nd Param: Alternative msg
kpc ()
{
local k; local nu; local ms;
nu=""; r=1; ms="-> $1"
false;
while (( $? ))
do
while (( 1 ))
do
read -s -n1 -p "$1? [Y/n]" k
case $k in
"$nu" ) echo $'\n'$ms; return 0;;
[yY] ) echo $'\n'$ms; return 0;;
[nN] ) echo ""; break;;
* ) echo $'\n'"Invalid Key '$k'"
esac
done
# Fall Through
kpv "$2"
done
! [[ ${3+x} ]] && echo "-> $2"
return 1;
}
sd0() # Create one-liner in 'slack-desc'
{
[[ ! -d $fr/install ]] && mkdir $fr/install
sd=$fr/install/slack-desc
echo "$1" > $sd
ad=${1%%:*}:; # Application plus Delimiter
for ((i=0; i<10; i++)); do echo $ad >> $sd; done
echo "<slack-desc>"
head -n1 $sd
}
# Strip Leading and Trailing Whitespace 2015-08-28 14:21:56
stripoff()
{
((0)) && echo "first='$1'"
local x; local y; local s; local t
x=$(expr "$1" : '[[:space:]]\+'); s=${1:x}; # Leading Stripped
y=$(expr "$s" : '.\+[^[:space:]]'); t=${s:0:y}; # Trailing Stripped
echo "$t"
}
# 2txz <fakeroot> [<version string>] "<application>:<space><description>"
dir2txz()
{
# 2txz <fake root> [[<tag>]<initials>] "<application>:<space><description>"
#
# 2txz <fake root> <[0-9]>.<[0-9]>[.<[0-9]>][-tag[initials]] "<application>:<space><description>"
#
# <version string>: {<version>[-<tag>[initials]],[<tag>]<initials>}
# <initials>: <[a-z]><[a-z]> (2 letters) <tag>: <[0-9]>
# <version>: <[0-9]>.<[0-9]>[.<[0-9]>]
#
# 'Readonly Variables': sys ver des vst (Final version string)
dry=0; # Dry Run
ex=0; # Examples Run
if [[ $# -lt 2 ]]; then (($#)) && echo "Error: Too few arguments: '$@' !";
na=${0##*/}; na=${na%.sh}
printf "Usage:\t%s\t<fakeroot>\t[<version string>]\t\"<application>:<space><description>\"\n\n" $na
printf "\t<version string>:\t{<version>[-tag[initials]],[<tag>]<initials>}\n"
printf "\t<initials>:\t[a-z][a-z]\t\t(2 letters)\t<tag>:\t[0-9]\n"
printf "\t<version>:\t[0-9].[0-9][.[0-9]]\n"
return 4;
fi
if [[ ! -d $1 ]]; then echo Error: $1 not a Directory!; return 1; fi
[[ ! -w $1 ]] && { echo "Permission: Cannot create Slackdesc in '$1' !"; return 1; };
sys=x86_64; [[ $(file /bin/bash) =~ ELF[[:space:]]+32-bit ]] && sys=i586; # Kernel 32 or 64 bit?
fr=$1; # Fakeroot
# v=""; d=$2; if [[ $3 ]]; then v=$2; d=$3; fi
# Allow for defaulting the version. 2016-12-14 17:28:08
v=""; shift 1;
if [[ $1 =~ ^[0-9]+\.|^[0-9]?[a-z][a-z]$ ]]; then v=$1; shift 1; fi
# Insert ':" Separator. if Missing. Followed by remainder pf Param 2 and/or rest of Params, forming Description of Package.
d=$*; a=${d%% *}; r=${d:${#a}}; d=${a%:}:$r; # r: Description after app name. 2016-12-14 15:11:23
ver=$v; des=$d; # Save original values
# Application Name as applied to Description Format
# Version Processing
[[ ${v:=xy} =~ ^[a-z][a-z]$ ]] && v=0.0.0-0$v;
[[ $v =~ ^[[:digit:]]+[a-z][a-z]$ ]] && v=0.0.0-$v;
[[ $v =~ ^[[:digit:]]+\.[[:digit:]]+(\.[[:digit:]]+)?$ ]] && v=$v-0xy;
[[ $v =~ ^[[:digit:]]+\.[[:digit:]]+(\.[[:digit:]]+)?-[[:digit:]]$ ]] &&
v=${v%-?}-${v#*-}xy;
if [[ ! $v =~ ^[[:digit:]]+\.[[:digit:]]+(\.[[:digit:]]+)?(-[[:digit:]][a-z][a-z])?$ ]]; then
echo "Version Format Error: '$ver' !"; return 2;
fi
vst=$v; # Keep Version Value
# Version now Set Up
[[ ! $h ]] && h="|-----handy-ruler------------------------------------------------------|";
# Get it Right
r=1; while ((r)); # Functional Loop
# APPLICATION/DESCRIPTION LINE PROCESSING
do
[[ $em ]] && des=$d; # Loop Description 2015-08-29 23:10:03
em=""; a=""; # Application Name
w=${d%%:*}; [[ $w == $d ]] && em="Missing Application Name Field: '$des'"
if [[ ! $em ]]; then a=$(stripoff "${d%%:*}");
m=$(expr "$a" : '.* '); # Check for embedded blanks
((m)) && em="Blanks in Application Name Field: '$des'";
fi
let r=-1; # Flag Previous
if [[ ! $em ]]; then # Strip Leading and Trailing Blanks from Desc Field
s=${d#*:}; t=$(stripoff "$s");
# Set up Application: Description Line
l="$a: $t"; n=${#l}; let r=n-72; # Check for O'flow; Set up Dashed Line
if [[ r -gt 0 ]]; then [[ ! $dl ]] && for((i=0; i<72; i++)); do dl+=-; done;
em="Overflow";
fi
else
em=$'\n'"$em"
fi
[[ $em ]] && echo "Error: Application/Description Line $em!";
# [[ $em ]] && { [[ $em0 ]] && em1=echo "Error: Application / Description Line"$'\n'"$em !"; }
# Description Overflow
[[ r -gt 0 ]] && { echo $'\t'$'\t'" ${dl:0:r}"; echo Overrun: $'\t'"|${l:72}"; echo $'\t'$'\t'" ${dl:0:r}";
echo " $dl"; echo "|${l:0:72}|"; echo " $dl"; }
# All Clear
if [[ ! $em ]]; then v=$vst; # Continue to make Package?
kpv "Continue to make Package $a-${v%-*}-$sys-${v#*-}.txz" && break;
kpc "Redo Application/Description" "Terminate"
(($?)) && echo Terminated! && return 9;
fi
if [[ $em ]]; then kpv "Redo Application/Description: '$des'";
(($?)) && echo Terminated! && return 9;
fi
d=$(dialog --stdout --max-input 72 --title "Application/Description" --no-cancel --fixed-font --inputbox " $h" 6 78 "$d")
done
p=$a-${v%-*}-$sys-${v#*-}.txz;
((ex)) && echo " -> Package Creation" && return 0;
echo "$h"; ((dry)) && echo "$l"; # Success!
! ((dry)) && sd0 "$l"
((dry)) && return 0;
pushd . > /dev/null
cd $fr
/sbin/makepkg -l y -c n ../$p; # 2015-07-03 14:58:59
popd > /dev/null
}
dir2txz "$@"; # '2txz' not accepted, presumably because variable name cannot be numeric initially.
Superseded---------------------------------------------
If invoked as 2txz.sh:
Code: Select all
sh 2txz.sh <fakeroot> [<version string>] "<application>:<space><description>"
Code: Select all
guest@porteus:~$ 2txz
Usage: 2txz <fakeroot> [<version string>] "<application>:<space><description>"
<version string>: <version>[-tag[initials]] initials:'xy'
Default: [<tag>]<initials> tag:'0'
<initials>: [a-z][a-z] (2 letters) <tag>: [0-9]
<version>: [0-9].[0-9][.[0-9]]
Code: Select all
guest@porteus:~$ mkdir far
guest@porteus:~$ and="symfix: Sym Link Fix for /lib/liblzma.so.5 and /lib/libgpg-error.so.0"
guest@porteus:~$ 2txz far "$and"
Continue to make Package symfix-0.0.0-i486-0xy.txz? [Y/n]
-> Package Creation
guest@porteus:~$ 2txz far zb "$and"
Continue to make Package symfix-0.0.0-i486-0zb.txz? [Y/n]
-> Package Creation
guest@porteus:~$ 2txz far 9zb "$and"
Continue to make Package symfix-0.0.0-i486-9zb.txz? [Y/n]
-> Package Creation
guest@porteus:~$ 2txz far 0.3 "$and"
Continue to make Package symfix-0.3-i486-0xy.txz? [Y/n]
-> Package Creation
guest@porteus:~$ 2txz far 0.5-2 "$and"
Continue to make Package symfix-0.5-i486-2xy.txz? [Y/n]
-> Package Creation
guest@porteus:~$ 2txz far 1.8.3 "$and"
Continue to make Package symfix-1.8.3-i486-0xy.txz? [Y/n]
-> Package Creation
guest@porteus:~$ 2txz far 2.6.4-7 "$and"
Continue to make Package symfix-2.6.4-i486-7xy.txz? [Y/n]
-> Package Creation
guest@porteus:~$ 2txz far 0.9-2zb "$and"
Continue to make Package symfix-0.9-i486-2zb.txz? [Y/n]
-> Package Creation
guest@porteus:~$ 2txz far 3.5.6-8zb "$and"
Continue to make Package symfix-3.5.6-i486-8zb.txz? [Y/n]
-> Package Creation
Code: Select all
guest@porteus:~$ 2txz far symfix:" Sym Link Fix for /lib/liblzma.so.5 and /lib/libgpg-error.so.0"
Continue to make Package symfix-0.0.0-i486-0xy.txz? [Y/n]
|-----handy-ruler------------------------------------------------------|
symfix: Sym Link Fix for /lib/liblzma.so.5 and /lib/libgpg-error.so.0
<slack-desc>
symfix: Sym Link Fix for /lib/liblzma.so.5 and /lib/libgpg-error.so.0
guest@porteus:~$ tree far
far
└── install
└── slack-desc
1 directory, 1 file
guest@porteus:~$ cat far/install/slack-desc
symfix: Sym Link Fix for /lib/liblzma.so.5 and /lib/libgpg-error.so.0
symfix:
symfix:
symfix:
symfix:
symfix:
symfix:
symfix:
symfix:
symfix:
symfix:
Code: Select all
guest@porteus:~$ sh 2txz.sh sym bp "symfix: Fix up of symbolic links for /lib/liblzma.so.5 and /lib/libgpg-error.so.0"
Error: Application / Description Line Overflow!
------------
Overrun: |g-error.so.0
------------
------------------------------------------------------------------------
|symfix: Fix up of symbolic links for /lib/liblzma.so.5 and /lib/libgp|
------------------------------------------------------------------------
Redo Application/Description: 'symfix: Fix up of symbolic links for /lib/liblzma.so.5 and /lib/libgpg-error.so.0'? [Y/n]
┌─────────────────────────Application/Description────────────────────────────┐
│ |-----handy-ruler------------------------------------------------------| │
│ ┌────────────────────────────────────────────────────────────────────────┐ │
├─│symfix: Fix up of sym links for /lib/liblzma.so.5 /lib/libgpg-error.so.│─┤
│ └───────────────────────────────< OK >─────────────────────────────────┘ │
└────────────────────────────────────────────────────────────────────────────┘
Error: Application / Description Line Overflow!
-
Overrun: |0
-
------------------------------------------------------------------------
|symfix: Fix up of sym links for /lib/liblzma.so.5 /lib/libgpg-error.so.|
------------------------------------------------------------------------
Redo Application/Description: 'symfix: Fix up of sym links for /lib/liblzma.so.5 /lib/libgpg-error.so.0'? [Y/n]
┌─────────────────────────Application/Description────────────────────────────┐
│ |-----handy-ruler------------------------------------------------------| │
│ ┌────────────────────────────────────────────────────────────────────────┐ │
├─│symfix: Fix up sym links for /lib/liblzma.so.5 & /lib/libgpg-error.so.0 │─┤
│ └───────────────────────────────< OK >─────────────────────────────────┘ │
└────────────────────────────────────────────────────────────────────────────┘
Continue to make Package symfix-0.0.0-i486-0bp.txz? [Y/n]
|-----handy-ruler------------------------------------------------------|
<slack-desc>
symfix: Fix up sym links for /lib/liblzma.so.5 & /lib/libgpg-error.so.0
Slackware package maker, version 3.14159.
Searching for symbolic links:
No symbolic links were found, so we won't make an installation script.
You can make your own later in ./install/doinst.sh and rebuild the
package if you like.
...
Creating Slackware package: ../symfix-0.0.0-i486-0bp.txz
./
install/
install/slack-desc
etc/
etc/rc.d/
etc/rc.d/symfix
lib/
lib/libgpg-error.so.0
lib/liblzma.so.5
Slackware package ../symfix-0.0.0-i486-0bp.txz created.
Code: Select all
## Verification by Key Press 2015-02-12 00:11:36
kpv ()
{
local nu; local k;
while (( 1 ))
do
read -s -n1 -p "$1? [Y/n]" k
case $k in
"$nu" ) echo ""; return 0;;
[yY] ) echo ""; return 0;;
[nN] ) echo ""; return 1;;
* ) echo $'\n'"Invalid Key '$k'"
esac
done
}
## Key Press with Confirmation
# 1st Param: Default string msg
# 2nd Param: Alternative msg
kpc ()
{
local k; local nu; local ms;
nu=""; r=1; ms="-> $1"
false;
while (( $? ))
do
while (( 1 ))
do
read -s -n1 -p "$1? [Y/n]" k
case $k in
"$nu" ) echo $'\n'$ms; return 0;;
[yY] ) echo $'\n'$ms; return 0;;
[nN] ) echo ""; break;;
* ) echo $'\n'"Invalid Key '$k'"
esac
done
# Fall Through
kpv "$2"
done
! [[ ${3+x} ]] && echo "-> $2"
return 1;
}
sd0() # Create one-liner in 'slack-desc'
{
[[ ! -d $fr/install ]] && mkdir $fr/install
sd=$fr/install/slack-desc
echo "$1" > $sd
ad=${1%%:*}:; # Application plus Delimiter
for ((i=0; i<10; i++)); do echo $ad >> $sd; done
echo "<slack-desc>"
head -n1 $sd
}
# Strip Leading and Trailing Whitespace 2015-08-28 14:21:56
stripoff()
{
((0)) && echo "first='$1'"
local x; local y; local s; local t
x=$(expr "$1" : '[[:space:]]\+'); s=${1:x}; # Leading Stripped
y=$(expr "$s" : '.\+[^[:space:]]'); t=${s:0:y}; # Trailing Stripped
echo "$t"
}
# 2txz <fakeroot> [<version string>] "<application>:<space><description>"
dir2txz()
{
# 2txz <fake root> [[<tag>]<initials>] "<application>:<space><description>"
#
# 2txz <fake root> <[0-9]>.<[0-9]>[.<[0-9]>][-tag[initials]] "<application>:<space><description>"
#
# <version string>: {<version>[-<tag>[initials]],[<tag>]<initials>}
# <initials>: <[a-z]><[a-z]> (2 letters) <tag>: <[0-9]>
# <version>: <[0-9]>.<[0-9]>[.<[0-9]>]
#
# 'Readonly Variables': sys ver des vst (Final version string)
dry=0; # Dry Run
ex=0; # Examples Run
if [[ $# -gt 3 || $# -lt 2 ]]; then (($#)) && echo "Error: Too many/few arguments: '$@' !";
na=${0##*/}; na=${na%.sh}
printf "Usage:\t%s\t<fakeroot>\t[<version string>]\t\"<application>:<space><description>\"\n\n" $na
printf "\t<version string>:\t{<version>[-tag[initials]],[<tag>]<initials>}\n"
printf "\t<initials>:\t[a-z][a-z]\t\t(2 letters)\t<tag>:\t[0-9]\n"
printf "\t<version>:\t[0-9].[0-9][.[0-9]]\n"
return 4;
fi
if [[ ! -d $1 ]]; then echo Error: $1 not a Directory!; return 1; fi
[[ ! -w $1 ]] && { echo "Permission: Cannot create Slackdesc in '$1' !"; return 1; };
sys=x86_64; [[ $(file /sbin/init) =~ ELF[[:space:]]+32-bit ]] && sys=i486; # Kernel 32 or 64 bit?
fr=$1; # Fakeroot
v=""; d=$2; if [[ $3 ]]; then v=$2; d=$3; fi
ver=$v; des=$d; # Save original values
# Application Name as applied to Description Format
# Version Processing
[[ ${v:=xy} =~ ^[a-z][a-z]$ ]] && v=0.0.0-0$v;
[[ $v =~ ^[[:digit:]][a-z][a-z]$ ]] && v=0.0.0-$v;
[[ $v =~ ^[[:digit:]]\.[[:digit:]](\.[[:digit:]])?$ ]] && v=$v-0xy;
[[ $v =~ ^[[:digit:]]\.[[:digit:]](\.[[:digit:]])?-[[:digit:]]$ ]] &&
v=${v%-?}-${v#*-}xy;
if [[ ! $v =~ ^[[:digit:]]\.[[:digit:]](\.[[:digit:]])?(-[[:digit:]][a-z][a-z])?$ ]]; then
echo "Version Format Error: '$ver' !"; return 2;
fi
vst=$v; # Keep Version Value
# Version now Set Up
[[ ! $h ]] && h="|-----handy-ruler------------------------------------------------------|";
# Get it Right
r=1; while ((r)); # Functional Loop
# APPLICATION/DESCRIPTION LINE PROCESSING
do
[[ $em ]] && des=$d; # Loop Description 2015-08-29 23:10:03
em=""; a=""; # Application Name
w=${d%%:*}; [[ $w == $d ]] && em="Missing Application Name Field: '$des'"
if [[ ! $em ]]; then a=$(stripoff "${d%%:*}");
m=$(expr "$a" : '.* '); # Check for embedded blanks
((m)) && em="Blanks in Application Name Field: '$des'";
fi
let r=-1; # Flag Previous
if [[ ! $em ]]; then # Strip Leading and Trailing Blanks from Desc Field
s=${d#*:}; t=$(stripoff "$s");
# Set up Application: Description Line
l="$a: $t"; n=${#l}; let r=n-72; # Check for O'flow; Set up Dashed Line
if [[ r -gt 0 ]]; then [[ ! $dl ]] && for((i=0; i<72; i++)); do dl+=-; done;
em="Overflow";
fi
else
em=$'\n'"$em"
fi
[[ $em ]] && echo "Error: Application/Description Line $em!";
# [[ $em ]] && { [[ $em0 ]] && em1=echo "Error: Application / Description Line"$'\n'"$em !"; }
# Description Overflow
[[ r -gt 0 ]] && { echo $'\t'$'\t'" ${dl:0:r}"; echo Overrun: $'\t'"|${l:72}"; echo $'\t'$'\t'" ${dl:0:r}";
echo " $dl"; echo "|${l:0:72}|"; echo " $dl"; }
# All Clear
if [[ ! $em ]]; then v=$vst; # Continue to make Package?
kpv "Continue to make Package $a-${v%-*}-$sys-${v#*-}.txz" && break;
kpc "Redo Application/Description" "Terminate"
(($?)) && echo Terminated! && return 9;
fi
if [[ $em ]]; then kpv "Redo Application/Description: '$des'";
(($?)) && echo Terminated! && return 9;
fi
d=$(dialog --stdout --max-input 72 --title "Application/Description" --no-cancel --fixed-font --inputbox " $h" 6 78 "$d")
done
p=$a-${v%-*}-$sys-${v#*-}.txz;
((ex)) && echo " -> Package Creation" && return 0;
echo "$h"; ((dry)) && echo "$l"; # Success!
! ((dry)) && sd0 "$l"
((dry)) && return 0;
pushd . > /dev/null
cd $fr
/sbin/makepkg -l y -c n ../$p; # 2015-07-03 14:58:59
popd > /dev/null
}
dir2txz "$@"; # '2txz' no accepted, presumably because variable name cannot be numeric initially.