浏览代码

Compile profanity from source with omemo support

Bob Mottram 8 年前
父节点
当前提交
7d7591f235
共有 1 个文件被更改,包括 95 次插入3 次删除
  1. 95
    3
      src/freedombone-app-xmpp

+ 95
- 3
src/freedombone-app-xmpp 查看文件

@@ -46,6 +46,15 @@ prosody_nightly_hash='f1fdc8ce5b6f8bfa451d458616a0bbe5ed7c15881415e561586bab39bd
46 46
 prosody_filename=prosody-${prosody_latest_version}-1nightly${prosody_nightly}
47 47
 prosody_nightly_url="https://prosody.im/nightly/${prosody_latest_version}/latest/${prosody_filename}.tar.gz"
48 48
 
49
+LIBMESODE_REPO="https://github.com/boothj5/libmesode"
50
+LIBMESODE_COMMIT='e3db0e9bfba61b2d82193874343a94a88f910800'
51
+
52
+PROFANITY_REPO="https://github.com/boothj5/profanity"
53
+PROFANITY_COMMIT='b64646979ea50a13d0c7ec0b1a46969f661569a8'
54
+
55
+PROFANITY_OMEMO_PLUGIN_REPO="https://github.com/ReneVolution/profanity-omemo-plugin"
56
+PROFANITY_OMEMO_PLUGIN_COMMIT='8abc5bc1bf16e051d89824b9981fcd137ba03e78'
57
+
49 58
 xmpp_variables=(ONION_ONLY
50 59
                 INSTALLED_WITHIN_DOCKER
51 60
                 XMPP_CIPHERS
@@ -126,6 +135,12 @@ function change_password_xmpp {
126 135
     echo ''
127 136
     echo $'Currently Prosody requires password changes to be done interactively'
128 137
     prosodyctl passwd ${curr_username}@${DEFAULT_DOMAIN_NAME}
138
+
139
+    XMPP_CLIENT_DIR=/home/$curr_username/.local/share/profanity
140
+    XMPP_CLIENT_ACCOUNTS=$XMPP_CLIENT_DIR/accounts
141
+    if [ -f $XMPP_CLIENT_ACCOUNTS ]; then
142
+        sed -i "s|password=.*|password=$new_user_password|g" $XMPP_CLIENT_ACCOUNTS
143
+    fi
129 144
 }
130 145
 
131 146
 function reconfigure_xmpp {
@@ -183,6 +198,38 @@ function upgrade_xmpp {
183 198
         rm ${INSTALL_DIR}/${prosody_filename}.tar.gz
184 199
     fi
185 200
     systemctl restart prosody
201
+
202
+    # update profanity client
203
+    function_check set_repo_commit
204
+    set_repo_commit $INSTALL_DIR/libmesode "libmesode commit" "$LIBMESODE_COMMIT" $LIBMESODE_REPO
205
+    cd $INSTALL_DIR/libmesode
206
+    ./bootstrap.sh
207
+    ./configure
208
+    make
209
+    make install
210
+    cp /usr/local/lib/libmesode* /usr/lib
211
+
212
+    function_check set_repo_commit
213
+    set_repo_commit $INSTALL_DIR/profanity "profanity commit" "$PROFANITY_COMMIT" $PROFANITY_REPO
214
+    cd $INSTALL_DIR/profanity
215
+    ./bootstrap.sh
216
+    ./configure --disable-notifications --disable-icons --enable-otr --enable-pgp --enable-plugins --enable-c-plugins --enable-python-plugins --without-xscreensaver
217
+    make
218
+    make install
219
+
220
+    # upgrade omemo plugins for all users
221
+    set_repo_commit $INSTALL_DIR/profanity-omemo-plugin "profanity omemo plugin commit" "$PROFANITY_OMEMO_PLUGIN_COMMIT" $PROFANITY_OMEMO_PLUGIN_REPO
222
+    for d in /home/*/ ; do
223
+        USERNAME=$(echo "$d" | awk -F '/' '{print $3}')
224
+        if [[ $(is_valid_user "$USERNAME") == "1" ]]; then
225
+            if [ ! -d /home/$USERNAME/.local/share/profanity/plugins ]; then
226
+                mkdir -p /home/$USERNAME/.local/share/profanity/plugins
227
+            fi
228
+            cp $INSTALL_DIR/profanity-omemo-plugin/omemo.py /home/$USERNAME/.local/share/profanity/plugins
229
+            chown -R $USERNAME:$USERNAME /home/$USERNAME/.local
230
+        fi
231
+    done
232
+    cp $INSTALL_DIR/profanity-omemo-plugin/omemo.py /etc/skel/.local/share/profanity/plugins
186 233
 }
187 234
 
188 235
 function backup_local_xmpp {
@@ -690,10 +737,55 @@ function install_xmpp_main {
690 737
 }
691 738
 
692 739
 function install_xmpp_client {
740
+    # install profanity from source in order to get OMEMO support
693 741
     if [[ $(app_is_installed xmpp_client) == "1" ]]; then
694 742
         return
695 743
     fi
696
-    apt-get -yq install profanity
744
+    if [ ! -d $INSTALL_DIR ]; then
745
+        mkdir -p $INSTALL_DIR
746
+    fi
747
+
748
+    apt-get -yq install automake autoconf autoconf-archive libtool build-essential
749
+    apt-get -yq install libncursesw5-dev libglib2.0-dev libcurl3-dev sqlite3
750
+    apt-get -yq install libotr5-dev libgpgme11-dev python-dev libreadline-dev
751
+
752
+    # dependency for profanity not available in debian
753
+    git_clone $LIBMESODE_REPO $INSTALL_DIR/libmesode
754
+    cd $INSTALL_DIR/libmesode
755
+    git checkout $LIBMESODE_COMMIT -b $LIBMESODE_COMMIT
756
+    ./bootstrap.sh
757
+    ./configure
758
+    make
759
+    make install
760
+    cp /usr/local/lib/libmesode* /usr/lib
761
+
762
+    # build profanity
763
+    git_clone $PROFANITY_REPO $INSTALL_DIR/profanity
764
+    cd $INSTALL_DIR/profanity
765
+    git checkout $PROFANITY_COMMIT -b $PROFANITY_COMMIT
766
+    ./bootstrap.sh
767
+    ./configure --disable-notifications --disable-icons --enable-otr --enable-pgp --enable-plugins --enable-c-plugins --enable-python-plugins --without-xscreensaver
768
+    make
769
+    make install
770
+
771
+    if [ ! -f /usr/local/bin/profanity ]; then
772
+        echo $'Unable to build profanity'
773
+        exit 7825272
774
+    fi
775
+
776
+    # install the omemo plugin
777
+    git_clone $PROFANITY_OMEMO_PLUGIN_REPO $INSTALL_DIR/profanity-omemo-plugin
778
+    cd $INSTALL_DIR/profanity-omemo-plugin
779
+    git checkout $PROFANITY_OMEMO_PLUGIN_COMMIT -b $PROFANITY_OMEMO_PLUGIN_COMMIT
780
+    if [ ! -f $INSTALL_DIR/profanity-omemo-plugin/omemo.py ]; then
781
+        echo $'omemo.py not found'
782
+        exit 389225
783
+    fi
784
+
785
+    mkdir -p /etc/skel/.local/share/profanity/plugins
786
+    cp $INSTALL_DIR/profanity-omemo-plugin/omemo.py /etc/skel/.local/share/profanity/plugins
787
+    cp $INSTALL_DIR/profanity-omemo-plugin/omemo.py /home/$MY_USERNAME/.local/share/profanity/plugins
788
+    chown -R $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/.local
697 789
 
698 790
     XMPP_CLIENT_DIR=/home/$MY_USERNAME/.local/share/profanity
699 791
     XMPP_CLIENT_ACCOUNTS=$XMPP_CLIENT_DIR/accounts
@@ -706,7 +798,7 @@ function install_xmpp_client {
706 798
         echo 'enabled=true' >> $XMPP_CLIENT_ACCOUNTS
707 799
         echo "jid=${MY_USERNAME}@${DEFAULT_DOMAIN_NAME}" >> $XMPP_CLIENT_ACCOUNTS
708 800
         echo 'resource=profanity' >> $XMPP_CLIENT_ACCOUNTS
709
-        echo "muc.service=conference.${DEFAULT_DOMAIN_NAME}" >> $XMPP_CLIENT_ACCOUNTS
801
+        echo "muc.service=chat.${DEFAULT_DOMAIN_NAME}" >> $XMPP_CLIENT_ACCOUNTS
710 802
         echo "muc.nick=${MY_USERNAME}" >> $XMPP_CLIENT_ACCOUNTS
711 803
         echo 'presence.last=online' >> $XMPP_CLIENT_ACCOUNTS
712 804
         echo 'presence.login=online' >> $XMPP_CLIENT_ACCOUNTS
@@ -730,7 +822,7 @@ function install_xmpp_client {
730 822
         fi
731 823
         echo "jid=${MY_USERNAME}@${XMPP_ONION_HOSTNAME}" >> $XMPP_CLIENT_ACCOUNTS
732 824
         echo 'resource=profanity' >> $XMPP_CLIENT_ACCOUNTS
733
-        echo "muc.service=conference.${XMPP_ONION_HOSTNAME}" >> $XMPP_CLIENT_ACCOUNTS
825
+        echo "muc.service=${XMPP_ONION_HOSTNAME}" >> $XMPP_CLIENT_ACCOUNTS
734 826
         echo "muc.nick=${MY_USERNAME}" >> $XMPP_CLIENT_ACCOUNTS
735 827
         echo 'presence.last=online' >> $XMPP_CLIENT_ACCOUNTS
736 828
         echo 'presence.login=online' >> $XMPP_CLIENT_ACCOUNTS