summarylogtreecommitdiffstats
path: root/larksuite-bin.install
blob: 1dd7bd5b3b625e2057a94e5e990339124b0b168b (plain)
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
post_install() {
  # Add icons to the system icons
  XDG_ICON_RESOURCE="`which xdg-icon-resource 2> /dev/null || true`"
  if [ ! -x "$XDG_ICON_RESOURCE" ]; then
    echo "Error: Could not find xdg-icon-resource" >&2
    exit 1
  fi
  for icon in product_logo_48.png product_logo_24.png product_logo_256.png product_logo_16.png product_logo_64.png product_logo_128.png product_logo_32.png ; do
    size="$(echo ${icon} | sed 's/[^0-9]//g')"
    "$XDG_ICON_RESOURCE" install --size "${size}" "/opt/bytedance/lark/${icon}" \
      "bytedance-lark"
  done

  UPDATE_MENUS="`which update-mime-database usr/share/mime &> /dev/null 2> /dev/null || true`"
  if [ -x "$UPDATE_MENUS" ]; then
    update-mime-database usr/share/mime &> /dev/null
  fi

  # Update cache of .desktop file MIME types. Non-fatal since it's just a cache.
  update-desktop-database > /dev/null 2>&1 || true

  NSS_FILES="libnspr4.so.0d libplds4.so.0d libplc4.so.0d libssl3.so.1d \
      libnss3.so.1d libsmime3.so.1d libnssutil3.so.1d"

  add_nss_symlinks() {
    get_lib_dir
    for f in $NSS_FILES
    do
      target=$(echo $f | sed 's/\.[01]d$//')
      if [ -f "/$LIBDIR/$target" ]; then
        ln -snf "/$LIBDIR/$target" "/opt/bytedance/lark/$f"
      elif [ -f "/usr/$LIBDIR/$target" ]; then
        ln -snf "/usr/$LIBDIR/$target" "/opt/bytedance/lark/$f"
      else
        echo $f not found in "/$LIBDIR/$target" or "/usr/$LIBDIR/$target".
        exit 1
      fi
    done
  }

  remove_nss_symlinks() {
    for f in $NSS_FILES
    do
      rm -rf "/opt/bytedance/lark/$f"
    done
  }

  remove_udev_symlinks() {
    rm -rf "/opt/bytedance/lark/libudev.so.0"
  }

  remove_udev_symlinks
}

post_upgrade() {
  post_install
}

pre_remove() {
  action="$1"
  if [ "$2" = "in-favour" ]; then
    # Treat conflict remove as an upgrade.
    action="upgrade"
  fi
  # Don't clean-up just for an upgrade.`
  if [ "$action" = "upgrade" ] ; then
        return
  fi

  # Remove icons from the system icons
  XDG_ICON_RESOURCE="`which xdg-icon-resource 2> /dev/null || true`"
  if [ ! -x "$XDG_ICON_RESOURCE" ]; then
    echo "Error: Could not find xdg-icon-resource" >&2
    exit 1
  fi
  for icon in product_logo_48.png product_logo_24.png product_logo_256.png product_logo_16.png product_logo_64.png product_logo_128.png product_logo_32.png ; do
    size="$(echo ${icon} | sed 's/[^0-9]//g')"
    "$XDG_ICON_RESOURCE" uninstall --size "${size}" "bytedance-lark"
  done

  UPDATE_MENUS="`which update-mime-database usr/share/mime &> /dev/null 2> /dev/null || true`"
  if [ -x "$UPDATE_MENUS" ]; then
    update-mime-database usr/share/mime &> /dev/null
  fi

  # Update cache of .desktop file MIME types. Non-fatal since it's just a cache.
  update-desktop-database > /dev/null 2>&1 || true
}

post_remove() {
  action="$1"

  # Only do complete clean-up on purge.
  if [ "$action" != "purge" ] ; then
        return
  fi

  NSS_FILES="libnspr4.so.0d libplds4.so.0d libplc4.so.0d libssl3.so.1d \
      libnss3.so.1d libsmime3.so.1d libnssutil3.so.1d"

  add_nss_symlinks() {
    get_lib_dir
    for f in $NSS_FILES
    do
      target=$(echo $f | sed 's/\.[01]d$//')
      if [ -f "/$LIBDIR/$target" ]; then
        ln -snf "/$LIBDIR/$target" "/opt/bytedance/lark/$f"
      elif [ -f "/usr/$LIBDIR/$target" ]; then
        ln -snf "/usr/$LIBDIR/$target" "/opt/bytedance/lark/$f"
      else
        echo $f not found in "/$LIBDIR/$target" or "/usr/$LIBDIR/$target".
        exit 1
      fi
    done
  }

  {
    for f in $NSS_FILES
    do
      rm -rf "/opt/bytedance/lark/$f"
    done
  }

  {
    rm -rf "/opt/bytedance/lark/libudev.so.0"
  }

  remove_udev_symlinks
}