Skip to content

Commit

Permalink
apt-cyg pull 79 replace awk with gawk
Browse files Browse the repository at this point in the history
apt-cyg pull 79 replace awk with gawk

transcode-open/apt-cyg#79

Fixe issues 78 can't remove or install package cannot open file /etc/setup/setup.rc

transcode-open/apt-cyg#78
  • Loading branch information
andykimpe authored Jun 17, 2024
1 parent e4a5bbf commit 59c6db1
Showing 1 changed file with 23 additions and 23 deletions.
46 changes: 23 additions & 23 deletions apt-cyg
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ function find-workspace {
# default working directory and mirror

# work wherever setup worked last, if possible
cache=$(awk '
cache=$(gawk '
BEGIN {
RS = "\n\\<"
FS = "\n\t"
Expand All @@ -145,7 +145,7 @@ function find-workspace {

if [[ "$(uname -m)" == "x86_64" ]]
then
mirror=$(awk '
mirror=$(gawk '
/last-mirror/ {
getline
print $1
Expand Down Expand Up @@ -212,7 +212,7 @@ function apt-category {
find-workspace
for pkg in "${pks[@]}"
do
awk '
gawk '
$1 == "@" {
pck = $2
}
Expand All @@ -228,10 +228,10 @@ function apt-list {
for pkg in "${pks[@]}"
do
let sbq++ && echo
awk 'NR>1 && $1~pkg && $0=$1' pkg="$pkg" /etc/setup/installed.db
gawk 'NR>1 && $1~pkg && $0=$1' pkg="$pkg" /etc/setup/installed.db
done
let sbq && return
awk 'NR>1 && $0=$1' /etc/setup/installed.db
gawk 'NR>1 && $0=$1' /etc/setup/installed.db
}

function apt-listall {
Expand All @@ -241,7 +241,7 @@ function apt-listall {
for pkg in "${pks[@]}"
do
let sbq++ && echo
awk '$1~pkg && $0=$1' RS='\n\n@ ' FS='\n' pkg="$pkg" setup.ini
gawk '$1~pkg && $0=$1' RS='\n\n@ ' FS='\n' pkg="$pkg" setup.ini
done
}

Expand All @@ -266,7 +266,7 @@ function apt-show {
for pkg in "${pks[@]}"
do
(( notfirst++ )) && echo
awk '
gawk '
$1 == query {
print
fd++
Expand All @@ -284,7 +284,7 @@ function apt-depends {
check-packages
for pkg in "${pks[@]}"
do
awk '
gawk '
@include "join"
$1 == "@" {
apg = $2
Expand Down Expand Up @@ -318,7 +318,7 @@ function apt-rdepends {
find-workspace
for pkg in "${pks[@]}"
do
awk '
gawk '
@include "join"
$1 == "@" {
apg = $2
Expand Down Expand Up @@ -364,7 +364,7 @@ function download {
pkg=$1
# look for package and save desc file

awk '$1 == pc' RS='\n\n@ ' FS='\n' pc=$pkg setup.ini > desc
gawk '$1 == pc' RS='\n\n@ ' FS='\n' pc=$pkg setup.ini > desc
if [ ! -s desc ]
then
echo Unable to locate package $pkg
Expand All @@ -374,7 +374,7 @@ function download {
# download and unpack the bz2 or xz file

# pick the latest version, which comes first
set -- $(awk '$1 == "install:"' desc)
set -- $(gawk '$1 == "install:"' desc)
if (( ! $# ))
then
echo 'Could not find "install" in package description: obsolete package?'
Expand Down Expand Up @@ -438,7 +438,7 @@ function apt-searchall {
do
printf -v qs 'text=1&arch=%s&grep=%s' $arch "$pkg"
wget -O matches cygwin.com/cgi-bin2/package-grep.cgi?"$qs"
awk '
gawk '
NR == 1 {next}
mc[$1]++ {next}
/-debuginfo-/ {next}
Expand Down Expand Up @@ -471,7 +471,7 @@ function apt-install {
tar -x -C / -f $bn
# update the package database

awk '
gawk '
ins != 1 && pkg < $1 {
print pkg, bz, 0
ins = 1
Expand All @@ -480,14 +480,14 @@ function apt-install {
END {
if (ins != 1) print pkg, bz, 0
}
' pkg="$pkg" bz=$bn /etc/setup/installed.db > /tmp/awk.$$
' pkg="$pkg" bz=$bn /etc/setup/installed.db > /tmp/gawk.$$
mv /etc/setup/installed.db /etc/setup/installed.db-save
mv /tmp/awk.$$ /etc/setup/installed.db
mv /tmp/gawk.$$ /etc/setup/installed.db

[ -v nodeps ] && continue
# recursively install required packages

requires=$(awk '$1=="requires", $0=$2' FS=': ' desc)
requires=$(gawk '$1=="requires", $0=$2' FS=': ' desc)
cd ~-
wr=0
if [[ $requires ]]
Expand Down Expand Up @@ -526,7 +526,7 @@ function apt-install {
function apt-remove {
check-packages
cd /etc
cygcheck awk bash bunzip2 grep gzip mv sed tar xz > setup/essential.lst
cygcheck gawk bash bunzip2 grep gzip mv sed tar xz > setup/essential.lst
for pkg in "${pks[@]}"
do

Expand All @@ -542,7 +542,7 @@ function apt-remove {
exit 1
fi
gzip -dk setup/"$pkg".lst.gz
awk '
gawk '
NR == FNR {
if ($NF) ess[$NF]
next
Expand Down Expand Up @@ -570,7 +570,7 @@ function apt-remove {
[ -d /$each ] && rmdir --i /$each
done
rm -f setup/"$pkg".lst.gz postinstall/"$pkg".sh.done
awk -i inplace '$1 != ENVIRON["pkg"]' setup/installed.db
gawk -i inplace '$1 != ENVIRON["pkg"]' setup/installed.db
echo Package $pkg removed
fi
rm setup/"$pkg".lst
Expand All @@ -586,7 +586,7 @@ function apt-remove {
function apt-mirror {
if [ "$pks" ]
then
awk -i inplace '
gawk -i inplace '
1
/last-mirror/ {
getline
Expand All @@ -595,7 +595,7 @@ function apt-mirror {
' pks="$pks" /etc/setup/setup.rc
echo Mirror set to "$pks".
else
awk '
gawk '
/last-mirror/ {
getline
print $1
Expand All @@ -608,7 +608,7 @@ function apt-cache {
if [ "$pks" ]
then
vas=$(cygpath -aw "$pks")
awk -i inplace '
gawk -i inplace '
1
/last-cache/ {
getline
Expand All @@ -617,7 +617,7 @@ function apt-cache {
' vas="${vas//\\/\\\\}" /etc/setup/setup.rc
echo Cache set to "$vas".
else
awk '
gawk '
/last-cache/ {
getline
print $1
Expand Down

0 comments on commit 59c6db1

Please sign in to comment.