extract RPM package on mac

save the codes below as ‘rpm2cpio’, do not forget to chmod +x:

#!/bin/sh
  
pkg=$1
  
if [ "$pkg" = "" -o ! -e "$pkg" ]; then
  echo "no package supplied" 1>&2
  exit 1
fi
  
leadsize=96
o=`expr $leadsize + 8`
set `od -j $o -N 8 -t u1 $pkg`
il=`expr 256 \* \( 256 \* \( 256 \* $2 + $3 \) + $4 \) + $5`
dl=`expr 256 \* \( 256 \* \( 256 \* $6 + $7 \) + $8 \) + $9`
  
sigsize=`expr 8 + 16 \* $il + $dl`
o=`expr $o + $sigsize + \( 8 - \( $sigsize \% 8 \) \) \% 8 + 8`
set `od -j $o -N 8 -t u1 $pkg`
il=`expr 256 \* \( 256 \* \( 256 \* $2 + $3 \) + $4 \) + $5`
dl=`expr 256 \* \( 256 \* \( 256 \* $6 + $7 \) + $8 \) + $9`
  
hdrsize=`expr 8 + 16 \* $il + $dl`
o=`expr $o + $hdrsize`
  
dd if=$pkg ibs=$o skip=1 2>/dev/null | gunzip
  

then you can extract an RPM package like this:

./rpm2cpio example.rpm |cpio -divm

debrick the wnr3500l v2

you may find a post HERE but it does not work, so follow the steps below:

1. connect the TTL serials without GND pin;
2. keep holding Ctrl+C on the keyboard, may need a guy to do this;
3. make sure the router is power-off;
4. power on the router;
5. wait for 0.5 second and QUICKLY connect the GND pin;
6. then you'll see the CFE console.
7. if not, do step 3~6 again :-)

man to text

man awk |col -b > awk.txt

in mac:

#pdf
man -t awk |open -f -a /Applications/Preview.app
 
#html
cat `man -w awk` |groff -mmandoc -Thtml > awk.html