File: dic2ipk.sh

package info (click to toggle)
freedict-tools 0.7.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,520 kB
  • sloc: python: 2,869; haskell: 1,999; perl: 1,509; yacc: 502; sh: 435; sed: 392; makefile: 141; xml: 10
file content (109 lines) | stat: -rwxr-xr-x 2,729 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#!/bin/bash
# this script packages .dic (or .dic.dz) files
# for the zbedic program on the Zaurus platform
# into .ipk (installable packages)

# the iPKG file format is loosely based on Debian's
# package format. iPKG is documented at:
#
#   * http://www.zaurususergroup.com/modules.php?op=modload&name=phpWiki&file=index&pagename=IPKG%20Howto
#   * http://www.ossh.com/zaurus/mirrors/docs.zaurus.com/ipkg_howto.shtml
#     (same text like forst page)
#   * http://www.handhelds.org/
#     (The forst two links refer to the wiki here as reference, but
#      that page is currently (Jan 2005) unavailable

# ===== the filenames
INFILE=$1
EXTENSION=${INFILE#*.}
OUTFILE=`basename ${1/.$EXTENSION}`

# ===== check the syntax
if [[ "$1" == "" ]]; then
    echo "USAGE: $0 <zbedic FreeDict Dictionary>"
    exit 1
fi

# ==== is there a file-conflict
if [ -d ./home ]; then
    echo "There's already a ./home folder. Please remove that first!"
    exit 1
fi
if [ -e ./control ]; then
    echo "There's already a control file. Remove it first!"
    exit 1
fi
if [ -e ./control.tar.gz ]; then
    echo "There's already a control.tar.gz file. Remove it first!"
    exit 1
fi
if [ -e ./data.tar.gz ]; then
    echo "There's already a data.tar.gz file. Remove it first!"
    exit 1
fi

# ===== image type for the maps

# ===== make it lowercase
EXTENSION=`echo "$EXTENSION" | tr [A-Z] [a-z]`

if [[ "$EXTENSION" == "jpeg" ]]; then
    EXTENSION=jpg
fi

# ===== no converter specified?
#if [[ "`which convert`" == "" ]]; then
#    echo Cannot find the program convert!
#    exit 2
#fi
if [[ "$EXTENSION" == "" ]]; then
    echo Cannot identify the image-type or cannot find the file!
    exit 2
fi
if [ -d ./${OUTFILE} ]; then
    echo "There's already an image folder ${OUTFILE}."
    exit 2
fi


# ===== renaming files

# ===== adding overview

# ===== leaving image-folder

# ===== creating folders for ipkg

mkdir ./home
mkdir ./home/QtPalmtop
mkdir ./home/QtPalmtop/share
mkdir ./home/QtPalmtop/share/zbedic

# ===== moving the image-files into the right folder
cp ${INFILE} ./home/QtPalmtop/share/zbedic/

# ===== make a nice ipkg
DATE=$(date +"%Y%m%d")
FILE=./zbedic-${OUTFILE}_${DATE}_arm.ipk

# ===== package-information
echo -ne "Package: FreeDict-${OUTFILE}
InstalledSize: $(du -sh ./home | cut -f1)
Filename: ${FILE}
Maintainer: $(whoami)
Architecture: arm
Version: ${DATE}
Description: FreeDict ${OUTFILE} dictionary for zbedic
" > ./control

# ===== creating
tar -czf data.tar.gz ./home
tar -czf control.tar.gz ./control
tar -czf ${FILE} ./data.tar.gz ./control.tar.gz

# ===== removing temp-files
rm ./data.tar.gz ./control.tar.gz ./control

# ===== removing the NEW folders and NEW created images
rm -rf ./home
echo ${FILE}