clone only part or woof-CE (e.g. just clone the ppm)

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Post Reply
Message
Author
s243a
Posts: 2580
Joined: Tue 02 Sep 2014, 04:48
Contact:

clone only part or woof-CE (e.g. just clone the ppm)

#1 Post by s243a »

How to

If one wants to contribute to puppylinux they might do something like this:

Code: Select all

git clone git@github.com:puppylinux-woof-CE/woof-CE.git -b testing "new-branch"
cd "new-branch"
git checkout -b "new-branch"
#Make code changes
git add .
#Set remote to your fork of woof-CE
git remote origin set-url git@some-olther-url.git
git push origin "new-branch"
#Create a merge/pull request
The issue here is if you do several patches you don't need all of the files. If you do several patches to the woof-CE code then you are wasting space. Also perhaps you want to work on a part of woof-CE (e.g. the ppm) outside of woof-CE for a bit.

One way that we can clone only part of woof-CE is do a spare checkout. First we setup our local repo:

Code: Select all

#/bin/sh
[ -z "$2" ] && set -- "$1" ppm #ppm is the default second argument
mkdir "$2" 
cd "$2"
if [ "$1" = init ] || [ "$1" = all ]; then
  
   
  git init
  git remote add origin git@github.com:puppylinux-woof-CE/woof-CE.git
  git remote add –f origin git@github.com:puppylinux-woof-CE/woof-CE.git
  git config core.sparsecheckout true
fi
Then we decide which parts of the repo we want to clone:

Code: Select all

if [ "$1" = add_checkouts ] || [ "$1" = all ]; then
	#Main Directory
	echo /woof-code/rootfs-skeleton/usr/local/petget/ >> .git/info/sparse-checkout
	#Another important directory
	echo /woof-code/rootfs-packages/check_deps_gui >> .git/info/sparse-checkout
...
fi
If we are interested in the package manager some things that we might want to include are some symlinks:

Code: Select all

	echo /woof-code/rootfs-skeleton/usr/local/bin/ppm >> .git/info/sparse-checkout
	echo /woof-code/rootfs-skeleton/root/.packages >> .git/info/sparse-checkout
	echo /woof-code/rootfs-skeleton/usr/sbin/petget >> .git/info/sparse-checkout
        echo /woof-code/rootfs-skeleton/usr/sbin/dotpup1 >> .git/info/sparse-checkout
Some scripts for converting package types:

Code: Select all

	echo /woof-code/rootfs-skeleton/usr/bin/dir2pet >> .git/info/sparse-checkout
	echo /woof-code/rootfs-skeleton/usr/bin/dirs2pets >> .git/info/sparse-checkout
	echo /woof-code/rootfs-skeleton/usr/bin/dotpet >> .git/info/sparse-checkout
	echo /woof-code/rootfs-skeleton/usr/bin/pet2tgz >> .git/info/sparse-checkout
	echo /woof-code/rootfs-skeleton/usr/bin/petspec >> .git/info/sparse-checkout
	echo /woof-code/rootfs-skeleton/usr/bin/tgz2pet >> .git/info/sparse-checkout
	echo /woof-code/rootfs-skeleton/usr/sbin/dotpup1 >> .git/info/sparse-checkout
The script that is called when someone clicks on the install icon in the desktop or top tray:

Code: Select all

echo /woof-code/rootfs-skeleton/usr/sbin/dotpup >> .git/info/sparse-checkout


Perhaps some empty directories:

Code: Select all

echo /woof-code/rootfs-skeleton/var/packages >> .git/info/sparse-checkout

the petget.desktop file:

Code: Select all

	#This defines the menu item for the package manager. 
	echo /woof-code/rootfs-skeleton/usr/share/applications/petget.desktop
the license:

Code: Select all

echo LICENSE >> .git/info/sparse-checkout 
And maybe some of the woof code to build a puppy:

Code: Select all

    echo /woof-code/0setup >> .git/info/sparse-checkout	
	echo /woof-code/PKGS_MANAGEMENT >> .git/info/sparse-checkout	
	echo /woof-code/_00build.conf >> .git/info/sparse-checkout
    echo /woof-distro >> .git/info/sparse-checkout 
The reason for the latter is that these files and directories either contain or build important configuration files for the puppy package manager.

Anyway, once we have setup our local sparese-clone then cd into the directory and pull from woof-CE:

Code: Select all

cd ppm
git pull origin testing
And like before we can now checkout our new branch, make code changes, commit, push to our fork and then merge with the official woof-CE.

Complete script

The complete script can be found at:

https://pastebin.com/tr1rX3dM -- clone_ppm
** use raw view to copy form pastebin

I suggest creating a folder called ppm. Open up a terminal in this folder:

Code: Select all

chomod +x ppm
clone_ppm all "branch_name" #This both initiates our git repo and sets up the files for a sparce pull
cd "branch_name"
git pull origin testing
git checkout -b "branch_name"
Create a New Repo

I created a new repo on github called ppm via the web interface, and then did the following commands to push the code to this repo.

Code: Select all

get remote rename origin origin_old
git remote add origin https://github.com/s243a/ppm.git
git --prune push origin testing 
** The --prune option is critical. WIthout it you will end up pushing the entire woof-CE repo to your new repository rather than the specific parts that we selected for local checkout.

References / links / notes
1 - https://stackoverflow.com/questions/600 ... 1#13738951
2 - http://jasonkarns.com/blog/2011/11/15/s ... -checkout/
3 - http://schacon.github.io/git/git-read-t ... e_checkout
Last edited by s243a on Sat 07 Mar 2020, 08:16, edited 1 time in total.
Find me on [url=https://www.minds.com/ns_tidder]minds[/url] and on [url=https://www.pearltrees.com/s243a/puppy-linux/id12399810]pearltrees[/url].

s243a
Posts: 2580
Joined: Tue 02 Sep 2014, 04:48
Contact:

#2 Post by s243a »

I was originally going to push this to gitlab but I made a mistake and gitlab wouldn't let me immediately delete it, so I"m pushing it to github instead:

See:
"Preventing accidental project deletion via soft delete"
https://gitlab.com/gitlab-org/gitlab/is ... _301109209
Find me on [url=https://www.minds.com/ns_tidder]minds[/url] and on [url=https://www.pearltrees.com/s243a/puppy-linux/id12399810]pearltrees[/url].

s243a
Posts: 2580
Joined: Tue 02 Sep 2014, 04:48
Contact:

#3 Post by s243a »

The --prune option didn't work either, when pushing to github. So far the this sparse checkout is only working to pull to my local computer but the sparseness is lost when I push to github or gitlab :(

I wonder if I checkout a new branch before pushing if that would help. Maybe I"ll try that tomorrow.

Edit: Another possibly is that I should of deleted the old origin (from woof-CE) rather than renaming it.
Find me on [url=https://www.minds.com/ns_tidder]minds[/url] and on [url=https://www.pearltrees.com/s243a/puppy-linux/id12399810]pearltrees[/url].

Post Reply