Created
March 15, 2018 09:07
-
-
Save nsmr0604/e87ec397c1222ae9932a253925d0a8fc to your computer and use it in GitHub Desktop.
Elecom製の激安NAS[NSB-3NR series]のopkgパッケージをバックアップした ref: https://qiita.com/nsmr0604@github/items/e4d8fc20cd0b5a914a28
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# start script use busybox. | |
# set env | |
#PKGINFO=/var/lib/dpkg/info | |
PKGINFO=/usr/lib/opkg/info | |
PKGNAME=$1.pkg | |
PKGVER=_$3 | |
[ $PKGVER != _ ] && PKGNAME=$1$PKGVER.pkg | |
WORK=/tmp/$1.work | |
# mkdir work dir | |
mkdir -p $WORK/control.d | |
mkdir -p $WORK/data.d | |
# copy control and script | |
for file in $(ls $PKGINFO/$1.*) ; do | |
cp $file $WORK/control.d/${file##*.} | |
done | |
# copy files from list | |
while read line ; do | |
[ -d $line ] && continue | |
[ ! -d $WORK/data.d${line%/*} ] && mkdir -p $WORK/data.d${line%/*} | |
cp $line $WORK/data.d$line | |
done < $WORK/control.d/list | |
# pack data.tar.gz | |
tar -C $WORK/data.d -czf $WORK/data.tar.gz . | |
rm -rf $WORK/data.d | |
# pack control.tar.gz | |
rm $WORK/control.d/list | |
tar -C $WORK/control.d -czf $WORK/control.tar.gz . | |
rm -rf $WORK/control.d | |
# make package | |
echo '2.0' > $WORK/debian-binary | |
cd $WORK && ar -r $PKGNAME debian-binary control.tar.gz data.tar.gz && cd $OLDPD | |
# copy package to current | |
cp $WORK/$PKGNAME $PWD/ | |
# delete work dir | |
rm -rf $WORK | |
# end script | |
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
root@NAS:~# which sh | |
/usr/local/xbin/sh | |
root@NAS:~# sh --help | |
BusyBox v1.28.1 (2018-02-15 14:34:02 CET) multi-call binary. | |
Usage: sh [-/+OPTIONS] [-/+o OPT]... [-c 'SCRIPT' [ARG0 [ARGS]] / FILE [ARGS]] | |
Unix shell interpreter | |
root@NAS:~# opkg list-installed | xargs -n 3 mkPkg | |
(省略) | |
root@NAS:~# ls nasmiru* | |
nasmiruagentD_1.0-1.pkg | |
root@NAS:~# |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment