File: Fritzing

package info (click to toggle)
fritzing 1.0.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 42,144 kB
  • sloc: cpp: 98,203; xml: 2,203; python: 803; sh: 274; ansic: 26; makefile: 22
file content (78 lines) | stat: -rw-r--r-- 2,765 bytes parent folder | download
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
#! /bin/sh

SHARED_PARTS_DIR=/usr/share/fritzing/parts
DATABASE_DISTRIB=/usr/share/fritzing/parts.db.distrib
LOCAL_FRITZING=${HOME}/.local/lib/fritzing
LOCAL_DATABASE=${LOCAL_FRITZING}/fritzing-parts/parts.db
FRITZING_REAL=/usr/bin/fritzing.real

local_fritzing_parts_create_if_needed() {
    ###create and populate .local/lib/fritzing/fritzing-parts if needed ###

    # create a local directory for parts
    [ -d ${LOCAL_FRITZING}/fritzing-parts/svg ] || \
	mkdir -p ${LOCAL_FRITZING}/fritzing-parts/svg

    # create symlinks from this local directory to shared parts subdirectories
    # first, from ${SHARED_PARTS_DIR}
    for d in bins core  obsolete  scripts; do
	[ -e ${LOCAL_FRITZING}/fritzing-parts/$d ] || \
	    ln -s ${SHARED_PARTS_DIR}/$d ${LOCAL_FRITZING}/fritzing-parts/
    done
    # later, from ${SHARED_PARTS_DIR}/svg
    for d in core  obsolete; do
	[ -e ${LOCAL_FRITZING}/fritzing-parts/svg/$d ] || \
	    ln -s ${SHARED_PARTS_DIR}/svg/$d \
	       ${LOCAL_FRITZING}/fritzing-parts/svg/
    done

    # for other subdirectories make a deep copy
    for d in contrib user; do
	# first, from ${SHARED_PARTS_DIR}
	[ -e ${LOCAL_FRITZING}/fritzing-parts/$d ] || \
	    cp -Rd ${SHARED_PARTS_DIR}/$d ${LOCAL_FRITZING}/fritzing-parts/
	# later, from ${SHARED_PARTS_DIR}/svg
	[ -e ${LOCAL_FRITZING}/fritzing-parts/svg/$d ] || \
	    cp -Rd ${SHARED_PARTS_DIR}/svg/$d \
	       ${LOCAL_FRITZING}/fritzing-parts/svg/
    done
}

local_database_create_if_needed () {
    ### copy a template database if there is none locally ###############
    [ -f ${LOCAL_DATABASE} ] || \
	cp ${DATABASE_DISTRIB} ${LOCAL_DATABASE}
}

local_app_create_if_needed () {
    ### create and populate .local/lib/fritzing/app if needed ###########

    [ -d ${LOCAL_FRITZING}/app ] || mkdir -p ${LOCAL_FRITZING}/app

    [ -f ${LOCAL_FRITZING}/app/Fritzing ] || \
	cp ${FRITZING_REAL} ${LOCAL_FRITZING}/app/Fritzing

    for d in help sketches translations; do
	[ -e ${LOCAL_FRITZING}/app/$d ] || \
	    ln -s /usr/share/fritzing/$d ${LOCAL_FRITZING}/app
    done
}

local_fritzing_parts_create_if_needed
local_database_create_if_needed
local_app_create_if_needed

global_version=$(${FRITZING_REAL} --version | grep debian | sed 's%.*debian/\(.*\)%\1%')
local_version=$(${LOCAL_FRITZING}/app/Fritzing --version | grep debian | \
		    sed 's%.*debian/\(.*\)%\1%')

if dpkg --compare-versions "$global_version" gt "$local_version"; then
    if zenity --question --text="There is a new Fritzing version installed: $global_version. Should we replace the former version with the new one?"
    then
	rm -rf ${LOCAL_FRITZING}/app
	local_app_create_if_needed
    fi
fi

################ launch fritzing #####################################
exec ${LOCAL_FRITZING}/app/Fritzing "$@"