archlinux / contrib

Arch contrib scripts
GNU General Public License v2.0
63 stars 18 forks source link

Add aurify (an alternative of repos2aur). #42

Closed SantiagoTorres closed 3 months ago

SantiagoTorres commented 3 years ago

I mostly wanted to document this somewhere, I wonder if we can borrow pages for the repos2aur version.

ArchangeGabriel commented 3 years ago

I like your name better, but not sure we should have two different tools for the job. How about enhancing repos2aur and renaming it to aurify? :)

Also currently I guess your tool would not work if an AUR repo already existed. This step is taken into account in repos2aur, however this one does not retain the history. I guess we need something like git rebase --committer-date-is-author-date to rebase the community tree on top of the AUR one in this case? With something like forcefully overwriting all files in the first commit of the rebase, because it would likely not rebase cleanly…

SantiagoTorres commented 3 years ago

Oh most definitely. I think we can borrow some stuff from here and add it to repos2aur in the long term, which seems more mature. I just wanted to keep this open while we figure out what we want to do with it :D

jelly commented 3 years ago

This looks cool, would be nice to combine it with repos2aur

ArchangeGabriel commented 2 years ago

Here is my attempt at merging this with repos2aur, but I could not test the case of an existing repo. I expect rebase conflicts, but not sure how to handle them:

#!/bin/bash

# Script to move things from community to AUR while preserving the history

# SPDX-License-Identifier: GPL-2.0

if (( $# == 0 )); then
  echo "error: No arguments passed."
  echo "pkgbase is a required argument"
  exit 1
fi

PKGBASE=$1

TMPDIR=$(mktemp -d)

function cleanup {
  rm -rf "$TMPDIR"
}

trap cleanup EXIT

# Get the AUR repository even if empty
git clone "ssh://aur@aur.archlinux.org/$PKGBASE.git" $TMPDIR
pushd $TMPDIR
# Get the community history
git fetch https://github.com/archlinux/svntogit-community "packages/$PKGBASE":community
git checkout community
# Split the trunk folder
git subtree split -b trunk -P trunk HEAD
git checkout trunk
# Add .SRCINFO to satisfy the AUR hook
FILTER_BRANCH_SQUELCH_WARNING=1 git filter-branch --tree-filter 'makepkg --printsrcinfo > .SRCINFO'
# Merge back to master
if [[ $(git branch --list master) ]]; then
    git rebase --committer-date-is-author-date master
else
    git branch --copy trunk master
fi
git checkout master
git push origin master
popd
jelly commented 2 years ago

Here is my attempt at merging this with repos2aur, but I could not test the case of an existing repo. I expect rebase conflicts, but not sure how to handle them:

#!/bin/bash

# Script to move things from community to AUR while preserving the history

# SPDX-License-Identifier: GPL-2.0

if (( $# == 0 )); then
  echo "error: No arguments passed."
  echo "pkgbase is a required argument"
  exit 1
fi

PKGBASE=$1

TMPDIR=$(mktemp -d)

function cleanup {
  rm -rf "$TMPDIR"
}

trap cleanup EXIT

# Get the AUR repository even if empty
git clone "ssh://aur@aur.archlinux.org/$PKGBASE.git" $TMPDIR
pushd $TMPDIR
# Get the community history
git fetch https://github.com/archlinux/svntogit-community "packages/$PKGBASE":community
git checkout community
# Split the trunk folder
git subtree split -b trunk -P trunk HEAD
git checkout trunk
# Add .SRCINFO to satisfy the AUR hook
FILTER_BRANCH_SQUELCH_WARNING=1 git filter-branch --tree-filter 'makepkg --printsrcinfo > .SRCINFO'
# Merge back to master
if [[ $(git branch --list master) ]]; then
    git rebase --committer-date-is-author-date master
else
    git branch --copy trunk master
fi
git checkout master
git push origin master
popd

So this is an attempt to retain history, that sounds fine to me. It just needs a way to handle community/extra which wasn't an issue when giving a dir. Do you want me to rewrite the current repos2aur script?

ArchangeGabriel commented 2 years ago

@jelly Just merge community and extra and be done with it. ;p I could add a first arg that is either extra or community to know where to get the history from. But I still need to test the “existing” case anyway.

jelly commented 2 years ago

@jelly Just merge community and extra and be done with it. ;p I could add a first arg that is either extra or community to know where to get the history from. But I still need to test the “existing” case anyway.

Ok, so you are going to send a PR for the merging?

ArchangeGabriel commented 2 years ago

Yeah, once I have tested the “existing” scenario (soon, as I’ll drop arrow/orc).

ArchangeGabriel commented 2 years ago

So I’ve pushed a new version of aurify that almost work in the existing case (that ended up actually both much more complex and simple than I expected). It mostly works, excepted that…

$ ./aurify react-native-debugger
Cloning into '/tmp/tmp.WdZj6rylnM'...
remote: Enumerating objects: 126, done.
remote: Counting objects: 100% (126/126), done.
remote: Compressing objects: 100% (80/80), done.
remote: Total 126 (delta 45), reused 126 (delta 45), pack-reused 0
Receiving objects: 100% (126/126), 63.82 KiB | 233.00 KiB/s, done.
Resolving deltas: 100% (45/45), done.
/tmp/tmp.WdZj6rylnM /tmp/contrib/aur
remote: Enumerating objects: 235, done.
remote: Counting objects: 100% (29/29), done.
remote: Compressing objects: 100% (28/28), done.
remote: Total 235 (delta 16), reused 1 (delta 0), pack-reused 206
Receiving objects: 100% (235/235), 43.31 KiB | 197.00 KiB/s, done.
Resolving deltas: 100% (45/45), done.
From https://github.com/archlinux/svntogit-community
 * [new branch]      packages/react-native-debugger -> community
Switched to branch 'community'
Created branch 'trunk'
5d8a9894d47d8b86d05e6d1e1b85e48416c81ac3
Switched to branch 'trunk'
Rewrite 5d8a9894d47d8b86d05e6d1e1b85e48416c81ac3 (27/28) (14 seconds passed, remaining 0 predicted)    
Ref 'refs/heads/trunk' was rewritten
Switched to branch 'master'
Your branch is up to date with 'origin/master'.
Updating bab5ba7..b642911
Fast-forward
 .SRCINFO                        |  30 ++++++++++++++++--------------
 .gitignore                      |   6 ------
 PKGBUILD                        |  93 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------------
 disable-context-isolation.patch |  10 ++++++++++
 icon.png                        | Bin 38619 -> 0 bytes
 iconPath.patch                  |  11 +++++++++++
 react-native-debugger.desktop   |   9 ++++-----
 react-native-debugger.js        |  32 ++++++++++++++++++++++++++++++++
 8 files changed, 132 insertions(+), 59 deletions(-)
 delete mode 100644 .gitignore
 create mode 100644 disable-context-isolation.patch
 delete mode 100644 icon.png
 create mode 100644 iconPath.patch
 create mode 100644 react-native-debugger.js
Enumerating objects: 131, done.
Counting objects: 100% (131/131), done.
Delta compression using up to 8 threads
Compressing objects: 100% (111/111), done.
Writing objects: 100% (131/131), 32.48 KiB | 8.12 MiB/s, done.
Total 131 (delta 74), reused 47 (delta 20), pack-reused 0
remote: Resolving deltas: 100% (74/74), done.
remote: Checking connectivity: 131, done.
remote: error: denying non-fast-forward (you should pull first)
remote: error: hook declined to update refs/heads/master
To ssh://aur.archlinux.org/react-native-debugger.git
 ! [remote rejected] master -> master (hook declined)
error: failed to push some refs to 'ssh://aur.archlinux.org/react-native-debugger.git'
/tmp/contrib/aur

I don’t know what’s going wrong, because at that point if going into the directory (comment the trap line of aurify to keep it):

$ git pull
Current branch master is up to date.

and

$ git status
On branch master
Your branch is ahead of 'origin/master' by 28 commits.
  (use "git push" to publish your local commits)

nothing to commit, working tree clean

Of course there is still the possibility to use AUR_OVERWRITE=1, but as it should not be necessary I preferred to keep this case of react-debugger-native around so someone can figure it out.

jelly commented 2 years ago

Tried it here:

[jelle@t14s][~/projects/contrib]%./aur/aurify python-eyed3
Cloning into '/tmp/tmp.dFqKR1yLro'...
remote: Enumerating objects: 8, done.
remote: Counting objects: 100% (8/8), done.
remote: Compressing objects: 100% (8/8), done.
remote: Total 8 (delta 0), reused 8 (delta 0), pack-reused 0
Receiving objects: 100% (8/8), done.
/tmp/tmp.dFqKR1yLro ~/projects/contrib
fatal: couldn't find remote ref packages/python-eyed3
error: pathspec 'community' did not match any file(s) known to git
'trunk' does not exist; use 'git subtree add'
error: pathspec 'trunk' did not match any file(s) known to git
Rewrite 86f635d6a4a3327a3adb372d654b02755627ad92 (2/2) (1 seconds passed, remaining 0 predicted)
Ref 'refs/heads/master' was rewritten
fatal: ambiguous argument 'trunk': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
Already on 'master'
Your branch and 'origin/master' have diverged,
and have 1 and 2 different commits each, respectively.
  (use "git pull" to merge the remote branch into yours)
merge: trunk - not something we can merge
ArchangeGabriel commented 2 years ago

@jelly The tree does not exist in the svn2git repository. I guess you’ve already ran svn rm python-eyed3? In this case there is nowhere the history can be retrieved in order to push it to the AUR, it’s just lost.

ArchangeGabriel commented 2 years ago

Maybe we should edit https://wiki.archlinux.org/title/DeveloperWiki:HOWTO_Be_A_Packager#Removing_a_Package and tell to consider moving to the AUR before removing the tree.

jelly commented 3 months ago

We have pkgctl aur drop-from-repo now